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()));
}
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);
}
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;
}
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());
}
}
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;
}
Aggregations