commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie TestCookiePolicy.java TestCookie.java TestCookieAll.java
Date Sun, 25 Apr 2004 12:25:09 GMT
olegk       2004/04/25 05:25:09

  Modified:    httpclient/src/java/org/apache/commons/httpclient/cookie
                        CookiePolicy.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestWebapp.java
               httpclient/src/test/org/apache/commons/httpclient/cookie
                        TestCookie.java TestCookieAll.java
  Added:       httpclient/src/test/org/apache/commons/httpclient/cookie
                        TestCookiePolicy.java
  Removed:     httpclient/src/test/org/apache/commons/httpclient
                        TestWebappCookie.java
  Log:
  Test cases for the cookie policy class
  
  Contributed by Oleg Kalnichevski
  
  Revision  Changes    Path
  1.13      +8 -4      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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CookiePolicy.java	18 Apr 2004 23:51:37 -0000	1.12
  +++ CookiePolicy.java	25 Apr 2004 12:25:09 -0000	1.13
  @@ -172,7 +172,11 @@
           if (id == null) {
               throw new IllegalArgumentException("Id may not be null");
           }
  -        return (CookieSpec)SPECS.get(id);
  +        CookieSpec cookiespec = (CookieSpec)SPECS.get(id);
  +        if (cookiespec == null) {
  +            throw new IllegalStateException("Unsupported cookie spec '" + id + "'");
  +        }
  +        return cookiespec;
       } 
   
       /**
  
  
  
  1.10      +4 -5      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebapp.java
  
  Index: TestWebapp.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebapp.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestWebapp.java	22 Feb 2004 18:08:50 -0000	1.9
  +++ TestWebapp.java	25 Apr 2004 12:25:09 -0000	1.10
  @@ -66,7 +66,6 @@
           suite.addTest(TestWebappHeaders.suite());
           suite.addTest(TestWebappRedirect.suite());
           suite.addTest(TestWebappBasicAuth.suite());
  -        suite.addTest(TestWebappCookie.suite());
           suite.addTest(TestWebappPostMethod.suite());
           suite.addTest(TestWebappMultiPostMethod.suite());
           suite.addTest(TestWebappNoncompliant.suite());
  
  
  
  1.2       +4 -40     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookie.java
  
  Index: TestCookie.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookie.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCookie.java	24 Apr 2004 19:39:24 -0000	1.1
  +++ TestCookie.java	25 Apr 2004 12:25:09 -0000	1.2
  @@ -54,31 +54,14 @@
   public class TestCookie extends TestCookieBase {
   
   
  -    // -------------------------------------------------------------- Constants
  -
  -    private static final String DOMAIN_NAME = "www.apache.org";
  -    private static final String TEST_COOKIE = "cookie-name=cookie-value";
  -    private static final String OLD_EXPIRY = "Expires=Thu, 01-Jan-1970 00:00:10 GMT";
  -    private static final String SEP = ";";
  -    private static final String ROOT_PATH = "/";
  -    private static final int DEFAULT_PORT = 80;
  -
  -    private String[] testName = { "custno", "name", "name" };
  -    private String[] testValue = { "12345", "John", "Doe, John" };
  -    private String[] testDomain = { "www.apache.org", ".apache.org",
  -        ".apache.org" };
  -
       // ------------------------------------------------------------ Constructor
   
  -
       public TestCookie(String name) {
           super(name);
       }
   
  -
       // ------------------------------------------------------- TestCase Methods
   
  -
       public static Test suite() {
           return new TestSuite(TestCookie.class);
       }
  @@ -152,24 +135,5 @@
               // expected
           }
       }
  -    /*
  -    public void testIgnoreCookies() throws Exception {
  -        String headers = 
  -            "HTTP/1.1 401 OK\r\n" +
  -            "Connection: close\r\n" +
  -            "Content-Length: 0\r\n" +
  -            "Set-Cookie: custno = 12345; comment=test; version=1," +
  -            " name=John; version=1; max-age=600; secure; domain=.apache.org";
  -        
  -        conn.addResponse(headers);
  -        
  -        GetMethod get = new GetMethod("/");
  -        get.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
  -        client.executeMethod(get);
  -        
  -        assertEquals("Cookie parsing should have been disabled", 
  -                0, client.getState().getCookies().length);
  -    }
  -    */
   }
   
  
  
  
  1.2       +5 -4      jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java
  
  Index: TestCookieAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookieAll.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCookieAll.java	24 Apr 2004 19:39:24 -0000	1.1
  +++ TestCookieAll.java	25 Apr 2004 12:25:09 -0000	1.2
  @@ -47,6 +47,7 @@
           suite.addTest(TestCookieRFC2109Spec.suite());
           suite.addTest(TestCookieNetscapeDraft.suite());
           suite.addTest(TestCookieIgnoreSpec.suite());
  +        suite.addTest(TestCookiePolicy.suite());
           return suite;
       }
   
  
  
  
  1.1                  jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookiePolicy.java
  
  Index: TestCookiePolicy.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookiePolicy.java,v
1.1 2004/04/25 12:25:09 olegk Exp $
   * $Revision: 1.1 $
   * $Date: 2004/04/25 12:25:09 $
   * ====================================================================
   *
   *  Copyright 1999-2004 The Apache Software Foundation
   *
   *  Licensed 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.commons.httpclient.cookie;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  
  /**
   * Test cases for Cookie Policy
   *
   * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
   * 
   * @version $Revision: 1.1 $
   */
  public class TestCookiePolicy extends TestCookieBase {
  
      // ------------------------------------------------------------ Constructor
  
      public TestCookiePolicy(String name) {
          super(name);
      }
  
      // ------------------------------------------------------- TestCase Methods
  
      public static Test suite() {
          return new TestSuite(TestCookiePolicy.class);
      }
  
      public void testRegisterNullPolicyId() {
          try {
              CookiePolicy.registerCookieSpec(null, null);
              fail("IllegalArgumentException must have been thrown");
          } catch (IllegalArgumentException expected) {
          }
      }
  
      public void testRegisterNullPolicy() {
          try {
              CookiePolicy.registerCookieSpec("whatever", null);
              fail("IllegalArgumentException must have been thrown");
          } catch (IllegalArgumentException expected) {
          }
      }
  
      public void testUnregisterNullPolicy() {
          try {
              CookiePolicy.unregisterCookieSpec(null);
              fail("IllegalArgumentException must have been thrown");
          } catch (IllegalArgumentException expected) {
          }
      }
  
      public void testGetPolicyNullId() {
          try {
              CookiePolicy.getCookieSpec(null);
              fail("IllegalArgumentException must have been thrown");
          } catch (IllegalArgumentException expected) {
          }
      }
  
      public void testRegisterUnregister() {
          CookiePolicy.registerCookieSpec("whatever", new CookieSpecBase());
          CookiePolicy.unregisterCookieSpec("whatever");
          try {
              CookiePolicy.getCookieSpec("whatever");
              fail("IllegalStateException must have been thrown");
          } catch (IllegalStateException expected) {
          }
      }
  
      public void testGetDefaultPolicy() {
          assertNotNull(CookiePolicy.getDefaultSpec());
      }
  }
  
  
  
  

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


Mime
View raw message