@Test public void testExecute() throws Exception { System.out.println("execute"); SampleResult previousResult = null; Sampler currentSampler = null; Collection<CompoundVariable> parameters = new ArrayList<>(); for (int i = 0; i < 1000; i++) { parameters.add(new CompoundVariable(String.valueOf(i))); } parameters.add(new CompoundVariable("4.3346")); parameters.add(new CompoundVariable("5.3346")); ChooseRandom instance = new ChooseRandom(); instance.setParameters(parameters); String result1 = instance.execute(null, null); String result2 = instance.execute(null, null); Assert.assertTrue(!result1.equals(result2)); }
@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.put(varName, choice); } return choice; }
ChooseRandom extends AbstractFunction { @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.put(varName, choice); } return choice; } }
ChooseRandom extends AbstractFunction { @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.put(varName, choice); } return choice; } ChooseRandom(); }
ChooseRandom extends AbstractFunction { @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.put(varName, choice); } return choice; } ChooseRandom(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); }
ChooseRandom extends AbstractFunction { @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.put(varName, choice); } return choice; } ChooseRandom(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc();  }