1 package servletunit.struts.tests; 2 3 import servletunit.struts.MockStrutsTestCase; 4 5 12 public class TestClearParameters extends MockStrutsTestCase { 13 14 public TestClearParameters(String testName) { 15 super(testName); 16 } 17 18 24 protected void setUp() throws Exception { 25 super.setUp(); 26 setServletConfigFile("/WEB-INF/web.xml"); 27 } 28 29 public void testClearParameters() { 30 addRequestParameter("foo","bar"); 31 addRequestParameter("hi", "there"); 32 assertEquals("bar",getRequest().getParameter("foo")); 33 assertEquals("there",getRequest().getParameter("hi")); 34 clearRequestParameters(); 35 assertNull(getRequest().getParameter("foo")); 36 assertNull(getRequest().getParameter("hi")); 37 } 38 39 public void testClearsRedirectHeaderWhenRequested() { 40 setRequestPathInfo("test","/testRedirect"); 41 actionPerform(); 42 String forward = getActualForward(); 43 assertEquals("/test/main/success.jsp",forward); 44 clearRequestParameters(); 45 addRequestParameter("username","deryl"); 46 addRequestParameter("password","express"); 47 setRequestPathInfo("/login"); 48 actionPerform(); 49 verifyForward("login"); 50 } 51 } 52 | Popular Tags |