Search in sources :

Example 36 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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.jupiter.api.Test)

Example 37 with HTTPSamplerBase

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

the class HttpTestSampleGui method configure.

/**
 * {@inheritDoc}
 */
@Override
public void configure(TestElement element) {
    super.configure(element);
    final HTTPSamplerBase samplerBase = (HTTPSamplerBase) element;
    urlConfigGui.configure(element);
    retrieveEmbeddedResources.setSelected(samplerBase.isImageParser());
    concurrentDwn.setSelected(samplerBase.isConcurrentDwn());
    concurrentPool.setText(samplerBase.getConcurrentPool());
    useMD5.setSelected(samplerBase.useMD5());
    embeddedAllowRE.setText(samplerBase.getEmbeddedUrlRE());
    embeddedExcludeRE.setText(samplerBase.getEmbededUrlExcludeRE());
    if (!isAJP) {
        sourceIpAddr.setText(samplerBase.getIpSource());
        sourceIpType.setSelectedIndex(samplerBase.getIpSourceType());
        proxyScheme.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYSCHEME));
        proxyHost.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYHOST));
        proxyPort.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPORT));
        proxyUser.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYUSER));
        proxyPass.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.PROXYPASS));
        httpImplementation.setSelectedItem(samplerBase.getPropertyAsString(HTTPSamplerBase.IMPLEMENTATION));
        connectTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.CONNECT_TIMEOUT));
        responseTimeOut.setText(samplerBase.getPropertyAsString(HTTPSamplerBase.RESPONSE_TIMEOUT));
    }
}
Also used : HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)

Example 38 with HTTPSamplerBase

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

the class TestCacheManagerThreadIteration method testJmeterVariableCacheWhenThreadIterationIsANewUser.

@Test
public void testJmeterVariableCacheWhenThreadIterationIsANewUser() {
    jmvars.putObject(SAME_USER, true);
    jmctx.setVariables(jmvars);
    HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
    cacheManager.setControlledByThread(true);
    sampler.setCacheManager(cacheManager);
    sampler.setThreadContext(jmctx);
    boolean res = (boolean) cacheManager.getThreadContext().getVariables().getObject(SAME_USER);
    assertTrue("When test different user on the different iternation, the cache should be cleared", res);
}
Also used : HttpTestSampleGui(org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase) Test(org.junit.jupiter.api.Test)

Example 39 with HTTPSamplerBase

use of org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase 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.jupiter.api.Test)

Example 40 with HTTPSamplerBase

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

the class TestAnchorModifier method testProcessingHTMLFile.

private void testProcessingHTMLFile(String HTMLFileName) throws Exception {
    File file = findTestFile("testfiles/load_bug_list.jmx");
    HTTPSamplerBase config = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
    config.setRunningVersion(true);
    HTTPSampleResult result = new HTTPSampleResult();
    file = findTestFile("testfiles/Load_JMeter_Page.jmx");
    HTTPSamplerBase context = (HTTPSamplerBase) SaveService.loadTree(file).getArray()[0];
    jmctx.setCurrentSampler(context);
    jmctx.setCurrentSampler(config);
    result.setResponseData(new TextFile(findTestFile(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)

Aggregations

HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)65 Test (org.junit.jupiter.api.Test)40 SampleResult (org.apache.jmeter.samplers.SampleResult)20 Arguments (org.apache.jmeter.config.Arguments)18 HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)14 HTTPNullSampler (org.apache.jmeter.protocol.http.sampler.HTTPNullSampler)6 HttpTestSampleGui (org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui)5 NodeList (org.w3c.dom.NodeList)4 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 ArrayList (java.util.ArrayList)3 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)3 Sampler (org.apache.jmeter.samplers.Sampler)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 ClientCookie (org.apache.http.cookie.ClientCookie)2 BasicClientCookie (org.apache.http.impl.cookie.BasicClientCookie)2 Argument (org.apache.jmeter.config.Argument)2 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 JMeterContext (org.apache.jmeter.threads.JMeterContext)2 Node (org.w3c.dom.Node)2