You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2007/10/07 21:55:21 UTC

svn commit: r582672 - in /jakarta/jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java xdocs/changes.xml xdocs/usermanual/component_reference.xml

Author: sebb
Date: Sun Oct  7 12:55:19 2007
New Revision: 582672

URL: http://svn.apache.org/viewvc?rev=582672&view=rev
Log:
Cookie Manager not longer clears cookies defined in the GUI

Modified:
    jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
    jakarta/jmeter/trunk/xdocs/changes.xml
    jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java?rev=582672&r1=582671&r2=582672&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (original)
+++ jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java Sun Oct  7 12:55:19 2007
@@ -55,7 +55,7 @@
  * 
  */
 public class CookieManager extends ConfigTestElement implements TestListener, Serializable {
-    private static final Logger log = LoggingManager.getLoggerForClass();
+	private static final Logger log = LoggingManager.getLoggerForClass();
 
 	public static final String CLEAR = "CookieManager.clearEachIteration";// $NON-NLS-1$
 
@@ -75,6 +75,8 @@
 
     private transient CookieSpec cookieSpec;
 
+    private transient CollectionProperty initialCookies;
+    
     public static final String DEFAULT_POLICY = CookiePolicy.BROWSER_COMPATIBILITY;
 
 	public CookieManager() {
@@ -83,7 +85,14 @@
         setCookiePolicy(DEFAULT_POLICY);
 	}
 
-    public String getPolicy() {
+	// ensure that the initial cookies are copied to the per-thread instances
+	public Object clone(){
+		CookieManager clone = (CookieManager) super.clone();
+		clone.initialCookies = initialCookies;
+		return clone;
+	}
+
+	public String getPolicy() {
         return getPropertyAsString(POLICY,DEFAULT_POLICY);
     }
 
@@ -237,10 +246,15 @@
 		}
 	}
 
-	/**
+	public void clear(){
+		super.clear();
+		clearCookies(); // ensure data is set up OK initially
+	}
+
+	/*
 	 * Remove all the cookies.
 	 */
-	public void clear() {// TODO: should this call super.clear()?
+	private void clearCookies() {
 		log.debug("Clear all cookies from store");
 		setProperty(new CollectionProperty(COOKIES, new ArrayList()));
 	}
@@ -410,19 +424,23 @@
 	}
 
 	public void testStarted() {
+		initialCookies = getCookies();
 	}
 
 	public void testEnded() {
 	}
 
 	public void testStarted(String host) {
+		testStarted();
 	}
 
 	public void testEnded(String host) {
 	}
 
 	public void testIterationStart(LoopIterationEvent event) {
-		if (getClearEachIteration())
-			clear();
+		if (getClearEachIteration()) {
+			clearCookies();
+			setProperty(initialCookies);
+		}
 	}
 }

Modified: jakarta/jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/changes.xml?rev=582672&r1=582671&r2=582672&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/changes.xml (original)
+++ jakarta/jmeter/trunk/xdocs/changes.xml Sun Oct  7 12:55:19 2007
@@ -49,6 +49,7 @@
 <li>Bug 43451 - Allow Regex Extractor to operate on Response Code/Message</li>
 <li>JDBC Sampler now allows INOUT and OUT parameters for Called procedures</li>
 <li>JDBC Sampler now allows per-thread connections</li>
+<li>Cookie Manager not longer clears cookies defined in the GUI</li>
 </ul>
 
 <h4>Non-functional Improvements</h4>

Modified: jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=582672&r1=582671&r2=582672&view=diff
==============================================================================
--- jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml Sun Oct  7 12:55:19 2007
@@ -2225,8 +2225,8 @@
 </description>
 <properties>
   <property name="Name" required="No">Descriptive name for this element that is shown in the tree. </property>
-  <property name="Clear Cookies each Iteration" required="Yes">If selected, all cookies are cleared each time the main Thread Group loop is executed.
-  This includes all the Cookies stored in the manager, so they will never be sent.</property>
+  <property name="Clear Cookies each Iteration" required="Yes">If selected, all server-defined cookies are cleared each time the main Thread Group loop is executed.
+  In JMeter versions after 2.3, any cookies defined in the GUI are not cleared.</property>
   <property name="Cookie Policy" required="Yes">The cookie policy that will be used to manage the cookies. 
   "compatibility" is the default, and should work in most cases.
   See http://jakarta.apache.org/httpcomponents/httpclient-3.x/cookies.html and 



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org