org.apache.jmeter.protocol.http.control

Class CookieManager

Implemented Interfaces:
Cloneable, Serializable, ConfigElement, Serializable, TestElement, TestListener

public class CookieManager
extends ConfigTestElement
implements TestListener, Serializable

This class provides an interface to the netscape cookies file to pass cookies along with a request. Now uses Commons HttpClient parsing and matching code (since 2.1.2)

Field Summary

static String
DEFAULT_POLICY

Fields inherited from class org.apache.jmeter.config.ConfigTestElement

PASSWORD, USERNAME

Fields inherited from interface org.apache.jmeter.testelement.TestElement

COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS

Constructor Summary

CookieManager()

Method Summary

void
add(Cookie c)
Add a cookie.
void
addCookieFromHeader(String cookieHeader, URL url)
void
addFile(String cookieFile)
Add cookie data from a file.
void
clear()
Object
clone()
Cookie
get(int i)
Return the cookie at index i.
boolean
getClearEachIteration()
int
getCookieCount()
String
getCookieHeaderForURL(URL url)
Find cookies applicable to the given URL and build the Cookie header from them.
CollectionProperty
getCookies()
org.apache.commons.httpclient.Cookie[]
getCookiesForUrl(URL url)
Get array of valid HttpClient cookies for the URL
String
getPolicy()
void
recoverRunningVersion()
void
remove(int index)
Remove a cookie.
void
save(String authFile)
Save the static cookie data to a file.
void
setClearEachIteration(boolean clear)
void
setCookiePolicy(String policy)
void
setRunningVersion(boolean running)
Sets the runningVersion.
void
testEnded()
void
testEnded(String host)
void
testIterationStart(LoopIterationEvent event)
void
testStarted()
void
testStarted(String host)

Methods inherited from class org.apache.jmeter.config.ConfigTestElement

addConfigElement, addTestElement, expectsModification

Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

addProperty, addTestElement, canRemove, clear, clearTemporary, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty

Field Details

DEFAULT_POLICY

public static final String DEFAULT_POLICY

Constructor Details

CookieManager

public CookieManager()

Method Details

add

public void add(Cookie c)
Add a cookie.

addCookieFromHeader

public void addCookieFromHeader(String cookieHeader,
                                URL url)

addFile

public void addFile(String cookieFile)
            throws IOException
Add cookie data from a file.

clear

public void clear()
Specified by:
clear in interface TestElement
Overrides:
clear in interface AbstractTestElement

clone

public Object clone()
Specified by:
clone in interface ConfigElement
clone in interface TestElement
Overrides:
clone in interface AbstractTestElement

get

public Cookie get(int i)
Return the cookie at index i.

getClearEachIteration

public boolean getClearEachIteration()

getCookieCount

public int getCookieCount()

getCookieHeaderForURL

public String getCookieHeaderForURL(URL url)
Find cookies applicable to the given URL and build the Cookie header from them.
Parameters:
url - URL of the request to which the returned header will be added.
Returns:
the value string for the cookie header (goes after "Cookie: ").

getCookies

public CollectionProperty getCookies()

getCookiesForUrl

public org.apache.commons.httpclient.Cookie[] getCookiesForUrl(URL url)
Get array of valid HttpClient cookies for the URL
Parameters:
url - the target URL
Returns:
array of HttpClient cookies

getPolicy

public String getPolicy()

recoverRunningVersion

public void recoverRunningVersion()
Specified by:
recoverRunningVersion in interface TestElement
Overrides:
recoverRunningVersion in interface AbstractTestElement

remove

public void remove(int index)
Remove a cookie.

save

public void save(String authFile)
            throws IOException
Save the static cookie data to a file. Cookies are only taken from the GUI - runtime cookies are not included.

setClearEachIteration

public void setClearEachIteration(boolean clear)

setCookiePolicy

public void setCookiePolicy(String policy)

setRunningVersion

public void setRunningVersion(boolean running)
Sets the runningVersion.
Specified by:
setRunningVersion in interface TestElement
Overrides:
setRunningVersion in interface AbstractTestElement
Parameters:

testEnded

public void testEnded()
Specified by:
testEnded in interface TestListener

testEnded

public void testEnded(String host)
Specified by:
testEnded in interface TestListener

testIterationStart

public void testIterationStart(LoopIterationEvent event)
Specified by:
testIterationStart in interface TestListener

testStarted

public void testStarted()
Specified by:
testStarted in interface TestListener

testStarted

public void testStarted(String host)
Specified by:
testStarted in interface TestListener

Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.