Search in sources :

Example 71 with JMeterVariables

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

the class PackageTest method setUp.

@Override
public void setUp() {
    jmctx = JMeterContextService.getContext();
    jmctx.setVariables(new JMeterVariables());
    vars = jmctx.getVariables();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables)

Example 72 with JMeterVariables

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

the class SplitFunctionTest method setUp.

@Before
public void setUp() {
    jmctx = JMeterContextService.getContext();
    jmctx.setVariables(new JMeterVariables());
    vars = jmctx.getVariables();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) Before(org.junit.Before)

Example 73 with JMeterVariables

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

the class TestWhileController method setUp.

@Before
public void setUp() {
    jmctx = JMeterContextService.getContext();
    jmctx.setVariables(new JMeterVariables());
    jmvars = jmctx.getVariables();
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) Before(org.junit.Before)

Example 74 with JMeterVariables

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

the class PackageTest method setUp.

@Before
public void setUp() {
    jmctx = JMeterContextService.getContext();
    Map<String, String> variables = new HashMap<>();
    variables.put("my_regex", ".*");
    variables.put("server", "jakarta.apache.org");
    SampleResult result = new SampleResult();
    result.setResponseData("<html>hello world</html> costs: $3.47,$5.67", null);
    transformer = new ReplaceStringWithFunctions(new CompoundVariable(), variables);
    jmctx.setVariables(new JMeterVariables());
    jmctx.setSamplingStarted(true);
    jmctx.setPreviousResult(result);
    jmctx.getVariables().put("server", "jakarta.apache.org");
    jmctx.getVariables().put("my_regex", ".*");
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) HashMap(java.util.HashMap) SampleResult(org.apache.jmeter.samplers.SampleResult) Before(org.junit.Before)

Example 75 with JMeterVariables

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

the class PreCompiler method addNode.

/** {@inheritDoc} */
@Override
public void addNode(Object node, HashTree subTree) {
    if (isRemote && node instanceof ResultCollector) {
        try {
            replacer.replaceValues((TestElement) node);
        } catch (InvalidVariableException e) {
            log.error("invalid variables", e);
        }
    }
    if (isRemote) {
        return;
    }
    if (node instanceof TestElement) {
        try {
            replacer.replaceValues((TestElement) node);
        } catch (InvalidVariableException e) {
            log.error("invalid variables", e);
        }
    }
    if (node instanceof TestPlan) {
        //A hack to make user-defined variables in the testplan element more dynamic
        ((TestPlan) node).prepareForPreCompile();
        Map<String, String> args = ((TestPlan) node).getUserDefinedVariables();
        replacer.setUserDefinedVariables(args);
        JMeterVariables vars = new JMeterVariables();
        vars.putAll(args);
        JMeterContextService.getContext().setVariables(vars);
    }
    if (node instanceof Arguments) {
        ((Arguments) node).setRunningVersion(true);
        Map<String, String> args = ((Arguments) node).getArgumentsAsMap();
        replacer.addVariables(args);
        JMeterContextService.getContext().getVariables().putAll(args);
    }
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) InvalidVariableException(org.apache.jmeter.functions.InvalidVariableException) TestPlan(org.apache.jmeter.testelement.TestPlan) Arguments(org.apache.jmeter.config.Arguments) TestElement(org.apache.jmeter.testelement.TestElement) ResultCollector(org.apache.jmeter.reporters.ResultCollector)

Aggregations

JMeterVariables (org.apache.jmeter.threads.JMeterVariables)96 SampleResult (org.apache.jmeter.samplers.SampleResult)35 JMeterContext (org.apache.jmeter.threads.JMeterContext)33 Before (org.junit.Before)33 CompoundVariable (org.apache.jmeter.engine.util.CompoundVariable)17 Test (org.junit.Test)16 JSONPostProcessor (org.apache.jmeter.extractor.json.jsonpath.JSONPostProcessor)8 TestPlan (org.apache.jmeter.testelement.TestPlan)6 HashMap (java.util.HashMap)5 Sampler (org.apache.jmeter.samplers.Sampler)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ValueReplacer (org.apache.jmeter.engine.util.ValueReplacer)4 Properties (java.util.Properties)3 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)3 Logger (org.slf4j.Logger)3 URL (java.net.URL)2 Arguments (org.apache.jmeter.config.Arguments)2 ReplaceStringWithFunctions (org.apache.jmeter.engine.util.ReplaceStringWithFunctions)2 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)2