1 20 package org.apache.cactus.internal.util; 21 22 import java.net.URL ; 23 24 import org.apache.cactus.Cookie; 25 import org.apache.cactus.WebRequest; 26 import org.apache.cactus.internal.WebRequestImpl; 27 import org.apache.commons.httpclient.HttpState; 28 29 import junit.framework.TestCase; 30 31 36 public class TestCookieUtil extends TestCase 37 { 38 44 public void testCreateHttpStateWhenNoCactusCookieDefined() 45 throws Exception 46 { 47 WebRequest request = new WebRequestImpl(); 48 HttpState state = new HttpState(); 49 state.addCookies(CookieUtil.createHttpClientCookies(request, 50 new URL ("http://jakarta.apache.org"))); 51 assertEquals(0, state.getCookies().length); 52 } 53 54 60 public void testCreateHttpStateWhenSeveralCactusCookieExist() 61 throws Exception 62 { 63 WebRequest request = new WebRequestImpl(); 64 request.addCookie(new Cookie("domain1", "name1", "value1")); 65 request.addCookie(new Cookie("domain2", "name2", "value2")); 66 67 HttpState state = new HttpState(); 68 state.addCookies(CookieUtil.createHttpClientCookies(request, 69 new URL ("http://jakarta.apache.org"))); 70 71 assertEquals(2, state.getCookies().length); 72 } 73 74 } 75 | Popular Tags |