Search in sources :

Example 56 with JMeterContext

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

the class XMLFormatPostProcessor method process.

public void process() {
    JMeterContext threadContext = getThreadContext();
    String responseString = threadContext.getPreviousResult().getResponseDataAsString();
    try {
        threadContext.getPreviousResult().setResponseData(serialize2(responseString).getBytes("UTF-8"));
    } catch (Exception e) {
        log.info("Error while formating response xml - " + e.getMessage());
    }
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext)

Example 57 with JMeterContext

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

the class XMLFormatPostProcessorTest method testProcess.

/**
 * Test of process method, of class XMLFormatPostProcessor.
 */
@Test
public void testProcess() {
    System.out.println("process");
    JMeterContext threadContext = JMeterContextService.getContext();
    SampleResult res = new SampleResult();
    threadContext.setPreviousResult(res);
    XMLFormatPostProcessor instance = new XMLFormatPostProcessor();
    instance.process();
// TODO review the generated test code and remove the default call to fail.
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult) Test(org.junit.Test)

Example 58 with JMeterContext

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

the class AbstractSimpleThreadGroup method start.

@Override
public void start(int groupCount, ListenerNotifier notifier, ListedHashTree threadGroupTree, StandardJMeterEngine engine) {
    running = true;
    int numThreads = getNumThreads();
    log.info("Starting thread group number " + groupCount + " threads " + numThreads);
    // needs to be same time for all threads in the group
    long now = System.currentTimeMillis();
    final JMeterContext context = JMeterContextService.getContext();
    for (int i = 0; running && i < numThreads; i++) {
        JMeterThread jmThread = makeThread(groupCount, notifier, threadGroupTree, engine, i, context);
        // set start and end time
        scheduleThread(jmThread, now);
        Thread newThread = new Thread(jmThread, jmThread.getThreadName());
        registerStartedThread(jmThread, newThread);
        newThread.start();
    }
    log.info("Started thread group number " + groupCount);
}
Also used : JMeterContext(org.apache.jmeter.threads.JMeterContext) JMeterThread(org.apache.jmeter.threads.JMeterThread) JMeterThread(org.apache.jmeter.threads.JMeterThread)

Example 59 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter by apache.

the class XmlAssertionTest method setUp.

@BeforeEach
public void setUp() {
    JMeterContext jmctx = JMeterContextService.getContext();
    assertion = new XMLAssertion();
    assertion.setThreadContext(jmctx);
    JMeterVariables vars = new JMeterVariables();
    jmctx.setVariables(vars);
    sampleResult = new SampleResult();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) SampleResult(org.apache.jmeter.samplers.SampleResult) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 60 with JMeterContext

use of org.apache.jmeter.threads.JMeterContext in project jmeter by apache.

the class TestCVSDataSet method setUp.

@BeforeEach
public void setUp() {
    JMeterContext jmcx = JMeterContextService.getContext();
    jmcx.setVariables(new JMeterVariables());
    threadVars = jmcx.getVariables();
    threadVars.put("b", "value");
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

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