use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.
the class TestCookieManagerThreadIteration method testJmeterVariableCookieWhenThreadIterationIsANewUser.
@Test
public void testJmeterVariableCookieWhenThreadIterationIsANewUser() {
jmvars.putObject(SAME_USER, true);
jmctx.setVariables(jmvars);
HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
CookieManager cookieManager = new CookieManager();
cookieManager.setControlledByThread(true);
sampler.setCookieManager(cookieManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cookieManager.getThreadContext().getVariables().getObject(SAME_USER);
assertTrue("When test different users on the different iternations, the cookie should be cleared", res);
}
use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.
the class TestCookieManagerThreadIteration method testJmeterVariableCookieWhenThreadIterationIsSameUser.
@Test
public void testJmeterVariableCookieWhenThreadIterationIsSameUser() {
jmvars.putObject(SAME_USER, false);
jmctx.setVariables(jmvars);
HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
CookieManager cookieManager = new CookieManager();
cookieManager.setControlledByThread(true);
sampler.setCookieManager(cookieManager);
sampler.setThreadContext(jmctx);
boolean res = (boolean) cookieManager.getThreadContext().getVariables().getObject(SAME_USER);
assertFalse("When test same user on the different iternations, the cookie shouldn't be cleared", res);
}
use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.
the class TestCacheManagerThreadIteration method testJmeterVariableWhenThreadIterationIsSameUser.
@Test
public void testJmeterVariableWhenThreadIterationIsSameUser() {
jmvars.putObject(SAME_USER, false);
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);
assertFalse("When test different user on the different iternation, the cache shouldn't be cleared", res);
}
use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.
the class TestHTTPHC4Impl method testParameterWithMultipartAndExplicitHeader.
@Test
void testParameterWithMultipartAndExplicitHeader() throws Exception {
HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
sampler.setThreadContext(jmctx);
sampler.setDoMultipart(true);
sampler.setDoBrowserCompatibleMultipart(true);
HttpEntityEnclosingRequestBase post = new HttpPost();
post.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, "application/json");
sampler.setHTTPFiles(new HTTPFileArg[] { new HTTPFileArg("filename", "file", "application/octect; charset=utf-8") });
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);
assertEquals(0, post.getHeaders(HTTPConstants.HEADER_CONTENT_TYPE).length);
assertTrue(requestData.contains("charset=utf-8"));
}
use of org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui in project jmeter by apache.
the class TestHTTPHC4Impl method testParameterWithMimeTypeWithCharset.
@Test
void testParameterWithMimeTypeWithCharset() throws Exception {
HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui().createTestElement();
sampler.setThreadContext(jmctx);
sampler.setDoMultipart(true);
HttpEntityEnclosingRequestBase post = new HttpPost();
HTTPArgument argument = new HTTPArgument("upload", "some data");
argument.setContentType("text/html; charset=utf-8");
sampler.getArguments().addArgument(argument);
HTTPHC4Impl hc = new HTTPHC4Impl(sampler);
String requestData = hc.setupHttpEntityEnclosingRequestData(post);
assertTrue(requestData.contains("charset=utf-8"));
}
Aggregations