use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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());
}
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestURLRewritingModifier method testBug61314WithQuestionMark.
@Test
public void testBug61314WithQuestionMark() 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?toto=titi");
context.setCurrentSampler(sampler);
context.setPreviousResult(response);
mod.process();
assertEquals("/urlRewrite/index;jsessionid=123456789", sampler.getPath());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestURLRewritingModifier method createSampler.
private HTTPSamplerBase createSampler() {
HTTPSamplerBase sampler = new HTTPNullSampler();
sampler.setDomain("server.com");
sampler.setPath("index.html");
sampler.setMethod(HTTPConstants.GET);
sampler.setProtocol("http");
return sampler;
}
Aggregations