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 2006/06/04 00:26:27 UTC

svn commit: r411477 - /jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java

Author: sebb
Date: Sat Jun  3 15:26:26 2006
New Revision: 411477

URL: http://svn.apache.org/viewvc?rev=411477&view=rev
Log:
Add domain- and path-specified properties.
These are needed for some cookie policies

Modified:
    jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java

Modified: jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java?rev=411477&r1=411476&r2=411477&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/protocol/http/org/apache/jmeter/protocol/http/control/Cookie.java Sat Jun  3 15:26:26 2006
@@ -31,49 +31,60 @@
  * @author <a href="mailto:sdowd@arcmail.com">Sean Dowd</a>
  */
 public class Cookie extends AbstractTestElement implements Serializable {
-	private static String VALUE = "Cookie.value";
+	private static final String TAB = "\t";
 
-	private static String DOMAIN = "Cookie.domain";
+    private static String VALUE = "Cookie.value"; //$NON-NLS-1$
 
-	private static String EXPIRES = "Cookie.expires";
+	private static String DOMAIN = "Cookie.domain"; //$NON-NLS-1$
 
-	private static String SECURE = "Cookie.secure";
+	private static String EXPIRES = "Cookie.expires"; //$NON-NLS-1$
 
-	private static String PATH = "Cookie.path";
+	private static String SECURE = "Cookie.secure"; //$NON-NLS-1$
+
+	private static String PATH = "Cookie.path"; //$NON-NLS-1$
+
+    private static String PATH_SPECIFIED = "Cookie.path_specified"; //$NON-NLS-1$
+
+    private static String DOMAIN_SPECIFIED = "Cookie.domain_specified"; //$NON-NLS-1$
 
 	/**
 	 * create the coookie
 	 */
 	public Cookie() {
-		this.setName("");
-		this.setValue("");
-		this.setDomain("");
-		this.setPath("");
-		this.setSecure(false);
-		this.setExpires(0);
+        this("","","","",false,0,false,false);
 	}
 
-	/**
+    /**
 	 * create the coookie
+     * 
+     * @param expires - this is in seconds
+     * 
 	 */
 	public Cookie(String name, String value, String domain, String path, boolean secure, long expires) {
-		this.setName(name);
-		this.setValue(value);
-		this.setDomain(domain);
-		this.setPath(path);
-		this.setSecure(secure);
-		this.setExpires(expires);
-	}
-
-	public void addConfigElement(ConfigElement config) {
+        this(name,value,domain,path,secure,expires,true,true);
 	}
 
-	public boolean expectsModification() {
-		return false;
-	}
+    /**
+     * create the coookie
+     * 
+     * @param expires - this is in seconds
+     * @param hasPath - was the path explicitly specified?
+     * @param hasDomain - was the domain explicitly specified?
+     * 
+     */
+    public Cookie(String name, String value, String domain, String path, 
+            boolean secure, long expires, boolean hasPath, boolean hasDomain) {
+        this.setName(name);
+        this.setValue(value);
+        this.setDomain(domain);
+        this.setPath(path);
+        this.setSecure(secure);
+        this.setExpires(expires);
+        this.setPathSpecified(hasPath);
+        this.setDomainSpecified(hasDomain);
+    }
 
-	public String getClassLabel() {
-		return "Cookie";
+    public void addConfigElement(ConfigElement config) {
 	}
 
 	/**
@@ -159,11 +170,36 @@
 		setProperty(PATH, path);
 	}
 
+    public void setPathSpecified(boolean b) {
+        setProperty(PATH_SPECIFIED, JOrphanUtils.booleanToString(b));
+    }
+
+    public boolean isPathSpecified(){
+        return getPropertyAsBoolean(PATH_SPECIFIED);
+    }
+    
+    public void setDomainSpecified(boolean b) {
+        setProperty(DOMAIN_SPECIFIED, JOrphanUtils.booleanToString(b));
+    }
+
+    public boolean isDomainSpecified(){
+        return getPropertyAsBoolean(DOMAIN_SPECIFIED);
+    }
+    
 	/**
 	 * creates a string representation of this cookie
 	 */
 	public String toString() {
-		return getDomain() + "\tTRUE\t" + getPath() + "\t" + JOrphanUtils.booleanToSTRING(getSecure()) + "\t"
-				+ getExpires() + "\t" + getName() + "\t" + getValue();
+        StringBuffer sb=new StringBuffer(80);
+        sb.append(getDomain());
+        sb.append(TAB).append("TRUE"); //TODO - what does this represent?
+        sb.append(TAB).append(getPath());
+        sb.append(TAB).append(JOrphanUtils.booleanToSTRING(getSecure())); 
+        sb.append(TAB).append(getExpires());
+        sb.append(TAB).append(getName());
+        sb.append(TAB).append(getValue());
+        return sb.toString();
 	}
+
+
 }



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