Search in sources :

Example 21 with HTTPSampleResult

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

Example 22 with HTTPSampleResult

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

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