Search in sources :

Example 6 with HttpTestSampleGui

use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui 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 7 with HttpTestSampleGui

use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.

the class TestHTTPHC4Impl method testFileargWithMimeTypeWithCharset.

@Test
void testFileargWithMimeTypeWithCharset() throws Exception {
    HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
    sampler.setThreadContext(jmctx);
    sampler.setDoMultipart(true);
    HttpEntityEnclosingRequestBase post = new HttpPost();
    HTTPFileArg fileArg = new HTTPFileArg();
    fileArg.setMimeType("text/html; charset=utf-8");
    fileArg.setName("somefile.html");
    fileArg.setParamName("upload");
    File dummyFile = File.createTempFile("somefile", ".html");
    dummyFile.deleteOnExit();
    fileArg.setPath(dummyFile.getAbsolutePath());
    sampler.setHTTPFiles(Collections.singletonList(fileArg).toArray(new HTTPFileArg[1]));
    HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
    String requestData = hc.setupHttpEntityEnclosingRequestData(post);
    assertTrue(requestData.contains("charset=utf-8"));
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) HttpEntityEnclosingRequestBase(org.apache.http.client.methods.HttpEntityEnclosingRequestBase) HttpTestSampleGui(org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui) HTTPFileArg(org.apache.jmeter.protocol.http.util.HTTPFileArg) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

HttpTestSampleGui (org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui)7 Test (org.junit.jupiter.api.Test)7 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)4 HttpEntityEnclosingRequestBase (org.apache.http.client.methods.HttpEntityEnclosingRequestBase)3 HttpPost (org.apache.http.client.methods.HttpPost)3 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)2 File (java.io.File)1 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)1