Search in sources :

Example 16 with HTTPSampleResult

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

the class TestAnchorModifier method testProcessingHTMLFile.

private void testProcessingHTMLFile(String HTMLFileName) throws Exception {
    File file = new File(System.getProperty("user.dir") + "/testfiles/load_bug_list.jmx");
    HTTPSamplerBase config = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
    config.setRunningVersion(true);
    HTTPSampleResult result = new HTTPSampleResult();
    file = new File(System.getProperty("user.dir") + "/testfiles/Load_JMeter_Page.jmx");
    HTTPSamplerBase context = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
    jmctx.setCurrentSampler(context);
    jmctx.setCurrentSampler(config);
    result.setResponseData(new TextFile(System.getProperty("user.dir") + HTMLFileName).getText(), null);
    result.setSampleLabel(context.toString());
    result.setSamplerData(context.toString());
    result.setURL(new URL("http://bz.apache.org/fakepage.html"));
    jmctx.setPreviousResult(result);
    AnchorModifier modifier = new AnchorModifier();
    modifier.setThreadContext(jmctx);
    modifier.process();
    assertEquals("http://bz.apache.org/bugzilla/buglist.cgi?" + "bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED" + "&email1=&emailtype1=substring&emailassigned_to1=1" + "&email2=&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue=" + "&product=JMeter&short_desc=&short_desc_type=substring" + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords=" + "&keywords_type=anywords" + "&field0-0-0=noop&type0-0-0=noop&value0-0-0=" + "&cmdtype=doit&order=Reuse+same+sort+as+last+time", config.toString());
    config.recoverRunningVersion();
    assertEquals("http://bz.apache.org/bugzilla/buglist.cgi?" + "bug_status=.*&bug_status=.*&bug_status=.*&email1=" + "&emailtype1=substring&emailassigned_to1=1&email2=" + "&emailtype2=substring&emailreporter2=1" + "&bugidtype=include&bug_id=&changedin=&votes=" + "&chfieldfrom=&chfieldto=Now&chfieldvalue=" + "&product=JMeter&short_desc=&short_desc_type=substring" + "&long_desc=&long_desc_type=substring&bug_file_loc=" + "&bug_file_loc_type=substring&keywords=" + "&keywords_type=anywords&field0-0-0=noop" + "&type0-0-0=noop&value0-0-0=&cmdtype=doit" + "&order=Reuse+same+sort+as+last+time", config.toString());
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult) TextFile(org.apache.jorphan.io.TextFile) TextFile(org.apache.jorphan.io.TextFile) File(java.io.File) URL(java.net.URL) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)

Example 17 with HTTPSampleResult

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

Example 18 with HTTPSampleResult

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

Example 19 with HTTPSampleResult

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

the class TestCacheManagerBase method getSampleResultWithSpecifiedResponseCode.

private HTTPSampleResult getSampleResultWithSpecifiedResponseCode(String code) {
    HTTPSampleResult sampleResult = new HTTPSampleResult();
    sampleResult.setResponseCode(code);
    sampleResult.setHTTPMethod("GET");
    sampleResult.setURL(url);
    return sampleResult;
}
Also used : HTTPSampleResult(org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)

Example 20 with HTTPSampleResult

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

the class TestCacheManagerBase method cacheResultWithGivenCode.

private void cacheResultWithGivenCode(String responseCode) throws Exception {
    HTTPSampleResult sampleResult = getSampleResultWithSpecifiedResponseCode(responseCode);
    cacheResult(sampleResult);
}
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