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());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method makeUrlConfig.
private HTTPSamplerBase makeUrlConfig(String path) {
HTTPSamplerBase config = new HTTPNullSampler();
config.setDomain("www.apache.org");
config.setMethod(HTTPConstants.GET);
config.setPath(path);
config.setPort(HTTPConstants.DEFAULT_HTTP_PORT);
config.setProtocol(HTTPConstants.PROTOCOL_HTTP);
return config;
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase in project jmeter by apache.
the class TestAnchorModifier method testSimpleParse.
@Test
public void testSimpleParse() throws Exception {
HTTPSamplerBase config = makeUrlConfig(".*/index\\.html");
HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/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();
jmctx.setCurrentSampler(context);
jmctx.setCurrentSampler(config);
result.setResponseData(responseText, null);
result.setSampleLabel(context.toString());
result.setSamplerData(context.toString());
result.setURL(context.getUrl());
jmctx.setPreviousResult(result);
parser.process();
assertEquals("http://www.apache.org/subdir/index.html", config.getUrl().toString());
}
Aggregations