1 6 package net.sourceforge.jwebunit; 7 8 import junit.framework.TestCase; 9 10 import javax.servlet.http.Cookie ; 11 import java.util.List ; 12 import java.util.Locale ; 13 14 public class TestContextTest extends TestCase { 15 private TestContext context; 16 17 public TestContextTest(String s) { 18 super(s); 19 } 20 21 protected void setUp() throws Exception { 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 cookies = context.getCookies(); 35 Cookie c = (Cookie )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 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 |