use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResultFloat.
@Test
public void testGetResultFloat() {
System.out.println("testGetResultFloat");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": [{\"test\":0.0000123456789}]}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval[*].test");
instance.setJsonValidationBool(true);
instance.setIsRegex(false);
instance.setExpectedValue("0.0000123456789");
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_not_regexp.
@Test
public void testGetResult_not_regexp() {
System.out.println("not regexp");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": \"some complicated value\"}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setJsonValidationBool(true);
instance.setExpectedValue("some.+");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(false, result.isFailure());
instance.setIsRegex(false);
AssertionResult result2 = instance.getResult(samplerResult);
assertEquals(true, result2.isFailure());
}
use of org.apache.jmeter.samplers.SampleResult in project jmeter-plugins by undera.
the class JSONPathAssertionTest method testGetResult_list_negative.
@Test
public void testGetResult_list_negative() {
System.out.println("getResult list-neg");
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("5");
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_null_not_found.
@Test
public void testGetResult_null_not_found() {
System.out.println("getResult null");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": 123}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setExpectNull(true);
instance.setJsonValidationBool(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_null.
@Test
public void testGetResult_null() {
System.out.println("getResult null");
SampleResult samplerResult = new SampleResult();
samplerResult.setResponseData("{\"myval\": null}".getBytes());
JSONPathAssertion instance = new JSONPathAssertion();
instance.setJsonPath("$.myval");
instance.setExpectNull(true);
instance.setJsonValidationBool(true);
AssertionResult expResult = new AssertionResult("");
AssertionResult result = instance.getResult(samplerResult);
assertEquals(expResult.getName(), result.getName());
assertEquals(false, result.isFailure());
}
Aggregations