Made Cookie an interface

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@558477 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2007-07-22 12:54:07 +00:00
parent bdeb8786af
commit 6d36b3aa06
10 changed files with 519 additions and 258 deletions

View File

@ -33,62 +33,30 @@ package org.apache.http.cookie;
import java.util.Date;
import org.apache.http.util.CharArrayBuffer;
/**
* <p>
* HTTP "magic-cookie" represents a piece of state information
* that the HTTP agent and the target server can exchange to maintain
* a session.
* </p>
*
* @author B.C. Holmes
* @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
* @author <a href="mailto:dsale@us.britannica.com">Doug Sale</a>
* @author Rod Waldhoff
* @author dIon Gillard
* @author Sean C. Sullivan
* @author <a href="mailto:JEvans@Cyveillance.com">John Evans</a>
* @author Marc A. Saegesser
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
* @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
*
* @version $Revision$
* @since 4.0
*/
public class Cookie {
/**
* Default Constructor taking a name and a value. The value may be null.
*
* @param name The name.
* @param value The value.
*/
public Cookie(final String name, final String value) {
super();
if (name == null) {
throw new IllegalArgumentException("Name may not be null");
}
this.name = name;
this.value = value;
}
public interface Cookie {
/**
* Returns the name.
*
* @return String name The name
*/
public String getName() {
return this.name;
}
String getName();
/**
* Returns the value.
*
* @return String value The current value.
*/
public String getValue() {
return this.value;
}
String getValue();
/**
* Returns the comment describing the purpose of this cookie, or
@ -98,9 +66,7 @@ public class Cookie {
*
* @see #setComment(String)
*/
public String getComment() {
return cookieComment;
}
String getComment();
/**
* If a user agent (web browser) presents this cookie to a user, the
@ -110,9 +76,7 @@ public class Cookie {
*
* @see #getComment()
*/
public void setComment(String comment) {
cookieComment = comment;
}
void setComment(String comment);
/**
* Returns the expiration {@link Date} of the cookie, or <tt>null</tt>
@ -125,9 +89,7 @@ public class Cookie {
* @see #setExpiryDate(java.util.Date)
*
*/
public Date getExpiryDate() {
return cookieExpiryDate;
}
Date getExpiryDate();
/**
* Sets expiration date.
@ -140,9 +102,7 @@ public class Cookie {
* @see #getExpiryDate
*
*/
public void setExpiryDate (Date expiryDate) {
cookieExpiryDate = expiryDate;
}
void setExpiryDate (Date expiryDate);
/**
@ -152,9 +112,7 @@ public class Cookie {
* @return <tt>false</tt> if the cookie should be discarded at the end
* of the "session"; <tt>true</tt> otherwise
*/
public boolean isPersistent() {
return (null != cookieExpiryDate);
}
boolean isPersistent();
/**
@ -164,9 +122,7 @@ public class Cookie {
*
* @see #setDomain(java.lang.String)
*/
public String getDomain() {
return cookieDomain;
}
String getDomain();
/**
* Sets the domain attribute.
@ -175,13 +131,7 @@ public class Cookie {
*
* @see #getDomain
*/
public void setDomain(String domain) {
if (domain != null) {
cookieDomain = domain.toLowerCase();
} else {
cookieDomain = null;
}
}
void setDomain(String domain);
/**
@ -191,9 +141,7 @@ public class Cookie {
*
* @see #setPath(java.lang.String)
*/
public String getPath() {
return cookiePath;
}
String getPath();
/**
* Sets the path attribute.
@ -203,17 +151,13 @@ public class Cookie {
* @see #getPath
*
*/
public void setPath(String path) {
cookiePath = path;
}
void setPath(String path);
/**
* @return <code>true</code> if this cookie should only be sent over secure connections.
* @see #setSecure(boolean)
*/
public boolean isSecure() {
return isSecure;
}
boolean isSecure();
/**
* Sets the secure attribute of the cookie.
@ -227,9 +171,7 @@ public class Cookie {
*
* @see #isSecure()
*/
public void setSecure (boolean secure) {
isSecure = secure;
}
void setSecure (boolean secure);
/**
* Returns the version of the cookie specification to which this
@ -240,9 +182,7 @@ public class Cookie {
* @see #setVersion(int)
*
*/
public int getVersion() {
return cookieVersion;
}
int getVersion();
/**
* Sets the version of the cookie specification to which this
@ -252,9 +192,7 @@ public class Cookie {
*
* @see #getVersion
*/
public void setVersion(int version) {
cookieVersion = version;
}
void setVersion(int version);
/**
* Returns true if this cookie has expired.
@ -262,13 +200,7 @@ public class Cookie {
*
* @return <tt>true</tt> if the cookie has expired.
*/
public boolean isExpired(final Date date) {
if (date == null) {
throw new IllegalArgumentException("Date may not be null");
}
return (cookieExpiryDate != null
&& cookieExpiryDate.getTime() <= date.getTime());
}
boolean isExpired(final Date date);
/**
* Indicates whether the cookie had a path specified in a
@ -283,9 +215,7 @@ public class Cookie {
*
* @see #isPathAttributeSpecified
*/
public void setPathAttributeSpecified(boolean value) {
hasPathAttribute = value;
}
public void setPathAttributeSpecified(boolean value);
/**
* Returns <tt>true</tt> if cookie's path was set via a path attribute
@ -296,9 +226,7 @@ public class Cookie {
*
* @see #setPathAttributeSpecified
*/
public boolean isPathAttributeSpecified() {
return hasPathAttribute;
}
boolean isPathAttributeSpecified();
/**
* Indicates whether the cookie had a domain specified in a
@ -313,9 +241,7 @@ public class Cookie {
*
* @see #isDomainAttributeSpecified
*/
public void setDomainAttributeSpecified(boolean value) {
hasDomainAttribute = value;
}
void setDomainAttributeSpecified(boolean value);
/**
* Returns <tt>true</tt> if cookie's domain was set via a domain
@ -326,69 +252,7 @@ public class Cookie {
*
* @see #setDomainAttributeSpecified
*/
public boolean isDomainAttributeSpecified() {
return hasDomainAttribute;
}
public String toString() {
CharArrayBuffer buffer = new CharArrayBuffer(64);
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.value);
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
// ----------------------------------------------------- Instance Variables
private final String name;
private final String value;
/** Comment attribute. */
private String cookieComment;
/** Domain attribute. */
private String cookieDomain;
/** Expiration {@link Date}. */
private Date cookieExpiryDate;
/** Path attribute. */
private String cookiePath;
/** My secure flag. */
private boolean isSecure;
/**
* Specifies if the set-cookie header included a Path attribute for this
* cookie
*/
private boolean hasPathAttribute = false;
/**
* Specifies if the set-cookie header included a Domain attribute for this
* cookie
*/
private boolean hasDomainAttribute = false;
/** The version of the cookie specification I was created from. */
private int cookieVersion = 0;
boolean isDomainAttributeSpecified();
}

View File

@ -0,0 +1,395 @@
/*
* $HeadURL$
* $Revision$
* $Date$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.impl.cookie;
import java.util.Date;
import org.apache.http.cookie.Cookie;
import org.apache.http.util.CharArrayBuffer;
/**
* <p>
* HTTP "magic-cookie" represents a piece of state information
* that the HTTP agent and the target server can exchange to maintain
* a session.
* </p>
*
* @author B.C. Holmes
* @author <a href="mailto:jericho@thinkfree.com">Park, Sung-Gu</a>
* @author <a href="mailto:dsale@us.britannica.com">Doug Sale</a>
* @author Rod Waldhoff
* @author dIon Gillard
* @author Sean C. Sullivan
* @author <a href="mailto:JEvans@Cyveillance.com">John Evans</a>
* @author Marc A. Saegesser
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
* @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
*
* @version $Revision$
*/
public class BasicCookie implements Cookie {
/**
* Default Constructor taking a name and a value. The value may be null.
*
* @param name The name.
* @param value The value.
*/
public BasicCookie(final String name, final String value) {
super();
if (name == null) {
throw new IllegalArgumentException("Name may not be null");
}
this.name = name;
this.value = value;
}
/**
* Returns the name.
*
* @return String name The name
*/
public String getName() {
return this.name;
}
/**
* Returns the value.
*
* @return String value The current value.
*/
public String getValue() {
return this.value;
}
/**
* Returns the comment describing the purpose of this cookie, or
* <tt>null</tt> if no such comment has been defined.
*
* @return comment
*
* @see #setComment(String)
*/
public String getComment() {
return cookieComment;
}
/**
* If a user agent (web browser) presents this cookie to a user, the
* cookie's purpose will be described using this comment.
*
* @param comment
*
* @see #getComment()
*/
public void setComment(String comment) {
cookieComment = comment;
}
/**
* Returns the expiration {@link Date} of the cookie, or <tt>null</tt>
* if none exists.
* <p><strong>Note:</strong> the object returned by this method is
* considered immutable. Changing it (e.g. using setTime()) could result
* in undefined behaviour. Do so at your peril. </p>
* @return Expiration {@link Date}, or <tt>null</tt>.
*
* @see #setExpiryDate(java.util.Date)
*
*/
public Date getExpiryDate() {
return cookieExpiryDate;
}
/**
* Sets expiration date.
* <p><strong>Note:</strong> the object returned by this method is considered
* immutable. Changing it (e.g. using setTime()) could result in undefined
* behaviour. Do so at your peril.</p>
*
* @param expiryDate the {@link Date} after which this cookie is no longer valid.
*
* @see #getExpiryDate
*
*/
public void setExpiryDate (Date expiryDate) {
cookieExpiryDate = expiryDate;
}
/**
* Returns <tt>false</tt> if the cookie should be discarded at the end
* of the "session"; <tt>true</tt> otherwise.
*
* @return <tt>false</tt> if the cookie should be discarded at the end
* of the "session"; <tt>true</tt> otherwise
*/
public boolean isPersistent() {
return (null != cookieExpiryDate);
}
/**
* Returns domain attribute of the cookie.
*
* @return the value of the domain attribute
*
* @see #setDomain(java.lang.String)
*/
public String getDomain() {
return cookieDomain;
}
/**
* Sets the domain attribute.
*
* @param domain The value of the domain attribute
*
* @see #getDomain
*/
public void setDomain(String domain) {
if (domain != null) {
cookieDomain = domain.toLowerCase();
} else {
cookieDomain = null;
}
}
/**
* Returns the path attribute of the cookie
*
* @return The value of the path attribute.
*
* @see #setPath(java.lang.String)
*/
public String getPath() {
return cookiePath;
}
/**
* Sets the path attribute.
*
* @param path The value of the path attribute
*
* @see #getPath
*
*/
public void setPath(String path) {
cookiePath = path;
}
/**
* @return <code>true</code> if this cookie should only be sent over secure connections.
* @see #setSecure(boolean)
*/
public boolean isSecure() {
return isSecure;
}
/**
* Sets the secure attribute of the cookie.
* <p>
* When <tt>true</tt> the cookie should only be sent
* using a secure protocol (https). This should only be set when
* the cookie's originating server used a secure protocol to set the
* cookie's value.
*
* @param secure The value of the secure attribute
*
* @see #isSecure()
*/
public void setSecure (boolean secure) {
isSecure = secure;
}
/**
* Returns the version of the cookie specification to which this
* cookie conforms.
*
* @return the version of the cookie.
*
* @see #setVersion(int)
*
*/
public int getVersion() {
return cookieVersion;
}
/**
* Sets the version of the cookie specification to which this
* cookie conforms.
*
* @param version the version of the cookie.
*
* @see #getVersion
*/
public void setVersion(int version) {
cookieVersion = version;
}
/**
* Returns true if this cookie has expired.
* @param date Current time
*
* @return <tt>true</tt> if the cookie has expired.
*/
public boolean isExpired(final Date date) {
if (date == null) {
throw new IllegalArgumentException("Date may not be null");
}
return (cookieExpiryDate != null
&& cookieExpiryDate.getTime() <= date.getTime());
}
/**
* Indicates whether the cookie had a path specified in a
* path attribute of the <tt>Set-Cookie</tt> header. This value
* is important for generating the <tt>Cookie</tt> header because
* some cookie specifications require that the <tt>Cookie</tt> header
* should only include a path attribute if the cookie's path
* was specified in the <tt>Set-Cookie</tt> header.
*
* @param value <tt>true</tt> if the cookie's path was explicitly
* set, <tt>false</tt> otherwise.
*
* @see #isPathAttributeSpecified
*/
public void setPathAttributeSpecified(boolean value) {
hasPathAttribute = value;
}
/**
* Returns <tt>true</tt> if cookie's path was set via a path attribute
* in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's path was explicitly
* set, <tt>false</tt> otherwise.
*
* @see #setPathAttributeSpecified
*/
public boolean isPathAttributeSpecified() {
return hasPathAttribute;
}
/**
* Indicates whether the cookie had a domain specified in a
* domain attribute of the <tt>Set-Cookie</tt> header. This value
* is important for generating the <tt>Cookie</tt> header because
* some cookie specifications require that the <tt>Cookie</tt> header
* should only include a domain attribute if the cookie's domain
* was specified in the <tt>Set-Cookie</tt> header.
*
* @param value <tt>true</tt> if the cookie's domain was explicitly
* set, <tt>false</tt> otherwise.
*
* @see #isDomainAttributeSpecified
*/
public void setDomainAttributeSpecified(boolean value) {
hasDomainAttribute = value;
}
/**
* Returns <tt>true</tt> if cookie's domain was set via a domain
* attribute in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's domain was explicitly
* set, <tt>false</tt> otherwise.
*
* @see #setDomainAttributeSpecified
*/
public boolean isDomainAttributeSpecified() {
return hasDomainAttribute;
}
public String toString() {
CharArrayBuffer buffer = new CharArrayBuffer(64);
buffer.append("[version: ");
buffer.append(Integer.toString(this.cookieVersion));
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.name);
buffer.append("]");
buffer.append("[name: ");
buffer.append(this.value);
buffer.append("]");
buffer.append("[domain: ");
buffer.append(this.cookieDomain);
buffer.append("]");
buffer.append("[path: ");
buffer.append(this.cookiePath);
buffer.append("]");
buffer.append("[expiry: ");
buffer.append(this.cookieExpiryDate);
buffer.append("]");
return buffer.toString();
}
// ----------------------------------------------------- Instance Variables
private final String name;
private final String value;
/** Comment attribute. */
private String cookieComment;
/** Domain attribute. */
private String cookieDomain;
/** Expiration {@link Date}. */
private Date cookieExpiryDate;
/** Path attribute. */
private String cookiePath;
/** My secure flag. */
private boolean isSecure;
/**
* Specifies if the set-cookie header included a Path attribute for this
* cookie
*/
private boolean hasPathAttribute = false;
/**
* Specifies if the set-cookie header included a Domain attribute for this
* cookie
*/
private boolean hasDomainAttribute = false;
/** The version of the cookie specification I was created from. */
private int cookieVersion = 0;
}

