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);
}
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());
}
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());
}
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());
}
}
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());
}
Aggregations