org.apache.jmeter.functions.InvalidVariableException Java Examples
The following examples show how to use
org.apache.jmeter.functions.InvalidVariableException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FifoPop.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String fifoName = ((CompoundVariable) values[0]).execute(); String value = null; try { Object valueObj = FifoMap.getInstance().pop(fifoName, timeout); if (valueObj != null) { value = valueObj.toString(); } } catch (InterruptedException ex) { log.warn("Interrupted pop from queue " + fifoName); value = "INTERRUPTED"; } JMeterVariables vars = getVariables(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, value); } return value; }
Example #2
Source File: If.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String actual = getParameter(0); String expected = getParameter(1); String result = null; if (actual.equals(expected)) { result = getParameter(2).toString(); } else { result = getParameter(3).toString(); } JMeterVariables vars = getVariables(); if (vars != null && values.length > 4) { String varName = getParameter(4).trim(); vars.put(varName, result); } return result; }
Example #3
Source File: StrReplace.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String totalString = getParameter(0).replace(getParameter(1), getParameter(2)); JMeterVariables vars = getVariables(); if (values.length > 3) { String varName = getParameter(3); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, totalString); } } return totalString; }
Example #4
Source File: StrReplaceRegex.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String totalString = getParameter(0).replaceAll(getParameter(1), getParameter(2)); JMeterVariables vars = getVariables(); if (values.length > 3) { String varName = getParameter(3); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, totalString); } } return totalString; }
Example #5
Source File: Env.java From jmeter-plugins with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String propertyName = values[0].execute(); String propertyDefault = propertyName; if (values.length > 2) { // We have a 3rd parameter propertyDefault = values[2].execute(); } String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) {// Allow for empty name final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, propertyValue); } } } return propertyValue; }
Example #6
Source File: MD5.java From jmeter-plugins with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String str = ((CompoundVariable) values[0]).execute(); MessageDigest digest; try { digest = MessageDigest.getInstance("md5"); } catch (NoSuchAlgorithmException ex) { return "Error creating digest: " + ex; } String res = JOrphanUtils.baToHexString(digest.digest(str.getBytes())); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, res); } return res; }
Example #7
Source File: SetVariablesActionTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testSample() throws InvalidVariableException { System.out.println("next"); Arguments args = new Arguments(); args.addArgument("var2", "${var1}"); args.addArgument("var3", "${var2}"); instance.setUserDefinedVariables(args); ValueReplacer replacer = new ValueReplacer(); replacer.replaceValues(instance); args.setRunningVersion(true); instance.sample(null); JMeterVariables vars = JMeterContextService.getContext().getVariables(); assertEquals("${var2}", vars.get("var3")); assertEquals("val1", vars.get("var2")); instance.sample(null); assertEquals("val1", vars.get("var3")); }
Example #8
Source File: ParameterizedControllerTest.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Test public void testNext() throws InvalidVariableException { System.out.println("next"); Arguments args = new Arguments(); args.addArgument("var2", "${var1}"); args.addArgument("var3", "${var2}"); instance.setUserDefinedVariables(args); ValueReplacer replacer = new ValueReplacer(); replacer.replaceValues(instance); args.setRunningVersion(true); instance.next(); JMeterVariables vars = JMeterContextService.getContext().getVariables(); assertEquals("${var2}", vars.get("var3")); assertEquals("val1", vars.get("var2")); instance.next(); assertEquals("val1", vars.get("var3")); }
Example #9
Source File: IsDefined.java From jmeter-plugins with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String res = ((CompoundVariable) values[0]).execute().trim(); if (vars != null) { Object var = vars.getObject(res); if (var != null) { return "1"; } } return "0"; }
Example #10
Source File: CaseFormat.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String originalString = values[0].execute(); String mode = null; // default if (values.length > 1) { mode = values[1].execute(); } if (StringUtils.isEmpty(mode)) { mode = CaseFormatMode.LOWER_CAMEL_CASE.getName(); // default } String targetString = changeCase(originalString, mode); if (values.length > 2) { addVariableValue(targetString, values[2].execute().trim()); } return targetString; }
Example #11
Source File: Substring.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String str = getParameter(0); int begin = Integer.parseInt(getParameter(1).trim()); int len = Integer.parseInt(getParameter(2).trim()); String totalString = str.substring(begin, len); JMeterVariables vars = getVariables(); if (values.length > 3) { String varName = getParameter(3); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, totalString); } } return totalString; }
Example #12
Source File: FifoGet.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String fifoName = ((CompoundVariable) values[0]).execute(); Object valueObj = FifoMap.getInstance().get(fifoName); String value = null; if (valueObj != null) { value = valueObj.toString(); } JMeterVariables vars = getVariables(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, value); } return value; }
Example #13
Source File: FifoSize.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String fifoName = ((CompoundVariable) values[0]).execute(); int size = FifoMap.getInstance().length(fifoName); String value = Integer.toString(size); JMeterVariables vars = getVariables(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, value); } return value; }
Example #14
Source File: Base64Encode.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.encodeBase64(sourceString.getBytes())); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) {// Allow for empty name final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }
Example #15
Source File: Base64Decode.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String sourceString = values[0].execute(); String decodedValue = new String(Base64.decodeBase64(sourceString)); if (values.length > 1) { String variableName = values[1].execute(); if (variableName.length() > 0) {// Allow for empty name final JMeterVariables variables = getVariables(); if (variables != null) { variables.put(variableName, decodedValue); } } } return decodedValue; }
Example #16
Source File: StrLen.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); Integer len = ((CompoundVariable) values[0]).execute().length(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, len.toString()); } return len.toString(); }
Example #17
Source File: DoubleSum.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); Double sum = 0D; String varName = ((CompoundVariable) values[values.length - 1]).execute().trim(); for (int i = 0; i < values.length - 1; i++) { sum += Double.parseDouble(((CompoundVariable) values[i]).execute()); } try { sum += Double.parseDouble(varName); varName = null; // there is no variable name } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, totalString); } return totalString; }
Example #18
Source File: ChooseRandom.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String varName = ((CompoundVariable) values[values.length - 1]).execute().trim(); int index = random.nextInt(values.length - 1); String choice = ((CompoundVariable) values[index]).execute(); if (vars != null && varName != null && varName.length() > 0) {// vars will be null on TestPlan vars.put(varName, choice); } return choice; }
Example #19
Source File: LowerCase.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String res = ((CompoundVariable) values[0]).execute().toLowerCase(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, res); } return res; }
Example #20
Source File: UpperCase.java From jmeter-plugins with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String res = ((CompoundVariable) values[0]).execute().toUpperCase(); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, res); } return res; }
Example #21
Source File: FifoPut.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { String fifoName = ((CompoundVariable) values[0]).execute(); String value = ((CompoundVariable) values[1]).execute(); try { FifoMap.getInstance().put(fifoName, value); } catch (InterruptedException ex) { log.warn("Interrupted put into queue " + fifoName); value = "INTERRUPTED"; } return value; }
Example #22
Source File: EnvTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test(expected = InvalidVariableException.class) public void testSetParametersException() throws Exception { System.out.println("setParameters"); Collection<CompoundVariable> parameters = new ArrayList<>(); Env instance = new Env(); instance.setParameters(parameters); }
Example #23
Source File: JMeterProxyControl.java From jsflight with Apache License 2.0 | 5 votes |
/** * Scan all test elements passed in for values matching the value of any of * the variables in any of the variable-holding elements in the collection. * * @param sampler A TestElement to replace values on * @param configs More TestElements to replace values on * @param variables Collection of Arguments to use to do the replacement, ordered * by ascending priority. */ private void replaceValues(TestElement sampler, TestElement[] configs, Collection<Arguments> variables) { // Build the replacer from all the variables in the collection: ValueReplacer replacer = new ValueReplacer(); for (Arguments variable : variables) { final Map<String, String> map = variable.getArgumentsAsMap(); for (Iterator<String> vals = map.values().iterator(); vals.hasNext();) { final Object next = vals.next(); if ("".equals(next)) {// Drop any empty values (Bug 45199) vals.remove(); } } replacer.addVariables(map); } try { boolean cachedRegexpMatch = regexMatch; replacer.reverseReplace(sampler, cachedRegexpMatch); for (TestElement config : configs) { if (config != null) { replacer.reverseReplace(config, cachedRegexpMatch); } } } catch (InvalidVariableException e) { LOG.warn("Invalid variables included for replacement into recorded " + "sample", e); } }
Example #24
Source File: EnvTest.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Test(expected = InvalidVariableException.class) public void testSetParametersException2() throws Exception { System.out.println("setParameters"); Collection<CompoundVariable> parameters = new ArrayList<>(); parameters.add(new CompoundVariable(key)); parameters.add(new CompoundVariable("save_variable")); parameters.add(new CompoundVariable("default_value")); parameters.add(new CompoundVariable("Error")); Env instance = new Env(); instance.setParameters(parameters); }
Example #25
Source File: ChooseRandom.java From jmeter-plugins with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkMinParameterCount(parameters, 3); values = parameters.toArray(); }
Example #26
Source File: StrReplaceRegex.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkMinParameterCount(parameters, 3); values = parameters.toArray(); }
Example #27
Source File: MD5.java From jmeter-plugins with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkMinParameterCount(parameters, 1); values = parameters.toArray(); }
Example #28
Source File: IterationNum.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { }
Example #29
Source File: IterationNum.java From jmeter-plugins with Apache License 2.0 | 4 votes |
@Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { return String.valueOf(getVariables().getIteration()); }
Example #30
Source File: LowerCase.java From jmeter-plugins with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException { checkMinParameterCount(parameters, 1); values = parameters.toArray(); }