blob: 9fd444142bc25f791c55d79755d04386fe74830a (
plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package org.simpleframework.http;
import junit.framework.TestCase;
public class CookieTest extends TestCase {
public void testCookies() throws Exception {
Cookie cookie = new Cookie("JSESSIONID", "XXX");
cookie.setExpiry(10);
cookie.setPath("/path");
System.err.println(cookie);
assertTrue(cookie.toString().contains("max-age=10"));
assertTrue(cookie.toString().matches(".*expires=\\w\\w\\w, \\d\\d-\\w\\w\\w-\\d\\d\\d\\d \\d\\d:\\d\\d:\\d\\d GMT;.*"));
}
public void testCookieWithoutExpiry() throws Exception {
Cookie cookie = new Cookie("JSESSIONID", "XXX");
cookie.setPath("/path");
System.err.println(cookie);
assertFalse(cookie.toString().contains("max-age=10"));
assertFalse(cookie.toString().matches(".*expires=\\w\\w\\w, \\d\\d \\w\\w\\w \\d\\d\\d\\d \\d\\d:\\d\\d:\\d\\d GMT;.*"));
}
public void testSecureCookies() throws Exception {
Cookie cookie = new Cookie("JSESSIONID", "XXX");
cookie.setExpiry(10);
cookie.setPath("/path");
cookie.setSecure(true);
System.err.println(cookie);
assertTrue(cookie.toString().contains("max-age=10"));
assertTrue(cookie.toString().matches(".*expires=\\w\\w\\w, \\d\\d-\\w\\w\\w-\\d\\d\\d\\d \\d\\d:\\d\\d:\\d\\d GMT;.*"));
cookie.setExpiry(10);
cookie.setPath("/path");
cookie.setSecure(false);
cookie.setProtected(true);
System.err.println(cookie);
assertTrue(cookie.toString().contains("max-age=10"));
assertTrue(cookie.toString().matches(".*expires=\\w\\w\\w, \\d\\d-\\w\\w\\w-\\d\\d\\d\\d \\d\\d:\\d\\d:\\d\\d GMT;.*"));
cookie.setExpiry(10);
cookie.setPath("/path");
cookie.setSecure(true);
cookie.setProtected(true);
System.err.println(cookie);
assertTrue(cookie.toString().contains("max-age=10"));
assertTrue(cookie.toString().matches(".*expires=\\w\\w\\w, \\d\\d-\\w\\w\\w-\\d\\d\\d\\d \\d\\d:\\d\\d:\\d\\d GMT;.*"));
}
}
|