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 package org.apache.http.cookie;
29
30 import org.junit.Assert;
31 import org.junit.Test;
32
33
34
35
36 public class TestCookieOrigin {
37
38 @Test
39 public void testConstructor() {
40 final CookieOrigin origin = new CookieOrigin("www.apache.org", 80, "/", false);
41 Assert.assertEquals("www.apache.org", origin.getHost());
42 Assert.assertEquals(80, origin.getPort());
43 Assert.assertEquals("/", origin.getPath());
44 Assert.assertFalse(origin.isSecure());
45 }
46
47 @SuppressWarnings("unused")
48 @Test(expected=IllegalArgumentException.class)
49 public void testNullHost() {
50 new CookieOrigin(null, 80, "/", false);
51 }
52
53 @SuppressWarnings("unused")
54 @Test(expected=IllegalArgumentException.class)
55 public void testEmptyHost() {
56 new CookieOrigin(" ", 80, "/", false);
57 }
58
59 @SuppressWarnings("unused")
60 @Test(expected=IllegalArgumentException.class)
61 public void testNegativePort() {
62 new CookieOrigin("www.apache.org", -80, "/", false);
63 }
64
65 @SuppressWarnings("unused")
66 @Test(expected=IllegalArgumentException.class)
67 public void testNullPath() {
68 new CookieOrigin("www.apache.org", 80, null, false);
69 }
70
71 @Test
72 public void testEmptyPath() {
73 final CookieOrigin origin = new CookieOrigin("www.apache.org", 80, "", false);
74 Assert.assertEquals("www.apache.org", origin.getHost());
75 Assert.assertEquals(80, origin.getPort());
76 Assert.assertEquals("/", origin.getPath());
77 Assert.assertFalse(origin.isSecure());
78 }
79
80 }
81