use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestJexl2Function method testSumVar.
@Test
public void testSumVar() throws Exception {
params.add(new CompoundVariable("1+2+3"));
params.add(new CompoundVariable("TOTAL"));
function.setParameters(params);
String ret = function.execute(result, null);
assertEquals("6", ret);
assertEquals("6", vars.get("TOTAL"));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestRandomFromMultipleVars method testExtractionFromMultipleVars.
@Test
public void testExtractionFromMultipleVars() throws Exception {
String existingVarName1 = "var1";
String existingVarName2 = "var2";
vars.put(existingVarName1 + "_matchNr", "1");
vars.put(existingVarName1 + "_1", "var1_value");
vars.put(existingVarName2 + "_matchNr", "2");
vars.put(existingVarName2 + "_1", "var2_value1");
vars.put(existingVarName2 + "_2", "var2_value2");
params.add(new CompoundVariable("var1|var2"));
function.setParameters(params);
String returnValue = function.execute(result, null);
Assert.assertThat(returnValue, CoreMatchers.anyOf(CoreMatchers.is("var1_value"), CoreMatchers.is("var2_value1"), CoreMatchers.is("var2_value2")));
Assert.assertNull(vars.get("outputVar"));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeFunction method testTooMany.
@Test
public void testTooMany() throws Exception {
params.add(new CompoundVariable("YMD"));
params.add(new CompoundVariable("NAME"));
params.add(new CompoundVariable("YMD"));
try {
variable.setParameters(params);
fail("Should have raised InvalidVariableException");
} catch (InvalidVariableException ignored) {
}
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeFunction method testDivisor.
@Test
public void testDivisor() throws Exception {
params.add(new CompoundVariable("/1000"));
variable.setParameters(params);
long before = System.currentTimeMillis() / 1000;
value = variable.execute(result, null);
long now = Long.parseLong(value);
long after = System.currentTimeMillis() / 1000;
assertTrue(now >= before && now <= after);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeFunction method testDefault1.
@Test
public void testDefault1() throws Exception {
params.add(new CompoundVariable());
variable.setParameters(params);
long before = System.currentTimeMillis();
value = variable.execute(result, null);
long now = Long.parseLong(value);
long after = System.currentTimeMillis();
assertTrue(now >= before && now <= after);
}
Aggregations