use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.
the class TestAnchorModifier method testSimpleParse4.
@Test
public void testSimpleParse4() throws Exception {
HTTPSamplerBase config = makeUrlConfig("/subdir/index\\..*");
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();
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.HTTPSampleResult in project jmeter by apache.
the class TestAnchorModifier method testSpecialCharParse.
@Test
public void testSpecialCharParse() throws Exception {
// These are some of the special characters
String specialChars = "-_.!~*'()%25";
String htmlEncodedFixture = URLEncoder.encode(specialChars, StandardCharsets.UTF_8.name());
HTTPSamplerBase config = makeUrlConfig(".*index.html");
config.addArgument("test", ".*");
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=\"hidden\" name=\"test\"" + " value=\"" + htmlEncodedFixture + "\">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=" + htmlEncodedFixture, config.getQueryString());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.
the class TestAnchorModifier method testBadCharParse.
@Test
public void testBadCharParse() throws Exception {
HTTPSamplerBase config = makeUrlConfig(".*index.html");
config.addArgument("te$st", "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=\"te$st\"" + " 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("te%24st=goto", config.getQueryString());
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.
the class TestAnchorModifier method testNullSampler.
@Test
public void testNullSampler() {
jmctx.setCurrentSampler(null);
jmctx.setPreviousResult(new HTTPSampleResult());
// should do nothing
parser.process();
}
use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.
the class HTTPResultConverter method unmarshal.
/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
HTTPSampleResult res = (HTTPSampleResult) createCollection(context.getRequiredType());
retrieveAttributes(reader, context, res);
while (reader.hasMoreChildren()) {
reader.moveDown();
Object subItem = readItem(reader, context, res);
if (!retrieveItem(reader, context, res, subItem)) {
retrieveHTTPItem(reader, res, subItem);
}
reader.moveUp();
}
// If we have a file, but no data, then read the file
String resultFileName = res.getResultFileName();
if (resultFileName.length() > 0 && res.getResponseData().length == 0) {
readFile(resultFileName, res);
}
return res;
}
Aggregations