Search in sources :

Example 41 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class PackageTest method configure.

private void configure(HTTPSamplerBase sampler) throws Exception {
    sampler.addArgument("arg1", "val1");
    ConfigTestElement config = (ConfigTestElement) new HttpDefaultsGui().createTestElement();
    ((Arguments) config.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue()).addArgument(new HTTPArgument("config1", "configValue"));
    config.setRunningVersion(true);
    sampler.setRunningVersion(true);
    sampler.setRunningVersion(true);
    sampler.addTestElement(config);
    assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
    sampler.recoverRunningVersion();
    config.recoverRunningVersion();
    assertEquals(1, sampler.getArguments().getArgumentCount());
    sampler.addTestElement(config);
    assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Arguments(org.apache.jmeter.config.Arguments) HttpDefaultsGui(org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 42 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class TestURLRewritingModifier method testGrabSessionId.

@Test
public void testGrabSessionId() throws Exception {
    String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session_id", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 43 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class TestURLRewritingModifier method testNoCache.

@Test
public void testNoCache() throws Exception {
    String[] html = new String[] { "<input name=\"sid\" value=\"myId\">", "myId", "<html></html>", "" };
    URLRewritingModifier newMod = new URLRewritingModifier();
    newMod.setThreadContext(context);
    newMod.setArgumentName("sid");
    newMod.setPathExtension(false);
    newMod.setShouldCache(false);
    for (int i = 0; i < html.length / 2; i++) {
        response = new SampleResult();
        response.setResponseData(html[i * 2], null);
        HTTPSamplerBase sampler = createSampler();
        context.setCurrentSampler(sampler);
        context.setPreviousResult(response);
        newMod.process();
        Arguments args = sampler.getArguments();
        assertEquals("For case i=" + i, html[i * 2 + 1], ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    }
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 44 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class TestURLRewritingModifier method testGrabSessionId6.

@Test
public void testGrabSessionId6() throws Exception {
    String html = "location: http://server.com/index.html" + "?session_id=bonjour+monsieur";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session_id", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("bonjour monsieur", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    assertEquals("http://server.com/index.html?" + "session_id=bonjour+monsieur", sampler.toString());
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 45 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class TestURLRewritingModifier method testGrabSessionId5.

@Test
public void testGrabSessionId5() throws Exception {
    String html = "location: http://server.com/index.html" + "?session[33]=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session[33]");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session[33]", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue()).getValue());
    assertEquals("http://server.com/index.html?session%5B33%5D=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Aggregations

Arguments (org.apache.jmeter.config.Arguments)96 Test (org.junit.jupiter.api.Test)32 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)18 SampleResult (org.apache.jmeter.samplers.SampleResult)17 Argument (org.apache.jmeter.config.Argument)15 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)10 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)8 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)6 TestElement (org.apache.jmeter.testelement.TestElement)6 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)5 Test (org.junit.Test)5 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)4 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)4 IOException (java.io.IOException)3 URL (java.net.URL)3 Iterator (java.util.Iterator)3 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)3 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)3