us.abstracta.jmeter.javadsl.http.DslCookieManager Maven / Gradle / Ivy
Show all versions of jmeter-java-dsl Show documentation
package us.abstracta.jmeter.javadsl.http;
import java.lang.reflect.Method;
import java.util.List;
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.gui.CookiePanel;
import org.apache.jmeter.testelement.TestElement;
/**
* Allows configuring cookies settings used by HTTP samplers.
*
* This element can only be added as child of test plan, and currently allows only to disable HTTP
* cookies handling which is enabled by default (emulating browser behavior).
*
* This element has to be added before any http sampler to be considered, and if you add multiple
* instances of cookie manager to a test plan, only the first one will be considered.
*
* @since 0.17
*/
public class DslCookieManager extends AutoEnabledHttpConfigElement {
public DslCookieManager() {
super("HTTP Cookie Manager", CookiePanel.class);
}
/**
* disables HTTP cookies handling for the test plan.
*
* @return the DslCookieManager to allow fluent API usage.
*/
public DslCookieManager disable() {
enabled = false;
return this;
}
@Override
protected TestElement buildTestElement() {
CookieManager ret = new CookieManager();
ret.setClearEachIteration(true);
return ret;
}
public static class CodeBuilder extends AutoEnabledHttpConfigElement.CodeBuilder {
public CodeBuilder(List builderMethods) {
super(CookieManager.class, builderMethods);
}
}
}