Search in sources :

Example 1 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter-plugins by undera.

the class JSONFormatterTest method testProcess_float.

@Test
public void testProcess_float() {
    System.out.println("process float");
    JSONFormatter instance = new JSONFormatter();
    JMeterContext threadContext = JMeterContextService.getContext();
    SampleResult res = new SampleResult();
    res.setResponseData("3.14", "UTF8");
    threadContext.setPreviousResult(res);
    instance.process();
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 2 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter-plugins by undera.

the class JSONFormatterTest method testProcess_array.

@Test
public void testProcess_array() {
    System.out.println("process array");
    JSONFormatter instance = new JSONFormatter();
    JMeterContext threadContext = JMeterContextService.getContext();
    SampleResult res = new SampleResult();
    res.setResponseData("[]", "UTF8");
    threadContext.setPreviousResult(res);
    instance.process();
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 3 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter-plugins by undera.

the class CaseFormatTest method setUp.

@Before
public void setUp() {
    changeCase = new CaseFormat();
    result = new SampleResult();
    JMeterContext jmctx = JMeterContextService.getContext();
    String data = "dummy data";
    result.setResponseData(data, null);
    JMeterVariables vars = new JMeterVariables();
    jmctx.setVariables(vars);
    jmctx.setPreviousResult(result);
    params = new LinkedList<>();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 4 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter-plugins by undera.

the class Base64DecodeTest method testExecute.

@Test
public void testExecute() throws Exception {
    JMeterContext context = JMeterContextService.getContext();
    context.setVariables(new JMeterVariables());
    Collection<CompoundVariable> parameters = new ArrayList<>();
    parameters.add(new CompoundVariable("dGVzdCBzdHJpbmc="));
    parameters.add(new CompoundVariable("b64dec_res"));
    Base64Decode instance = new Base64Decode();
    instance.setParameters(parameters);
    String res = instance.execute(null, null);
    Assert.assertEquals("test string", res);
    Assert.assertNotNull(context.getVariables().get("b64dec_res"));
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter-plugins by undera.

the class JSONPathExtractorTest method testProcess_default.

@Test
public void testProcess_default() {
    System.out.println("process def");
    JMeterContext context = JMeterContextService.getContext();
    SampleResult res = new SampleResult();
    context.setPreviousResult(res);
    JSONPathExtractor instance = new JSONPathExtractor();
    instance.setDefaultValue("DEFAULT");
    instance.setVar("test");
    instance.process();
    JMeterVariables vars = context.getVariables();
    assertEquals("DEFAULT", vars.get("test"));
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Aggregations

JMeterContext (org.apache.jmeter.threads.JMeterContext)98 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)64 SampleResult (org.apache.jmeter.samplers.SampleResult)47 Test (org.junit.Test)19 Test (org.junit.jupiter.api.Test)18 BeforeEach (org.junit.jupiter.api.BeforeEach)13 JSONPostProcessor (org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)10 Sampler (org.apache.jmeter.samplers.Sampler)9 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)8 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)4 Properties (java.util.Properties)3 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)3 JMeterException (org.apache.jorphan.util.JMeterException)3 HashMap (java.util.HashMap)2 Bindings (javax.script.Bindings)2 Arguments (org.apache.jmeter.config.Arguments)2 ReplaceStringWithFunctions (org.apache.jmeter.engine.util.ReplaceStringWithFunctions)2