@Test public void testExecute() throws Exception { System.out.println("execute"); SampleResult previousResult = null; Sampler currentSampler = null; Collection<CompoundVariable> parameters = new ArrayList<>(); parameters.add(new CompoundVariable("1.256")); parameters.add(new CompoundVariable("4.3346")); DoubleSum instance = new DoubleSum(); instance.setParameters(parameters); String expResult = "5.5906"; String result = instance.execute(null, null); Assert.assertEquals(expResult, result); }
@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; } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) { vars.put(varName, totalString); } return totalString; }
DoubleSum extends AbstractFunction { @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; } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) { vars.put(varName, totalString); } return totalString; } }
DoubleSum extends AbstractFunction { @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; } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) { vars.put(varName, totalString); } return totalString; } DoubleSum(); }
DoubleSum extends AbstractFunction { @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; } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) { vars.put(varName, totalString); } return totalString; } DoubleSum(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); }
DoubleSum extends AbstractFunction { @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; } catch (NumberFormatException ignored) { } String totalString = Double.toString(sum); if (vars != null && varName != null && varName.length() > 0) { vars.put(varName, totalString); } return totalString; } DoubleSum(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc();  }