Search in sources :

Example 21 with HTTPSamplerBase

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

the class TestURLRewritingModifier method testGrabSessionId3.

@Test
public void testGrabSessionId3() throws Exception {
    String html = "href='index.html?session_id=jfdkjdkfjddkfdfjkdjfdf'";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((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 22 with HTTPSamplerBase

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

the class TestURLRewritingModifier method testGrabSessionIdFromXMLNonPatExtension.

@Test
public void testGrabSessionIdFromXMLNonPatExtension() throws Exception {
    // Bug 50286
    String html = "<url>/some/path;jsessionid=123456789</url>";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("jsessionid");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("123456789", ((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 23 with HTTPSamplerBase

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

the class TestURLRewritingModifier method testGrabSessionId2.

@Test
public void testGrabSessionId2() throws Exception {
    String html = "<a href=\"http://server.com/index.html?" + "session_id=jfdkjdkfjddkfdfjkdjfdf\">";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkfjddkfdfjkdjfdf", ((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 24 with HTTPSamplerBase

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

the class TestURLRewritingModifier method testBug61314.

@Test
public void testBug61314() 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();
    sampler.setPath("/urlRewrite/index;jsessionid=657CF77A86183868CF30AC36321394B7");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    assertEquals("/urlRewrite/index;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 25 with HTTPSamplerBase

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

the class TestHC4CookieManager method testSendCookie.

@Test
public void testSendCookie() throws Exception {
    man.add(new Cookie("id", "value", "jakarta.apache.org", "/", false, 9999999999L));
    HTTPSamplerBase sampler = new HTTPNullSampler();
    sampler.setDomain("jakarta.apache.org");
    sampler.setPath("/index.html");
    sampler.setMethod(HTTPConstants.GET);
    assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
}
Also used : BasicClientCookie(org.apache.http.impl.cookie.BasicClientCookie) ClientCookie(org.apache.http.cookie.ClientCookie) HTTPNullSampler(org.apache.jmeter.protocol.http.sampler.HTTPNullSampler) 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