use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeShiftFunction method testNowWithComplexPeriod.
@Test
public void testNowWithComplexPeriod() throws Exception {
Collection<CompoundVariable> params = makeParams("YYYY-MM-dd'T'HH:mm:ss", "", "P10DT-1H-5M5S", "");
function.setParameters(params);
value = function.execute(result, null);
LocalDateTime futureDate = LocalDateTime.now().plusDays(10).plusHours(-1).plusMinutes(-5).plusSeconds(5);
LocalDateTime futureDateFromFunction = LocalDateTime.parse(value);
assertThat(futureDateFromFunction, within(1, ChronoUnit.SECONDS, futureDate));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeShiftFunction method testDefault.
@Test
public void testDefault() throws Exception {
Collection<CompoundVariable> params = makeParams("", "", "", "");
function.setParameters(params);
value = function.execute(result, null);
long resultat = Long.parseLong(value);
LocalDateTime nowFromFunction = LocalDateTime.ofInstant(Instant.ofEpochMilli(resultat), TimeZone.getDefault().toZoneId());
assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now()));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestTimeShiftFunction method testWrongAmountToAdd.
@Test
public void testWrongAmountToAdd() throws Exception {
// Nothing is add with wrong value, so check if return is now
Collection<CompoundVariable> params = makeParams("", "", "qefv1Psd", "");
function.setParameters(params);
value = function.execute(result, null);
long resultat = Long.parseLong(value);
LocalDateTime nowFromFunction = LocalDateTime.ofInstant(Instant.ofEpochMilli(resultat), TimeZone.getDefault().toZoneId());
assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now()));
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class TestUrlEncodeDecode method testUrlEncode.
@Test
public void testUrlEncode() throws Exception {
AbstractFunction function = new UrlEncode();
params.add(new CompoundVariable("Veni, vidi, vici ?"));
function.setParameters(params);
String returnValue = function.execute(result, null);
assertEquals("Veni%2C+vidi%2C+vici+%3F", returnValue);
}
use of org.apache.jmeter.engine.util.CompoundVariable in project jmeter by apache.
the class VariableTest method variableTest1.
@Test
public void variableTest1() throws Exception {
Variable r = new Variable();
vars.put("A_1", "a1");
vars.put("A_2", "a2");
vars.put("one", "1");
vars.put("two", "2");
vars.put("V", "A");
Collection<CompoundVariable> parms;
String s;
parms = makeParams("V", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("A", s);
parms = makeParams("X", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("X", s);
parms = makeParams("A${X}", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("A${X}", s);
parms = makeParams("A_1", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("a1", s);
parms = makeParams("A_2", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("a2", s);
parms = makeParams("A_${two}", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("a2", s);
parms = makeParams("${V}_${one}", null, null);
r.setParameters(parms);
s = r.execute(null, null);
assertEquals("a1", s);
}
Aggregations