@Test public void testExecute() throws Exception { System.out.println("execute 1"); Collection<CompoundVariable> parameters = new ArrayList<CompoundVariable>(); parameters.add(new CompoundVariable("test string")); parameters.add(new CompoundVariable("5")); parameters.add(new CompoundVariable("8")); parameters.add(new CompoundVariable("var")); If instance = new If(); instance.setParameters(parameters); String expResult = "var"; String result = instance.execute(null, null); Assert.assertEquals(expResult, result); }
@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; }
If extends AbstractFunction { @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; } }
If extends AbstractFunction { @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; } If(); }
If extends AbstractFunction { @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; } If(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc(); }
If extends AbstractFunction { @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; } If(); @Override synchronized String execute(SampleResult previousResult, Sampler currentSampler); @Override synchronized void setParameters(Collection<CompoundVariable> parameters); @Override String getReferenceKey(); @Override List<String> getArgumentDesc();  }