Search in sources :

Example 11 with SampleResult

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());
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 12 with SampleResult

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());
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 13 with SampleResult

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());
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 14 with SampleResult

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());
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 15 with SampleResult

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());
}
Also used : AssertionResult(org.apache.jmeter.assertions.AssertionResult) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Aggregations

SampleResult (org.apache.jmeter.samplers.SampleResult)381 Test (org.junit.Test)83 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)71 Test (org.junit.jupiter.api.Test)59 JMeterContext (org.apache.jmeter.threads.JMeterContext)47 BeforeEach (org.junit.jupiter.api.BeforeEach)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 SampleEvent (org.apache.jmeter.samplers.SampleEvent)30 Sampler (org.apache.jmeter.samplers.Sampler)30 AssertionResult (org.apache.jmeter.assertions.AssertionResult)27 ArrayList (java.util.ArrayList)26 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)20 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)20 IOException (java.io.IOException)17 Arguments (org.apache.jmeter.config.Arguments)16 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)12 URL (java.net.URL)9 File (java.io.File)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7