use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method testSimpleParse5.
@Test
public void testSimpleParse5() throws Exception {
HTTPSamplerBase config = makeUrlConfig("/subdir/index\\.h.*");
HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/one/previous.html");
String responseText = "<html><head><title>Test page</title></head><body>" + "<a href=\"../index.html\">Goto index page</a></body></html>";
HTTPSampleResult result = new HTTPSampleResult();
result.setResponseData(responseText, null);
result.setSampleLabel(context.toString());
result.setURL(context.getUrl());
jmctx.setCurrentSampler(context);
jmctx.setCurrentSampler(config);
jmctx.setPreviousResult(result);
parser.process();
String newUrl = config.getUrl().toString();
assertEquals("http://www.apache.org/subdir/index.html", newUrl);
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method testProcessingHTMLFile.
private void testProcessingHTMLFile(String HTMLFileName) throws Exception {
File file = findTestFile("testfiles/load_bug_list.jmx");
HTTPSamplerBase config = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
config.setRunningVersion(true);
HTTPSampleResult result = new HTTPSampleResult();
file = findTestFile("testfiles/Load_JMeter_Page.jmx");
HTTPSamplerBase context = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
jmctx.setCurrentSampler(context);
jmctx.setCurrentSampler(config);
result.setResponseData(new TextFile(findTestFile(HTMLFileName)).getText(), null);
result.setSampleLabel(context.toString());
result.setSamplerData(context.toString());
result.setURL(new URL("http://bz.apache.org/fakepage.html"));
jmctx.setPreviousResult(result);
AnchorModifier modifier = new AnchorModifier();
modifier.setThreadContext(jmctx);
modifier.process();
assertEquals("http://bz.apache.org/bugzilla/buglist.cgi?" + "bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED" + "&email1=&emailtype1=substring&emailassigned_to1=1" + "&email2=&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue=" + "&product=JMeter&short_desc=&short_desc_type=substring" + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords=" + "&keywords_type=anywords" + "&field0-0-0=noop&type0-0-0=noop&value0-0-0=" + "&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
config.recoverRunningVersion();
assertEquals("http://bz.apache.org/bugzilla/buglist.cgi?" + "bug_status=.*&bug_status=.*&bug_status=.*&email1=" + "&emailtype1=substring&emailassigned_to1=1&email2=" + "&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue=" + "&product=JMeter&short_desc=&short_desc_type=substring" + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords=" + "&keywords_type=anywords&field0-0-0=noop" + "&type0-0-0=noop&value0-0-0=&cmdtype=doit" + "&order=Reuse+same+sort+as+last+time", config.toString());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method testFailSimpleParse3.
@Test
public void testFailSimpleParse3() throws Exception {
HTTPSamplerBase config = makeUrlConfig("/home/index.html");
HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
String responseText = "<html><head><title>Test page</title></head><body>" + "<a href=\"/home/index.html?param1=value1\">" + "Goto index page</a></body></html>";
HTTPSampleResult result = new HTTPSampleResult();
String newUrl = config.getUrl().toString();
result.setResponseData(responseText, null);
result.setSampleLabel(context.toString());
result.setURL(context.getUrl());
jmctx.setCurrentSampler(context);
jmctx.setCurrentSampler(config);
jmctx.setPreviousResult(result);
parser.process();
assertEquals(newUrl + "?param1=value1", config.getUrl().toString());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method makeContext.
private HTTPSamplerBase makeContext(String url) throws MalformedURLException {
URL u = new URL(url);
HTTPSamplerBase context = new HTTPNullSampler();
context.setDomain(u.getHost());
context.setPath(u.getPath());
context.setPort(u.getPort());
context.setProtocol(u.getProtocol());
context.parseArguments(u.getQuery());
return context;
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method testSimpleFormParse.
@Test
public void testSimpleFormParse() throws Exception {
HTTPSamplerBase config = makeUrlConfig(".*index.html");
config.addArgument("test", "g.*");
config.setMethod(HTTPConstants.POST);
HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
String responseText = "<html><head><title>Test page</title></head><body>" + "<form action=\"index.html\" method=\"POST\">" + "<input type=\"checkbox\" name=\"test\"" + " value=\"goto\">Goto index page</form></body></html>";
HTTPSampleResult result = new HTTPSampleResult();
result.setResponseData(responseText, null);
result.setSampleLabel(context.toString());
result.setURL(context.getUrl());
jmctx.setCurrentSampler(context);
jmctx.setCurrentSampler(config);
jmctx.setPreviousResult(result);
parser.process();
assertEquals("http://www.apache.org/subdir/index.html", config.getUrl().toString());
assertEquals("test=goto", config.getQueryString());
}
Aggregations