Search in sources :

Example 6 with HTTPSampleResult

use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.

the class TestAnchorModifier method testFailSimpleParse1.

@Test
public void testFailSimpleParse1() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*index.*?param2=.+1");
    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, 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 7 with HTTPSampleResult

use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.

the class TestAnchorModifier method testSimpleParse1.

// Test https works too
@Test
public void testSimpleParse1() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*/index\\.html");
    config.setProtocol(HTTPConstants.PROTOCOL_HTTPS);
    config.setPort(HTTPConstants.DEFAULT_HTTPS_PORT);
    HTTPSamplerBase context = makeContext("https://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("https://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 8 with HTTPSampleResult

use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.

the class TestAnchorModifier method testSimpleParse2.

@Test
public void testSimpleParse2() 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>" + "hfdfjiudfjdfjkjfkdjf" + "<b>bold text</b><a href=lowerdir/index.html>lower</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();
    assertTrue("http://www.apache.org/index.html".equals(newUrl) || "http://www.apache.org/subdir/lowerdir/index.html".equals(newUrl));
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.Test)

Example 9 with HTTPSampleResult

use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.

the class TestAnchorModifier method testFailSimpleParse2.

@Test
public void testFailSimpleParse2() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*login\\.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();
    result.setResponseData(responseText, null);
    result.setSampleLabel(context.toString());
    result.setURL(context.getUrl());
    jmctx.setCurrentSampler(context);
    jmctx.setPreviousResult(result);
    parser.process();
    String newUrl = config.getUrl().toString();
    assertNotEquals("http://www.apache.org/home/index.html?param1=value1", newUrl);
    assertEquals(config.getUrl().toString(), newUrl);
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.Test)

Example 10 with HTTPSampleResult

use of org.apache.jmeter.protocol.http.sampler.HTTPSampleResult in project jmeter by apache.

the class TestAnchorModifier method testSimpleParse3.

@Test
public void testSimpleParse3() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*index.*");
    config.getArguments().addArgument("param1", "value1");
    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();
    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/home/index.html?param1=value1", 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