Search in sources :

Example 11 with HTTPSampleResult

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);
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.Test)

Example 12 with HTTPSampleResult

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());
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.Test)

Example 13 with HTTPSampleResult

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());
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.Test)

Example 14 with HTTPSampleResult

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();
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) Test(org.junit.Test)

Example 15 with HTTPSampleResult

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;
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)

Aggregations

HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)22 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)14 Test (org.junit.Test)14 URL (java.net.URL)2 Argument (org.apache.jmeter.config.Argument)2 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 Entry (java.util.Map.Entry)1 Arguments (org.apache.jmeter.config.Arguments)1 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)1 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)1 MultipartUrlConfig (org.apache.jmeter.protocol.http.config.MultipartUrlConfig)1 Authorization (org.apache.jmeter.protocol.http.control.Authorization)1 SampleEvent (org.apache.jmeter.samplers.SampleEvent)1 SampleResult (org.apache.jmeter.samplers.SampleResult)1 SampleSaveConfiguration (org.apache.jmeter.samplers.SampleSaveConfiguration)1 Sampler (org.apache.jmeter.samplers.Sampler)1