KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > cookie > TestCookiePolicy


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: 480424 $
4  * $Date: 2006-11-29 05:56:49 +0000 (Wed, 29 Nov 2006) $
5  * ====================================================================
6  *
7  * Licensed to the Apache Software Foundation (ASF) under one or more
8  * contributor license agreements. See the NOTICE file distributed with
9  * this work for additional information regarding copyright ownership.
10  * The ASF licenses this file to You under the Apache License, Version 2.0
11  * (the "License"); you may not use this file except in compliance with
12  * the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ====================================================================
22  *
23  * This software consists of voluntary contributions made by many
24  * individuals on behalf of the Apache Software Foundation. For more
25  * information on the Apache Software Foundation, please see
26  * <http://www.apache.org/>.
27  *
28  */

29
30 package org.apache.commons.httpclient.cookie;
31
32 import junit.framework.Test;
33 import junit.framework.TestSuite;
34
35
36 /**
37  * Test cases for Cookie Policy
38  *
39  * @author <a HREF="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
40  *
41  * @version $Revision: 480424 $
42  */

43 public class TestCookiePolicy extends TestCookieBase {
44
45     // ------------------------------------------------------------ Constructor
46

47     public TestCookiePolicy(String JavaDoc name) {
48         super(name);
49     }
50
51     // ------------------------------------------------------- TestCase Methods
52

53     public static Test suite() {
54         return new TestSuite(TestCookiePolicy.class);
55     }
56
57     public void testRegisterNullPolicyId() {
58         try {
59             CookiePolicy.registerCookieSpec(null, null);
60             fail("IllegalArgumentException must have been thrown");
61         } catch (IllegalArgumentException JavaDoc expected) {
62         }
63     }
64
65     public void testRegisterNullPolicy() {
66         try {
67             CookiePolicy.registerCookieSpec("whatever", null);
68             fail("IllegalArgumentException must have been thrown");
69         } catch (IllegalArgumentException JavaDoc expected) {
70         }
71     }
72
73     public void testUnregisterNullPolicy() {
74         try {
75             CookiePolicy.unregisterCookieSpec(null);
76             fail("IllegalArgumentException must have been thrown");
77         } catch (IllegalArgumentException JavaDoc expected) {
78         }
79     }
80
81     public void testGetPolicyNullId() {
82         try {
83             CookiePolicy.getCookieSpec(null);
84             fail("IllegalArgumentException must have been thrown");
85         } catch (IllegalArgumentException JavaDoc expected) {
86         }
87     }
88
89     public void testRegisterUnregister() {
90         CookiePolicy.registerCookieSpec("whatever", CookieSpecBase.class);
91         CookiePolicy.unregisterCookieSpec("whatever");
92         try {
93             CookiePolicy.getCookieSpec("whatever");
94             fail("IllegalStateException must have been thrown");
95         } catch (IllegalStateException JavaDoc expected) {
96         }
97     }
98
99     public void testGetDefaultPolicy() {
100         assertNotNull(CookiePolicy.getDefaultSpec());
101     }
102 }
103
104
Popular Tags