KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > httpd > CookieWrapperTest


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
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 JavaDoc;
28 import java.util.Date JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.text.SimpleDateFormat JavaDoc;
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 JavaDoc testName) {
42         super(testName);
43     }
44
45     protected void setUp() throws Exception JavaDoc {
46     }
47
48     protected void tearDown() throws Exception JavaDoc {
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 JavaDoc {
61         System.out.println("testCookieGenerate");
62         
63         CookieWrapper instance = new CookieWrapper("test","value");
64         java.util.Date JavaDoc testDate = new java.util.Date JavaDoc();
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         
78         System.out.println(instance.getSetCookieString());
79         instance.setPath(null);
80         System.out.println(instance.getSetCookieString());
81     }
82 }
83
Popular Tags