use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResult_match_msg_problem.
@Test
public void testGetResult_match_msg_problem() {
System.out.println("getResult notexist");
SampleResult samplerResult = new SampleResult();
String str = "{\"execution\":[{\"scenario\":{\"requests\":[{\"headers\":{\"headerkey\":\"header value\"}}]}}]}";
samplerResult.setResponseData(str.getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.execution[0].scenario.requests[0].headers");
instance.setJsonValidationBool(true);
instance.setExpectNull(false);
instance.setExpectedValue("{headerkey=header value}");
instance.setInvert(false);
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertEquals(true, result.isFailure());
assertEquals("Value expected to match regexp '{headerkey=header value}', but it did not match: '{\"headerkey\":\"header value\"}'", result.getFailureMessage());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResult_list_val.
@Test
public void testGetResult_list_val() {
System.out.println("getResult list-val");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": [{\"test\":1},{\"test\":2},{\"test\":3}]}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval[*].test");
instance.setJsonValidationBool(true);
instance.setExpectedValue("2");
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertEquals(false, result.isFailure());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResult_inverted_null.
@Test
public void testGetResult_inverted_null() {
System.out.println("getResult notexist");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": [{\"key\": null}]}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval[*].key");
instance.setJsonValidationBool(true);
instance.setExpectNull(true);
instance.setInvert(true);
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertEquals(true, result.isFailure());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResult_dict.
@Test
public void testGetResult_dict() {
System.out.println("getResult notexist");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": {\"key\": \"val\"}}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setJsonValidationBool(true);
instance.setExpectedValue("{\"key\":\"val\"}");
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertEquals(false, result.isFailure());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class UpperCaseTest method testExecute.
/**
* Test of execute method, of class UpperCase.
*/
@Test
public void testExecute() throws Exception {
System.out.println("execute");
Collection<CompoundVariable> parameters = new ArrayList<>();
parameters.add(new CompoundVariable("abc"));
parameters.add(new CompoundVariable("var"));
SampleResult previousResult = null;
Sampler currentSampler = null;
UpperCase instance = new UpperCase();
instance.setParameters(parameters);
String expResult = "ABC";
String result = instance.execute(null, null);
Assert.assertEquals(expResult, result);
Assert.assertEquals(expResult, JMeterContextService.getContext().getVariables().get("var"));
}
Aggregations