1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
45
46 public TestCookiePolicy(String name) {
47 super(name);
48 }
49
50
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