View File

@ -78,7 +78,7 @@ public abstract class CookieSpecBase extends AbstractCookieSpec {
throw new MalformedCookieException("Cookie name may not be empty");
}
Cookie cookie = new Cookie(name, value);
Cookie cookie = new BasicCookie(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));

View File

@ -32,6 +32,8 @@ package org.apache.http.cookie;
import java.util.Comparator;
import org.apache.http.impl.cookie.BasicCookie;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@ -55,9 +57,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testUnequality1() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath("/a/b/");
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/a/");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) < 0);
@ -65,9 +67,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testUnequality2() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath("/a/b");
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/a");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) < 0);
@ -75,9 +77,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testEquality1() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath("/a");
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/a");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) == 0);
@ -85,9 +87,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testEquality2() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath("/a/");
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/a");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) == 0);
@ -95,9 +97,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testEquality3() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath(null);
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) == 0);
@ -105,9 +107,9 @@ public class TestCookiePathComparator extends TestCase {
}
public void testEquality4() {
Cookie cookie1 = new Cookie("name1", "value");
Cookie cookie1 = new BasicCookie("name1", "value");
cookie1.setPath("/this");
Cookie cookie2 = new Cookie("name1", "value");
Cookie cookie2 = new BasicCookie("name1", "value");
cookie2.setPath("/that");
Comparator comparator = new CookiePathComparator();
assertTrue(comparator.compare(cookie1, cookie2) == 0);

View File

@ -62,7 +62,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicDomainHandler();
h.parse(cookie, "www.somedomain.com");
assertEquals("www.somedomain.com", cookie.getDomain());
@ -70,7 +70,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainParseInvalid() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicDomainHandler();
try {
h.parse(cookie, "");
@ -87,7 +87,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainValidate1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -111,7 +111,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainValidate2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -128,7 +128,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainValidate3() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -137,7 +137,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainValidate4() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -151,7 +151,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainMatch1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -163,7 +163,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicDomainMatch2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new BasicDomainHandler();
@ -192,7 +192,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
// expected
}
try {
h.validate(new Cookie("name", "value"), null);
h.validate(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -204,7 +204,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
// expected
}
try {
h.match(new Cookie("name", "value"), null);
h.match(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -212,7 +212,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicPathHandler();
h.parse(cookie, "stuff");
assertEquals("stuff", cookie.getPath());
@ -226,7 +226,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -234,7 +234,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -242,7 +242,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch3() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/more-stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -250,7 +250,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch4() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuffed", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -258,7 +258,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch5() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/otherstuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -266,7 +266,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch6() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff/");
@ -274,14 +274,14 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicPathMatch7() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
assertTrue(h.match(cookie, origin));
}
public void testBasicPathValidate() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false);
CookieAttributeHandler h = new BasicPathHandler();
cookie.setPath("/stuff");
@ -310,7 +310,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
// expected
}
try {
h.match(new Cookie("name", "value"), null);
h.match(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -318,14 +318,14 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicMaxAgeParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicMaxAgeHandler();
h.parse(cookie, "2000");
assertNotNull(cookie.getExpiryDate());
}
public void testBasicMaxAgeParseInvalid() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicMaxAgeHandler();
try {
h.parse(cookie, "garbage");
@ -352,7 +352,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicCommentParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicCommentHandler();
h.parse(cookie, "whatever");
assertEquals("whatever", cookie.getComment());
@ -371,7 +371,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicSecureParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicSecureHandler();
h.parse(cookie, "whatever");
assertTrue(cookie.isSecure());
@ -380,7 +380,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicSecureMatch() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicSecureHandler();
CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
@ -411,7 +411,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
// expected
}
try {
h.match(new Cookie("name", "value"), null);
h.match(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -419,7 +419,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicExpiresParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
DateFormat dateformat = new SimpleDateFormat(DateUtils.PATTERN_RFC1123, Locale.US);
@ -432,7 +432,7 @@ public class TestBasicCookieAttribHandlers extends TestCase {
}
public void testBasicExpiresParseInvalid() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
try {
h.parse(cookie, "garbage");

View File

@ -658,7 +658,7 @@ public class TestBrowserCompatSpec extends TestCase {
* browser compatibility mode.
*/
public void testSecondDomainLevelCookie() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -670,7 +670,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testSecondDomainLevelCookieMatch1() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -682,7 +682,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testSecondDomainLevelCookieMatch2() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain("sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -694,7 +694,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testSecondDomainLevelCookieMatch3() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -706,7 +706,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testInvalidSecondDomainLevelCookieMatch1() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -718,7 +718,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testInvalidSecondDomainLevelCookieMatch2() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain("sourceforge.net");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -731,7 +731,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testMatchBlankPath() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin("host", 80, " ", false);
@ -740,7 +740,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testMatchNullCookieDomain() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin("host", 80, "/", false);
assertFalse(cookiespec.match(cookie, origin));
@ -748,7 +748,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testMatchNullCookiePath() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
CookieOrigin origin = new CookieOrigin("host", 80, "/", false);
assertTrue(cookiespec.match(cookie, origin));
@ -756,7 +756,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMatch1() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin("host", 80, "/", false);
@ -765,7 +765,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMatch2() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain(".whatever.com");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin(".whatever.com", 80, "/", false);
@ -774,7 +774,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMatch3() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain(".whatever.com");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin(".really.whatever.com", 80, "/", false);
@ -783,7 +783,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMatch4() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar", false);
@ -792,7 +792,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMismatch1() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host1");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin("host2", 80, "/", false);
@ -801,7 +801,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMismatch2() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain(".aaaaaaaaa.com");
cookie.setPath("/");
CookieOrigin origin = new CookieOrigin(".bbbbbbbb.com", 80, "/", false);
@ -810,7 +810,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMismatch3() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/foobar");
CookieOrigin origin = new CookieOrigin("host", 80, "/foo", false);
@ -819,7 +819,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMismatch4() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/foobar");
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar/", false);
@ -828,7 +828,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMatch5() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/foobar/r");
CookieOrigin origin = new CookieOrigin("host", 80, "/foobar/", false);
@ -837,7 +837,7 @@ public class TestBrowserCompatSpec extends TestCase {
public void testCookieMismatch6() throws Exception {
CookieSpec cookiespec = new BrowserCompatSpec();
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
cookie.setDomain("host");
cookie.setPath("/foobar");
cookie.setSecure(true);
@ -846,7 +846,7 @@ public class TestBrowserCompatSpec extends TestCase {
}
public void testInvalidMatchDomain() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain("beta.gamma.com");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
@ -878,14 +878,14 @@ public class TestBrowserCompatSpec extends TestCase {
* Tests if null cookie values are handled correctly.
*/
public void testNullCookieValueFormatting() {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".whatever.com");
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
cookie.setPathAttributeSpecified(true);
CookieSpec cookiespec = new BrowserCompatSpec();
Header[] headers = cookiespec.formatCookies(new Cookie[]{cookie});
Header[] headers = cookiespec.formatCookies(new Cookie[]{ cookie });
assertNotNull(headers);
assertEquals(1, headers.length);
assertEquals("name=", headers[0].getValue());
@ -933,7 +933,7 @@ public class TestBrowserCompatSpec extends TestCase {
// expected
}
try {
cookiespec.validate(new Cookie("name", null), null);
cookiespec.validate(new BasicCookie("name", null), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -945,7 +945,7 @@ public class TestBrowserCompatSpec extends TestCase {
// expected
}
try {
cookiespec.match(new Cookie("name", null), null);
cookiespec.match(new BasicCookie("name", null), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -957,7 +957,7 @@ public class TestBrowserCompatSpec extends TestCase {
// expected
}
try {
cookiespec.formatCookies(new Cookie[] {});
cookiespec.formatCookies(new BasicCookie[] {});
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected

View File

@ -209,14 +209,14 @@ public class TestCookieNetscapeDraft extends TestCase {
}
public void testFormatCookies() throws Exception {
Cookie c1 = new Cookie("name1", "value1");
Cookie c1 = new BasicCookie("name1", "value1");
c1.setDomain(".whatever.com");
c1.setDomainAttributeSpecified(true);
c1.setPath("/");
c1.setPathAttributeSpecified(true);
Cookie c2 = new Cookie("name2", "value2");
Cookie c3 = new Cookie("name3", null);
Cookie c2 = new BasicCookie("name2", "value2");
Cookie c3 = new BasicCookie("name3", null);
CookieSpec cookiespec = new NetscapeDraftSpec();
Header[] headers = cookiespec.formatCookies(new Cookie[] {c1, c2, c3});
@ -246,7 +246,7 @@ public class TestCookieNetscapeDraft extends TestCase {
// expected
}
try {
cookiespec.formatCookies(new Cookie[] {});
cookiespec.formatCookies(new BasicCookie[] {});
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected

View File

@ -169,7 +169,7 @@ public class TestCookieRFC2109Spec extends TestCase {
* browser compatibility mode.
*/
public void testSecondDomainLevelCookie() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setPath("/");
cookie.setDomainAttributeSpecified(true);
@ -186,7 +186,7 @@ public class TestCookieRFC2109Spec extends TestCase {
}
public void testSecondDomainLevelCookieMatch() throws Exception {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".sourceforge.net");
cookie.setPath("/");
cookie.setDomainAttributeSpecified(true);
@ -361,7 +361,7 @@ public class TestCookieRFC2109Spec extends TestCase {
* Tests if null cookie values are handled correctly.
*/
public void testNullCookieValueFormatting() {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomain(".whatever.com");
cookie.setPath("/");
cookie.setDomainAttributeSpecified(true);
@ -383,7 +383,7 @@ public class TestCookieRFC2109Spec extends TestCase {
}
public void testCookieNullDomainNullPathFormatting() {
Cookie cookie = new Cookie("name", null);
Cookie cookie = new BasicCookie("name", null);
cookie.setDomainAttributeSpecified(true);
cookie.setPath("/");
cookie.setPathAttributeSpecified(true);
@ -403,16 +403,16 @@ public class TestCookieRFC2109Spec extends TestCase {
}
public void testCookieOrderingByPath() {
Cookie c1 = new Cookie("name1", "value1");
Cookie c1 = new BasicCookie("name1", "value1");
c1.setPath("/a/b/c");
c1.setPathAttributeSpecified(true);
Cookie c2 = new Cookie("name2", "value2");
Cookie c2 = new BasicCookie("name2", "value2");
c2.setPath("/a/b");
c2.setPathAttributeSpecified(true);
Cookie c3 = new Cookie("name3", "value3");
Cookie c3 = new BasicCookie("name3", "value3");
c3.setPath("/a");
c3.setPathAttributeSpecified(true);
Cookie c4 = new Cookie("name4", "value4");
Cookie c4 = new BasicCookie("name4", "value4");
c4.setPath("/");
c4.setPathAttributeSpecified(true);
@ -453,7 +453,7 @@ public class TestCookieRFC2109Spec extends TestCase {
// expected
}
try {
cookiespec.formatCookies(new Cookie[] {});
cookiespec.formatCookies(new BasicCookie[] {});
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected

View File

@ -56,7 +56,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainValidate1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -73,7 +73,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainValidate2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -97,7 +97,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainValidate3() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -114,7 +114,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainValidate4() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -131,7 +131,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainMatch1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -143,7 +143,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
}
public void testNetscapeDomainMatch2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new NetscapeDomainHandler();
@ -160,7 +160,7 @@ public class TestNetscapeCookieAttribHandlers extends TestCase {
// expected
}
try {
h.match(new Cookie("name", "value"), null);
h.match(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected

View File

@ -56,7 +56,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new RFC2109DomainHandler();
h.parse(cookie, "somehost");
@ -77,7 +77,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainValidate1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -101,7 +101,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainValidate2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -125,7 +125,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainValidate3() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -142,7 +142,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainValidate4() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -166,7 +166,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainMatch1() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -178,7 +178,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainMatch2() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.whatever.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -187,7 +187,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainMatch3() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -196,7 +196,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109DomainMatch4() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109DomainHandler();
@ -219,7 +219,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
// expected
}
try {
h.validate(new Cookie("name", "value"), null);
h.validate(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -231,7 +231,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
// expected
}
try {
h.match(new Cookie("name", "value"), null);
h.match(new BasicCookie("name", "value"), null);
fail("IllegalArgumentException must have been thrown");
} catch (IllegalArgumentException ex) {
// expected
@ -239,14 +239,14 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109VersionParse() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new RFC2109VersionHandler();
h.parse(cookie, "12");
assertEquals(12, cookie.getVersion());
}
public void testRFC2109VersionParseInvalid() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieAttributeHandler h = new RFC2109VersionHandler();
try {
h.parse(cookie, "garbage");
@ -269,7 +269,7 @@ public class TestRFC2109CookieAttribHandlers extends TestCase {
}
public void testRFC2109VersionValidate() throws Exception {
Cookie cookie = new Cookie("name", "value");
Cookie cookie = new BasicCookie("name", "value");
CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
CookieAttributeHandler h = new RFC2109VersionHandler();