Search in sources :

Example 1 with CookieManager

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

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

the class TestSessionFilter method testGetCookieManager.

@Test
public void testGetCookieManager() {
    SessionFilter orig = new SessionFilter();
    SessionFilter clone = (SessionFilter) orig.clone();
    final String ipAddr = "1.2.3.4";
    CookieManager cmOrig = orig.getCookieManager(ipAddr);
    // clear CookieManager in use in orig
    orig.threadFinished();
    CookieManager cmClone = clone.getCookieManager(ipAddr);
    // clear CookieManager in clone
    clone.threadFinished();
    assertSame(cmOrig, cmClone);
}
Also used : CookieManager(org.apache.jmeter.protocol.http.control.CookieManager) Test(org.junit.Test)

Example 3 with CookieManager

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

the class CookiePanel method createTestElement.

@Override
public TestElement createTestElement() {
    CookieManager cookieManager = new CookieManager();
    modifyTestElement(cookieManager);
    return cookieManager;
}
Also used : CookieManager(org.apache.jmeter.protocol.http.control.CookieManager)

Example 4 with CookieManager

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

the class CookiePanel method modifyTestElement.

/**
     * Modifies a given TestElement to mirror the data in the gui components.
     *
     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
     */
@Override
public void modifyTestElement(TestElement cm) {
    GuiUtils.stopTableEditing(cookieTable);
    cm.clear();
    configureTestElement(cm);
    if (cm instanceof CookieManager) {
        CookieManager cookieManager = (CookieManager) cm;
        for (int i = 0; i < tableModel.getRowCount(); i++) {
            Cookie cookie = createCookie(tableModel.getRowData(i));
            cookieManager.add(cookie);
        }
        cookieManager.setClearEachIteration(clearEachIteration.isSelected());
        cookieManager.setCookiePolicy(policy.getText());
    }
}
Also used : Cookie(org.apache.jmeter.protocol.http.control.Cookie) CookieManager(org.apache.jmeter.protocol.http.control.CookieManager)

Example 5 with CookieManager

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

the class SessionFilter method getCookieManager.

protected CookieManager getCookieManager(String ipAddr) {
    CookieManager cm;
    // threads stuck in wait can move on
    synchronized (LOCK) {
        if (lastUsed != null) {
            managersInUse.remove(lastUsed);
            LOCK.notifyAll();
        }
    }
    // let notified threads move on and get lock on managersInUse
    if (lastUsed != null) {
        Thread.yield();
    }
    // it up
    synchronized (LOCK) {
        cm = cookieManagers.get(ipAddr);
        if (cm == null) {
            cm = new CookieManager();
            cm.testStarted();
            cookieManagers.put(ipAddr, cm);
        }
        while (managersInUse.contains(cm)) {
            try {
                LOCK.wait();
            } catch (InterruptedException e) {
                log.info("SessionFilter wait interrupted");
                Thread.currentThread().interrupt();
            }
        }
        managersInUse.add(cm);
        lastUsed = cm;
    }
    return cm;
}
Also used : CookieManager(org.apache.jmeter.protocol.http.control.CookieManager)

Aggregations

CookieManager (org.apache.jmeter.protocol.http.control.CookieManager)13 Test (org.junit.Test)3 IOException (java.io.IOException)2 Cookie (org.apache.jmeter.protocol.http.control.Cookie)2 HTTPSampler (org.apache.jmeter.protocol.http.sampler.HTTPSampler)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Callable (java.util.concurrent.Callable)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 JFileChooser (javax.swing.JFileChooser)1 AuthManager (org.apache.jmeter.protocol.http.control.AuthManager)1 HeaderManager (org.apache.jmeter.protocol.http.control.HeaderManager)1 LinkExtractorParseException (org.apache.jmeter.protocol.http.parser.LinkExtractorParseException)1 LinkExtractorParser (org.apache.jmeter.protocol.http.parser.LinkExtractorParser)1