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
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$
42 */
43 public class TestCookiePolicy extends TestCookieBase {
44
45
46
47 public TestCookiePolicy(String name) {
48 super(name);
49 }
50
51
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 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 expected) {
70 }
71 }
72
73 public void testUnregisterNullPolicy() {
74 try {
75 CookiePolicy.unregisterCookieSpec(null);
76 fail("IllegalArgumentException must have been thrown");
77 } catch (IllegalArgumentException expected) {
78 }
79 }
80
81 public void testGetPolicyNullId() {
82 try {
83 CookiePolicy.getCookieSpec(null);
84 fail("IllegalArgumentException must have been thrown");
85 } catch (IllegalArgumentException 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 expected) {
96 }
97 }
98
99 public void testGetDefaultPolicy() {
100 assertNotNull(CookiePolicy.getDefaultSpec());
101 }
102 }
103