You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2004/09/14 22:11:32 UTC

cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie TestCookieCompatibilitySpec.java TestCookiePolicy.java

olegk       2004/09/14 13:11:32

  Modified:    httpclient/src/java/org/apache/commons/httpclient
                        HttpMethodBase.java HttpMethodDirector.java
                        HttpMethodRetryHandler.java
               httpclient/src/java/org/apache/commons/httpclient/cookie
                        CookiePolicy.java CookieSpec.java
                        CookieSpecBase.java IgnoreCookiesSpec.java
               httpclient/src/java/org/apache/commons/httpclient/params
                        DefaultHttpParamsFactory.java HttpMethodParams.java
               httpclient/src/java/org/apache/commons/httpclient/util
                        DateParser.java
               httpclient/src/test/org/apache/commons/httpclient/cookie
                        TestCookieCompatibilitySpec.java
                        TestCookiePolicy.java
  Log:
  PR #31163 (DateParser refactoring; Stateful cookie specs)
  
  Changelog:
  
  * CookieSpec instantiated on a per method basis
  * CookieSpec classes made stateful
  * DateParser no longer tightly coupled with the DefaultHttpParams
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  1.212     +25 -6     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
  
  Index: HttpMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
  retrieving revision 1.211
  retrieving revision 1.212
  diff -u -r1.211 -r1.212
  --- HttpMethodBase.java	19 Aug 2004 21:39:26 -0000	1.211
  +++ HttpMethodBase.java	14 Sep 2004 20:11:31 -0000	1.212
  @@ -34,6 +34,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.InterruptedIOException;
  +import java.util.Collection;
   
   import org.apache.commons.httpclient.auth.AuthState;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
  @@ -177,6 +178,10 @@
       /** Whether the HTTP request has been transmitted to the target
        * server it its entirety */
       private boolean requestSent = false;
  +    
  +    /** Actual cookie policy */
  +    private CookieSpec cookiespec = null;
  +    
       // ----------------------------------------------------------- Constructors
   
       /**
  @@ -1045,6 +1050,7 @@
           connectionCloseForced = false;
           hostAuthState.invalidate();
           proxyAuthState.invalidate();
  +        cookiespec = null;
           requestSent = false;
       }
   
  @@ -1113,6 +1119,19 @@
       }
   
   
  +    /** 
  +     * Returns the actual cookie policy
  +     * 
  +     * @return cookie spec
  +     */
  +    private CookieSpec getCookieSpec() {
  +    	if (this.cookiespec == null) {
  +    		this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
  +    		this.cookiespec.setValidDateFormats(
  +            		(Collection)this.params.getParameter(HttpMethodParams.DATE_PATTERNS));
  +    	}
  +    	return this.cookiespec;
  +    }
   
       /**
        * Generates <tt>Cookie</tt> request headers for those {@link Cookie cookie}s
  @@ -1141,7 +1160,7 @@
               }
           }
   
  -        CookieSpec matcher = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
  +        CookieSpec matcher = getCookieSpec();
           Cookie[] cookies = matcher.match(conn.getHost(), conn.getPort(),
               getPath(), conn.isSecure(), state.getCookies());
           if ((cookies != null) && (cookies.length > 0)) {
  @@ -1435,7 +1454,7 @@
               headers = getResponseHeaderGroup().getHeaders("set-cookie");
           }
           
  -        CookieSpec parser = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
  +        CookieSpec parser = getCookieSpec();
           for (int i = 0; i < headers.length; i++) {
               Header header = headers[i];
               Cookie[] cookies = null;
  
  
  
  1.29      +4 -4      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
  
  Index: HttpMethodDirector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodDirector.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- HttpMethodDirector.java	5 Jul 2004 22:46:58 -0000	1.28
  +++ HttpMethodDirector.java	14 Sep 2004 20:11:31 -0000	1.29
  @@ -406,7 +406,7 @@
                       // ========================================
                       HttpMethodRetryHandler handler = 
                           (HttpMethodRetryHandler)method.getParams().getParameter(
  -                                HttpMethodRetryHandler.HANDLER);
  +                                HttpMethodParams.RETRY_HANDLER);
                       if (handler == null) {
                           handler = new DefaultHttpMethodRetryHandler();
                       }
  
  
  
  1.2       +3 -11     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodRetryHandler.java
  
  Index: HttpMethodRetryHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodRetryHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpMethodRetryHandler.java	5 Jul 2004 22:46:58 -0000	1.1
  +++ HttpMethodRetryHandler.java	14 Sep 2004 20:11:31 -0000	1.2
  @@ -49,14 +49,6 @@
   public interface HttpMethodRetryHandler {
   
       /**
  -     * Sets the method retry handler parameter.
  -     * <p>
  -     * This parameter expects a value of type {@link HttpMethodRetryHandler}.
  -     * </p>
  -     */ 
  -    public static final String HANDLER = "http.method.retry-handler";
  -    
  -    /**
        * Determines if a method should be retried after an HttpRecoverableException
        * occurs during execution.
        * 
  
  
  
  1.15      +29 -19    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java
  
  Index: CookiePolicy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookiePolicy.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CookiePolicy.java	13 May 2004 04:02:00 -0000	1.14
  +++ CookiePolicy.java	14 Sep 2004 20:11:31 -0000	1.15
  @@ -95,11 +95,11 @@
       public static final String DEFAULT = "default";
       
       static {
  -        CookiePolicy.registerCookieSpec(DEFAULT, new RFC2109Spec());
  -        CookiePolicy.registerCookieSpec(RFC_2109, new RFC2109Spec());
  -        CookiePolicy.registerCookieSpec(BROWSER_COMPATIBILITY, new CookieSpecBase());
  -        CookiePolicy.registerCookieSpec(NETSCAPE, new NetscapeDraftSpec());
  -        CookiePolicy.registerCookieSpec(IGNORE_COOKIES, new IgnoreCookiesSpec());
  +        CookiePolicy.registerCookieSpec(DEFAULT, RFC2109Spec.class);
  +        CookiePolicy.registerCookieSpec(RFC_2109, RFC2109Spec.class);
  +        CookiePolicy.registerCookieSpec(BROWSER_COMPATIBILITY, CookieSpecBase.class);
  +        CookiePolicy.registerCookieSpec(NETSCAPE, NetscapeDraftSpec.class);
  +        CookiePolicy.registerCookieSpec(IGNORE_COOKIES, IgnoreCookiesSpec.class);
       }
       
       /**
  @@ -141,20 +141,20 @@
        * from {@link #getCookieSpec(String)}.
        * 
        * @param id the identifier for this specification
  -     * @param spec the {@link CookieSpec cookie specification} to register
  +     * @param clazz the {@link CookieSpec cookie specification} class to register
        * 
        * @see #getCookieSpec(String)
        * 
        * @since 3.0
        */
  -    public static void registerCookieSpec(final String id, final CookieSpec spec) {
  +    public static void registerCookieSpec(final String id, final Class clazz) {
            if (id == null) {
                throw new IllegalArgumentException("Id may not be null");
            }
  -        if (spec == null) {
  -            throw new IllegalArgumentException("Cookie spec may not be null");
  +        if (clazz == null) {
  +            throw new IllegalArgumentException("Cookie spec class may not be null");
           }
  -        SPECS.put(id, spec);
  +        SPECS.put(id.toLowerCase(), clazz);
       }
   
       /**
  @@ -168,7 +168,7 @@
            if (id == null) {
                throw new IllegalArgumentException("Id may not be null");
            }
  -        SPECS.remove(id);
  +         SPECS.remove(id.toLowerCase());
       }
   
       /**
  @@ -188,11 +188,20 @@
           if (id == null) {
               throw new IllegalArgumentException("Id may not be null");
           }
  -        CookieSpec cookiespec = (CookieSpec)SPECS.get(id);
  -        if (cookiespec == null) {
  -            throw new IllegalStateException("Unsupported cookie spec '" + id + "'");
  +        Class clazz = (Class)SPECS.get(id.toLowerCase());
  +
  +        if (clazz != null) {
  +            try {
  +                return (CookieSpec)clazz.newInstance();
  +            } catch (Exception e) {
  +                LOG.error("Error initializing cookie spec: " + id, e);
  +                throw new IllegalStateException(id + 
  +                    " cookie spec implemented by " +
  +                    clazz.getName() + " could not be initialized");
  +            }
  +        } else {
  +            throw new IllegalStateException("Unsupported cookie spec " + id);
           }
  -        return cookiespec;
       } 
   
       /**
  @@ -211,7 +220,8 @@
        * @param policy new default cookie policy
        *  <tt>(COMPATIBILITY | NETSCAPE_DRAFT | RFC2109)</tt>
        * 
  -     * @deprecated Use {@link CookiePolicy#registerCookieSpec(String, CookieSpec)}
  +     * @deprecated Use {@link CookiePolicy#registerCookieSpec(String, Class)}
  +     * @see #DEFAULT 
        */
       public static void setDefaultPolicy(int policy) {
           defaultPolicy = policy;
  
  
  
  1.11      +25 -6     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpec.java
  
  Index: CookieSpec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpec.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CookieSpec.java	13 May 2004 04:02:00 -0000	1.10
  +++ CookieSpec.java	14 Sep 2004 20:11:31 -0000	1.11
  @@ -29,6 +29,8 @@
   
   package org.apache.commons.httpclient.cookie;
   
  +import java.util.Collection;
  +
   import org.apache.commons.httpclient.Header;
   import org.apache.commons.httpclient.NameValuePair;
   import org.apache.commons.httpclient.Cookie;
  @@ -99,7 +101,7 @@
         * @throws MalformedCookieException if an exception occurs during parsing
         * @throws IllegalArgumentException if an input parameter is illegal
         */
  -    void parseAttribute(final NameValuePair attribute, final Cookie cookie)
  +    void parseAttribute(NameValuePair attribute, Cookie cookie)
         throws MalformedCookieException, IllegalArgumentException;
   
       /**
  @@ -119,6 +121,23 @@
         final Cookie cookie) 
         throws MalformedCookieException, IllegalArgumentException;
       
  +    
  +    /**
  +     * Sets the {@link Collection} of date patterns used for parsing. The String patterns must be 
  +     * compatible with {@link java.text.SimpleDateFormat}.
  +     *
  +     * @param datepatterns collection of date patterns
  +     */
  +    void setValidDateFormats(Collection datepatterns);
  +    
  +    /**
  +     * Returns the {@link Collection} of date patterns used for parsing. The String patterns are compatible 
  +     * with the {@link java.text.SimpleDateFormat}.
  +     *
  +     * @return collection of date patterns
  +     */
  +    Collection getValidDateFormats();
  +    
       /**
        * Determines if a Cookie matches a location.
        *
  @@ -158,7 +177,7 @@
        * 
        * @since 3.0
        */
  -    boolean domainMatch(final String host, final String domain);
  +    boolean domainMatch(String host, String domain);
   
       /**
        * Performs path-match as defined by the cookie specification.
  @@ -168,7 +187,7 @@
        * 
        * @since 3.0
        */
  -    boolean pathMatch(final String path, final String topmostPath);
  +    boolean pathMatch(String path, String topmostPath);
   
       /**
        * Create a <tt>"Cookie"</tt> header value for an array of cookies.
  
  
  
  1.27      +18 -6     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java
  
  Index: CookieSpecBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/CookieSpecBase.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- CookieSpecBase.java	27 Apr 2004 22:35:21 -0000	1.26
  +++ CookieSpecBase.java	14 Sep 2004 20:11:31 -0000	1.27
  @@ -29,6 +29,7 @@
   
   package org.apache.commons.httpclient.cookie;
   
  +import java.util.Collection;
   import java.util.Date;
   import java.util.LinkedList;
   import java.util.List;
  @@ -64,6 +65,9 @@
       /** Log object */
       protected static final Log LOG = LogFactory.getLog(CookieSpec.class);
   
  +    /** Valid date patterns */
  +    private Collection datepatterns = null;
  +    
       /** Default constructor */
       public CookieSpecBase() {
           super();
  @@ -153,7 +157,7 @@
                   i2 = header.length(); 
               }
               try {
  -                DateParser.parseDate(header.substring(i1, i2));
  +                DateParser.parseDate(header.substring(i1, i2), this.datepatterns);
                   isNetscapeCookie = true; 
               } catch (DateParseException e) {
                   // Does not look like a valid expiry date
  @@ -320,7 +324,7 @@
               }
   
               try {
  -                cookie.setExpiryDate(DateParser.parseDate(paramValue));
  +                cookie.setExpiryDate(DateParser.parseDate(paramValue, this.datepatterns));
               } catch (DateParseException dpe) {
                   LOG.debug("Error parsing cookie date", dpe);
                   throw new MalformedCookieException(
  @@ -336,7 +340,15 @@
       }
   
       
  -    /**
  +	public Collection getValidDateFormats() {
  +		return this.datepatterns;
  +	}
  +
  +	public void setValidDateFormats(final Collection datepatterns) {
  +		this.datepatterns = datepatterns;
  +	}
  +
  +	/**
         * Performs most common {@link Cookie} validation
         *
         * @param host the host from which the {@link Cookie} was received
  
  
  
  1.6       +18 -3     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java
  
  Index: IgnoreCookiesSpec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IgnoreCookiesSpec.java	13 May 2004 04:02:00 -0000	1.5
  +++ IgnoreCookiesSpec.java	14 Sep 2004 20:11:31 -0000	1.6
  @@ -29,6 +29,8 @@
   
   package org.apache.commons.httpclient.cookie;
   
  +import java.util.Collection;
  +
   import org.apache.commons.httpclient.Cookie;
   import org.apache.commons.httpclient.Header;
   import org.apache.commons.httpclient.NameValuePair;
  @@ -55,6 +57,19 @@
           return new Cookie[0];
       }
   
  +    /**
  +     * @return <code>null</code>
  +     */
  +	public Collection getValidDateFormats() {
  +		return null;
  +	}
  +	
  +    /**
  +     * Does nothing.
  +     */
  +	public void setValidDateFormats(Collection datepatterns) {
  +	}
  +	
       /**
        * @return <code>null</code>
        */
  
  
  
  1.12      +5 -6      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java
  
  Index: DefaultHttpParamsFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultHttpParamsFactory.java	5 Jul 2004 22:46:59 -0000	1.11
  +++ DefaultHttpParamsFactory.java	14 Sep 2004 20:11:32 -0000	1.12
  @@ -33,7 +33,6 @@
   import java.util.Arrays;
   
   import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
  -import org.apache.commons.httpclient.HttpMethodRetryHandler;
   import org.apache.commons.httpclient.HttpVersion;
   import org.apache.commons.httpclient.SimpleHttpConnectionManager;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
  @@ -75,7 +74,7 @@
           params.setCookiePolicy(CookiePolicy.RFC_2109);
           params.setHttpElementCharset("US-ASCII");
           params.setContentCharset("ISO-8859-1");
  -        params.setParameter(HttpMethodRetryHandler.HANDLER, new DefaultHttpMethodRetryHandler());
  +        params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
           
           ArrayList datePatterns = new ArrayList();
           datePatterns.addAll(
  @@ -98,7 +97,7 @@
                   }
               )
           );
  -        params.setParameter(DateParser.KEY_DATE_PATTERNS, datePatterns);
  +        params.setParameter(HttpMethodParams.DATE_PATTERNS, datePatterns);
               
           // TODO: To be removed. Provided for backward compatibility
           String agent = null;
  
  
  
  1.14      +23 -4     jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java
  
  Index: HttpMethodParams.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- HttpMethodParams.java	13 May 2004 04:01:22 -0000	1.13
  +++ HttpMethodParams.java	14 Sep 2004 20:11:32 -0000	1.14
  @@ -29,6 +29,7 @@
   
   package org.apache.commons.httpclient.params;
   
  +import org.apache.commons.httpclient.HttpMethodRetryHandler;
   import org.apache.commons.httpclient.HttpVersion;
   import org.apache.commons.httpclient.cookie.CookiePolicy;
   import org.apache.commons.logging.Log;
  @@ -229,6 +230,24 @@
        */
       public static final String SO_TIMEOUT = "http.socket.timeout"; 
   
  +    /**
  +     * The key used to look up the date patterns used for parsing. The String patterns are stored
  +     * in a {@link java.util.Collection} and must be compatible with 
  +     * {@link java.text.SimpleDateFormat}.
  +     * <p>
  +     * This parameter expects a value of type {@link java.util.Collection}.
  +     * </p>
  +     */
  +    public static final String DATE_PATTERNS = "http.dateparser.patterns";
  +
  +    /**
  +     * Sets the method retry handler parameter.
  +     * <p>
  +     * This parameter expects a value of type {@link HttpMethodRetryHandler}.
  +     * </p>
  +     */ 
  +    public static final String RETRY_HANDLER = "http.method.retry-handler";
  +    
       /**
        * Creates a new collection of parameters with the collection returned
        * by {@link #getDefaultParams()} as a parent. The collection will defer
  
  
  
  1.10      +10 -27    jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/DateParser.java
  
  Index: DateParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/util/DateParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DateParser.java	18 Apr 2004 23:51:38 -0000	1.9
  +++ DateParser.java	14 Sep 2004 20:11:32 -0000	1.10
  @@ -38,7 +38,6 @@
   import java.util.Locale;
   import java.util.TimeZone;
   
  -import org.apache.commons.httpclient.params.DefaultHttpParams;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -56,14 +55,6 @@
       private static final Log LOG = LogFactory.getLog(DateParser.class);
   
       /**
  -     * The key used to look up the date patterns used for parsing.  The String patterns are stored
  -     * in a {@link Collection} and must be compatible with {@link SimpleDateFormat}.
  -     * 
  -     * @see org.apache.commons.httpclient.params.DefaultHttpParams
  -     */
  -    public static final String KEY_DATE_PATTERNS = "http.dateParser.patterns";
  -
  -    /**
        * Date format pattern used to parse HTTP date headers in RFC 1123 format.
        */
       public static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";
  @@ -79,6 +70,8 @@
        */
       public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
   
  +    private static final Collection DEFAULT_PATTERNS = Arrays.asList(
  +    		new String[] { PATTERN_ASCTIME, PATTERN_RFC1036, PATTERN_RFC1123 } );
       /**
        * Parses a date value.  The formats used for parsing the date value are retrieved from
        * the default http params.
  @@ -89,21 +82,9 @@
        *
        * @throws DateParseException if the value could not be parsed using any of the 
        * supported date formats
  -     * 
  -     * @see DefaultHttpParams#getDefaultParams()
        */
       public static Date parseDate(String dateValue) throws DateParseException {
  -        
  -        Collection patterns = (Collection) DefaultHttpParams.getDefaultParams().getParameter(
  -            KEY_DATE_PATTERNS
  -        );
  -        if (patterns == null) {
  -            LOG.warn("DateParser patterns not included in the default params.");
  -            patterns = Arrays.asList(
  -                new String[] { PATTERN_ASCTIME, PATTERN_RFC1036, PATTERN_RFC1123 }
  -            );
  -        }
  -        return parseDate(dateValue, patterns);
  +        return parseDate(dateValue, null);
       }
       
       /**
  @@ -116,7 +97,7 @@
        * 
        * @throws DateParseException if none of the dataFormats could parse the dateValue
        */
  -    private static Date parseDate(
  +    public static Date parseDate(
           String dateValue, 
           Collection dateFormats
       ) throws DateParseException {
  @@ -124,7 +105,9 @@
           if (dateValue == null) {
               throw new IllegalArgumentException("dateValue is null");
           }
  -
  +        if (dateFormats == null) {
  +        	dateFormats = DEFAULT_PATTERNS;
  +        }
           // trim single quotes around date if present
           // see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5279
           if (dateValue.length() > 1 
  
  
  
  1.7       +11 -4     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java
  
  Index: TestCookieCompatibilitySpec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookieCompatibilitySpec.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestCookieCompatibilitySpec.java	5 Jun 2004 16:49:20 -0000	1.6
  +++ TestCookieCompatibilitySpec.java	14 Sep 2004 20:11:32 -0000	1.7
  @@ -28,6 +28,7 @@
   
   package org.apache.commons.httpclient.cookie;
   
  +import java.util.Collection;
   import java.util.Date;
   
   import junit.framework.Test;
  @@ -38,6 +39,9 @@
   import org.apache.commons.httpclient.HttpException;
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.httpclient.NameValuePair;
  +import org.apache.commons.httpclient.params.DefaultHttpParamsFactory;
  +import org.apache.commons.httpclient.params.HttpMethodParams;
  +import org.apache.commons.httpclient.params.HttpParams;
   
   
   /**
  @@ -768,7 +772,10 @@
   
       private void checkDate(String date) throws Exception {
           Header header = new Header("Set-Cookie", "custno=12345;Expires='"+date+"';");
  +        HttpParams params = new DefaultHttpParamsFactory().getDefaultParams();
           CookieSpec cookiespec = new CookieSpecBase();
  +        cookiespec.setValidDateFormats(
  +        		(Collection)params.getParameter(HttpMethodParams.DATE_PATTERNS));
           cookieParse(cookiespec, "localhost", 80, "/", false, header);
       }
   
  
  
  
  1.2       +5 -5      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookiePolicy.java
  
  Index: TestCookiePolicy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookiePolicy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCookiePolicy.java	25 Apr 2004 12:25:09 -0000	1.1
  +++ TestCookiePolicy.java	14 Sep 2004 20:11:32 -0000	1.2
  @@ -86,7 +86,7 @@
       }
   
       public void testRegisterUnregister() {
  -        CookiePolicy.registerCookieSpec("whatever", new CookieSpecBase());
  +        CookiePolicy.registerCookieSpec("whatever", CookieSpecBase.class);
           CookiePolicy.unregisterCookieSpec("whatever");
           try {
               CookiePolicy.getCookieSpec("whatever");
  
  
  

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