Apache JMeter
2.0.1.20050615

org.apache.jmeter.protocol.http.control
Class CookieManager

java.lang.Object
  extended byorg.apache.jmeter.testelement.AbstractTestElement
      extended byorg.apache.jmeter.config.ConfigTestElement
          extended byorg.apache.jmeter.protocol.http.control.CookieManager
All Implemented Interfaces:
Cloneable, 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.

Version:
$Revision: 1.26.2.2 $ $Date: 2004/11/07 00:48:00 $
Author:
Sean Dowd
See Also:
Serialized Form

Nested Class Summary
static class CookieManager.Test
           
 
Field Summary
static String CLEAR
           
static String COOKIES
           
 
Fields inherited from class org.apache.jmeter.config.ConfigTestElement
PASSWORD, USERNAME
 
Fields inherited from interface org.apache.jmeter.testelement.TestElement
ENABLED, GUI_CLASS, NAME, TEST_CLASS
 
Constructor Summary
CookieManager()
           
 
Method Summary
 void add()
          Add an empty cookie.
 void add(Cookie c)
          Add a cookie.
 void addCookieFromHeader(String cookieHeader, URL url)
          Parse the set-cookie header value and store the cookies for later retrieval.
 void addFile(String cookieFile)
          Add cookie data from a file.
 void clear()
          Remove all the cookies.
 String convertLongToDateFormatStr(long dateLong)
           
 Cookie get(int i)
          Return the cookie at index i.
 String getClassLabel()
           
 boolean getClearEachIteration()
           
 Cookie getCookie(int row)
           
 int getCookieCount()
           
 String getCookieHeaderForURL(URL url)
          Find cookies applicable to the given URL and build the Cookie header from them.
 CollectionProperty getCookies()
           
 void recoverRunningVersion()
          Tells the test element to return to the state it was in when makeRunningVersion() was called.
 void remove(int index)
          Remove a cookie.
 void removeCookieNamed(String name)
           
 void save(String authFile)
          Save the cookie data to a file.
 void setClearEachIteration(boolean clear)
           
 void setRunningVersion(boolean running)
          Sets the runningVersion.
 int size()
          Return the number of cookies.
 String[] split(String splittee, String splitChar, String def)
          Takes a String and a tokenizer character, and returns a new array of strings of the string split by the tokenizer character.
 void testEnded()
          Called once for all threads after the end of a test
 void testEnded(String host)
           
 void testIterationStart(LoopIterationEvent event)
          Each time through a Thread Group's test script, an iteration event is fired.
 void testStarted()
          Called just before the start of the test Note that not all the test variables will have been set up at this point.
 void testStarted(String host)
           
 
Methods inherited from class org.apache.jmeter.config.ConfigTestElement
addTestElement
 
Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement
addProperty, canRemove, clearTemporary, clone, emptyTemporary, equals, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsLong, getPropertyAsString, getThreadContext, getThreadName, isRunningVersion, isTemporary, logProperties, mergeIn, nextIsNull, propertyIterator, removeProperty, setName, setProperty, setProperty, setTemporary, setThreadContext, setThreadName, threadFinished, threadStarted, traverse, traverseCollection, traverseMap, traverseProperty
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLEAR

public static final String CLEAR
See Also:
Constant Field Values

COOKIES

public static final String COOKIES
See Also:
Constant Field Values
Constructor Detail

CookieManager

public CookieManager()
Method Detail

getCookies

public CollectionProperty getCookies()

getCookieCount

public int getCookieCount()

getClearEachIteration

public boolean getClearEachIteration()

setClearEachIteration

public void setClearEachIteration(boolean clear)

getCookie

public Cookie getCookie(int row)

save

public void save(String authFile)
          throws IOException
Save the cookie data to a file.

Throws:
IOException

addFile

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

Throws:
IOException

recoverRunningVersion

public void recoverRunningVersion()
Description copied from interface: TestElement
Tells the test element to return to the state it was in when makeRunningVersion() was called.

Specified by:
recoverRunningVersion in interface TestElement
Overrides:
recoverRunningVersion in class AbstractTestElement

setRunningVersion

public void setRunningVersion(boolean running)
Description copied from class: AbstractTestElement
Sets the runningVersion.

Specified by:
setRunningVersion in interface TestElement
Overrides:
setRunningVersion in class AbstractTestElement
Parameters:
running - the runningVersion to set

add

public void add(Cookie c)
Add a cookie.


add

public void add()
Add an empty cookie.


clear

public void clear()
Remove all the cookies.

Specified by:
clear in interface TestElement
Overrides:
clear in class AbstractTestElement

remove

public void remove(int index)
Remove a cookie.


size

public int size()
Return the number of cookies.


get

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


convertLongToDateFormatStr

public String convertLongToDateFormatStr(long dateLong)

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: ").

addCookieFromHeader

public void addCookieFromHeader(String cookieHeader,
                                URL url)
Parse the set-cookie header value and store the cookies for later retrieval.

Parameters:
cookieHeader - found after the "Set-Cookie: " in the response header
url - URL used in the request for the above-mentioned response.

removeCookieNamed

public void removeCookieNamed(String name)

split

public String[] split(String splittee,
                      String splitChar,
                      String def)
Takes a String and a tokenizer character, and returns a new array of strings of the string split by the tokenizer character.

Parameters:
splittee - string to be split
splitChar - character to split the string on
def - default value to place between two split chars that have nothing between them
Returns:
array of all the tokens.

getClassLabel

public String getClassLabel()

testStarted

public void testStarted()
Description copied from interface: TestListener
Called just before the start of the test Note that not all the test variables will have been set up at this point.

Specified by:
testStarted in interface TestListener
See Also:
StandardJMeterEngine.run()

testEnded

public void testEnded()
Description copied from interface: TestListener
Called once for all threads after the end of a test

Specified by:
testEnded in interface TestListener
See Also:
StandardJMeterEngine.stopTest()

testStarted

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

testEnded

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

testIterationStart

public void testIterationStart(LoopIterationEvent event)
Description copied from interface: TestListener
Each time through a Thread Group's test script, an iteration event is fired.

Specified by:
testIterationStart in interface TestListener
Parameters:
event -

Apache JMeter
2.0.1.20050615

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