Search in sources :

Example 1 with HTTPSampler

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

the class TestSessionFilter method testIsFiltered.

@Test
public void testIsFiltered() throws Exception {
    Map<String, CookieManager> cm = new ConcurrentHashMap<>();
    Set<CookieManager> inUse = Collections.synchronizedSet(new HashSet<CookieManager>());
    SessionFilter filter = new SessionFilter(cm, inUse);
    HTTPSampler sampler = new HTTPSampler();
    filter.isFiltered("1.2.3.4 ...", sampler);
    assertSame(cm.get("1.2.3.4"), sampler.getCookieManager());
    assertTrue(inUse.contains(sampler.getCookieManager()));
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HTTPSampler(org.apache.jmeter.protocol.http.sampler.HTTPSampler) CookieManager(org.apache.jmeter.protocol.http.control.CookieManager) Test(org.junit.Test)

Example 2 with HTTPSampler

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

the class SessionFilter method isFiltered.

/**
     * {@inheritDoc}
     */
@Override
public boolean isFiltered(String path, TestElement sampler) {
    String ipAddr = getIpAddress(path);
    CookieManager cm = getCookieManager(ipAddr);
    ((HTTPSampler) sampler).setCookieManager(cm);
    return false;
}
Also used : HTTPSampler(org.apache.jmeter.protocol.http.sampler.HTTPSampler) CookieManager(org.apache.jmeter.protocol.http.control.CookieManager)

Aggregations

CookieManager (org.apache.jmeter.protocol.http.control.CookieManager)2 HTTPSampler (org.apache.jmeter.protocol.http.sampler.HTTPSampler)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Test (org.junit.Test)1