01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * CookieWrapperTest.java
20: *
21: * JUnit based test
22: */
23:
24: package com.rift.coad.lib.httpd;
25:
26: import junit.framework.*;
27: import java.net.InetAddress;
28: import java.util.Date;
29: import java.util.Map;
30: import java.util.HashMap;
31: import java.text.SimpleDateFormat;
32: import com.rift.coad.lib.configuration.Configuration;
33: import com.rift.coad.lib.configuration.ConfigurationFactory;
34:
35: /**
36: *
37: * @author mincemeat
38: */
39: public class CookieWrapperTest extends TestCase {
40:
41: public CookieWrapperTest(String testName) {
42: super (testName);
43: }
44:
45: protected void setUp() throws Exception {
46: }
47:
48: protected void tearDown() throws Exception {
49: }
50:
51: public static Test suite() {
52: TestSuite suite = new TestSuite(CookieWrapperTest.class);
53:
54: return suite;
55: }
56:
57: /**
58: * Test creation of a cookie class com.rift.coad.lib.httpd.CookieWrapper.
59: */
60: public void testCookieGenerate() throws Exception {
61: System.out.println("testCookieGenerate");
62:
63: CookieWrapper instance = new CookieWrapper("test", "value");
64: java.util.Date testDate = new java.util.Date();
65: instance.setDomain("test.com");
66: instance.setPath("/test");
67: if (!instance.getName().equals("test")) {
68: fail("Name set incorrectly");
69: } else if (!instance.getValue().equals("value")) {
70: fail("Value set incorrectly");
71: } else if (!instance.getDomain().equals("test.com")) {
72: fail("Domain name set incorrectly");
73: } else if (!instance.getPath().equals("/test")) {
74: fail("The path has not been set correctly");
75: }
76:
77: System.out.println(instance.getSetCookieString());
78: instance.setPath(null);
79: System.out.println(instance.getSetCookieString());
80: }
81: }
|