1 20 package org.apache.cactus.sample.servlet.unit; 21 22 import org.apache.cactus.ServletTestCase; 23 import org.apache.cactus.WebRequest; 24 25 30 public class TestCookie extends ServletTestCase 31 { 32 38 public void beginCookieEncoding(WebRequest theRequest) 39 { 40 theRequest.addCookie("testcookie", "user&pwd"); 43 } 44 45 48 public void testCookieEncoding() 49 { 50 javax.servlet.http.Cookie [] cookies = request.getCookies(); 51 52 assertNotNull("No cookies in request", cookies); 53 54 for (int i = 0; i < cookies.length; i++) 55 { 56 if (cookies[i].getName().equals("testcookie")) 57 { 58 assertEquals("user&pwd", cookies[i].getValue()); 59 return; 60 } 61 } 62 63 fail("No cookie named 'testcookie' found"); 64 } 65 66 } 67 | Popular Tags |