Search in sources :

Example 11 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.

the class TestCacheManagerThreadIteration method testJmeterVariableWhenThreadIterationIsSameUser.

@Test
public void testJmeterVariableWhenThreadIterationIsSameUser() {
    jmvars.putObject(SAME_USER, false);
    jmctx.setVariables(jmvars);
    HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
    cacheManager.setControlledByThread(true);
    sampler.setCacheManager(cacheManager);
    sampler.setThreadContext(jmctx);
    boolean res = (boolean) cacheManager.getThreadContext().getVariables().getObject(SAME_USER);
    assertFalse("When test different user on the different iternation, the cache shouldn't be cleared", res);
}
Also used : HttpTestSampleGui(org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 12 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.

the class TestHttpTestSampleGui method testCloneSampler.

@Test
public void testCloneSampler() throws Exception {
    HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
    sampler.addArgument("param", "value");
    HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
    clonedSampler.setRunningVersion(true);
    sampler.getArguments().getArgument(0).setValue("new value");
    assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0).getValue());
}
Also used : HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 13 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.

the class TestURLRewritingModifier method testGrabSessionIdFromXMLPatExtension.

@Test
public void testGrabSessionIdFromXMLPatExtension() throws Exception {
    // Bug 50286
    String html = "<url>/some/path;jsessionid=123456789</url>";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("jsessionid");
    mod.setPathExtension(true);
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    assertEquals("index.html;jsessionid=123456789", sampler.getPath());
}
Also used : SampleResult(org.apache.jmeter.samplers.SampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 14 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.

the class TestURLRewritingModifier method testGrabSessionIdFromForm.

@Test
public void testGrabSessionIdFromForm() throws Exception {
    String[] html = new String[] { "<input name=\"sid\" value=\"myId\">", "<input name='sid' value='myId'>", "<input value=\"myId\" NAME='sid'>", "<input VALUE='myId' name=\"sid\">", "<input blah blah value=\"myId\" yoda yoda NAME='sid'>", "<input type=\"HIDDEN\" name=\"sid\"      value=\"myId\">", "<input type=\"HIDDEN\" name=\"sid\"\tvalue=\"myId\">" };
    for (int i = 0; i < html.length; i++) {
        response = new SampleResult();
        response.setResponseData(html[i], null);
        URLRewritingModifier newMod = new URLRewritingModifier();
        newMod.setThreadContext(context);
        newMod.setArgumentName("sid");
        newMod.setPathExtension(false);
        HTTPSamplerBase sampler = createSampler();
        context.setCurrentSampler(sampler);
        context.setPreviousResult(response);
        newMod.process();
        Arguments args = sampler.getArguments();
        assertEquals("For case i=" + i, "myId", ((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 15 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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)

Aggregations

HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)65 Test (org.junit.jupiter.api.Test)40 SampleResult (org.apache.jmeter.samplers.SampleResult)20 Arguments (org.apache.jmeter.config.Arguments)18 HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)14 HTTPNullSampler (org.apache.jmeter.protocol.http.sampler.HTTPNullSampler)6 HttpTestSampleGui (org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui)5 NodeList (org.w3c.dom.NodeList)4 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)3 Sampler (org.apache.jmeter.samplers.Sampler)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 ClientCookie (org.apache.http.cookie.ClientCookie)2 BasicClientCookie (org.apache.http.impl.cookie.BasicClientCookie)2 Argument (org.apache.jmeter.config.Argument)2 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 JMeterContext (org.apache.jmeter.threads.JMeterContext)2 Node (org.w3c.dom.Node)2