KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > jwebunit > TestContextTest


1 /*
2  * User: DJoiner
3  * Date: Aug 16, 2002
4  * Time: 8:41:00 AM
5  */

6 package net.sourceforge.jwebunit;
7
8 import junit.framework.TestCase;
9
10 import javax.servlet.http.Cookie JavaDoc;
11 import java.util.List JavaDoc;
12 import java.util.Locale JavaDoc;
13
14 public class TestContextTest extends TestCase {
15     private TestContext context;
16
17     public TestContextTest(String JavaDoc s) {
18         super(s);
19     }
20
21     protected void setUp() throws Exception JavaDoc {
22         context = new TestContext();
23         context.setAuthorization("user", "pwd");
24         context.addCookie("key", "val");
25         context.setLocale(Locale.CANADA_FRENCH);
26     }
27
28
29     public void testInit() {
30         assertTrue(context.hasAuthorization());
31         assertTrue(context.hasCookies());
32         assertEquals(context.getUser(), "user");
33         assertEquals(context.getPassword(), "pwd");
34         List JavaDoc cookies = context.getCookies();
35         Cookie JavaDoc c = (Cookie JavaDoc)cookies.get(0);
36         assertEquals(c.getName(), "key");
37         assertEquals(c.getValue(), "val");
38         assertEquals(Locale.CANADA_FRENCH, context.getLocale());
39         assertEquals("http://localhost:8080", context.getBaseUrl());
40         assertNull(context.getResourceBundleName());
41     }
42
43     public void testResourceBundle() {
44         String JavaDoc name = "net.sourceforge.jwebunit.TestContextBundle";
45         context.setResourceBundleName("net.sourceforge.jwebunit.TestContextBundle");
46         assertEquals(name, context.getResourceBundleName());
47     }
48
49     public void testBaseUrl() {
50
51     }
52
53 }
54
Popular Tags