1   /*
2    * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/cookie/TestCookiePolicy.java,v 1.2 2004/09/14 20:11:32 olegk Exp $
3    * $Revision: 155418 $
4    * $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
5    * ====================================================================
6    *
7    *  Copyright 1999-2004 The Apache Software Foundation
8    *
9    *  Licensed under the Apache License, Version 2.0 (the "License");
10   *  you may not use this file except in compliance with the License.
11   *  You may obtain a copy of the License at
12   *
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   *
15   *  Unless required by applicable law or agreed to in writing, software
16   *  distributed under the License is distributed on an "AS IS" BASIS,
17   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   *  See the License for the specific language governing permissions and
19   *  limitations under the License.
20   * ====================================================================
21   *
22   * This software consists of voluntary contributions made by many
23   * individuals on behalf of the Apache Software Foundation.  For more
24   * information on the Apache Software Foundation, please see
25   * <http://www.apache.org/>.
26   *
27   */
28  
29  package org.apache.commons.httpclient.cookie;
30  
31  import junit.framework.Test;
32  import junit.framework.TestSuite;
33  
34  
35  /***
36   * Test cases for Cookie Policy
37   *
38   * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
39   * 
40   * @version $Revision: 155418 $
41   */
42  public class TestCookiePolicy extends TestCookieBase {
43  
44      // ------------------------------------------------------------ Constructor
45  
46      public TestCookiePolicy(String name) {
47          super(name);
48      }
49  
50      // ------------------------------------------------------- TestCase Methods
51  
52      public static Test suite() {
53          return new TestSuite(TestCookiePolicy.class);
54      }
55  
56      public void testRegisterNullPolicyId() {
57          try {
58              CookiePolicy.registerCookieSpec(null, null);
59              fail("IllegalArgumentException must have been thrown");
60          } catch (IllegalArgumentException expected) {
61          }
62      }
63  
64      public void testRegisterNullPolicy() {
65          try {
66              CookiePolicy.registerCookieSpec("whatever", null);
67              fail("IllegalArgumentException must have been thrown");
68          } catch (IllegalArgumentException expected) {
69          }
70      }
71  
72      public void testUnregisterNullPolicy() {
73          try {
74              CookiePolicy.unregisterCookieSpec(null);
75              fail("IllegalArgumentException must have been thrown");
76          } catch (IllegalArgumentException expected) {
77          }
78      }
79  
80      public void testGetPolicyNullId() {
81          try {
82              CookiePolicy.getCookieSpec(null);
83              fail("IllegalArgumentException must have been thrown");
84          } catch (IllegalArgumentException expected) {
85          }
86      }
87  
88      public void testRegisterUnregister() {
89          CookiePolicy.registerCookieSpec("whatever", CookieSpecBase.class);
90          CookiePolicy.unregisterCookieSpec("whatever");
91          try {
92              CookiePolicy.getCookieSpec("whatever");
93              fail("IllegalStateException must have been thrown");
94          } catch (IllegalStateException expected) {
95          }
96      }
97  
98      public void testGetDefaultPolicy() {
99          assertNotNull(CookiePolicy.getDefaultSpec());
100     }
101 }
102