KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servletunit > struts > tests > TestClearParameters


1 package servletunit.struts.tests;
2
3 import servletunit.struts.MockStrutsTestCase;
4
5 /**
6  * Created by IntelliJ IDEA.
7  * User: deryl
8  * Date: Apr 12, 2003
9  * Time: 8:53:11 PM
10  * To change this template use Options | File Templates.
11  */

12 public class TestClearParameters extends MockStrutsTestCase {
13
14     public TestClearParameters(String JavaDoc testName) {
15         super(testName);
16     }
17
18     /**
19      * Sets up the test fixture for this test. This method creates
20      * an instance of the ActionServlet, initializes it to validate
21      * forms and turn off debugging, and creates a mock HttpServletRequest
22      * and HttpServletResponse object to use in this test.
23      */

24     protected void setUp() throws Exception JavaDoc {
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 JavaDoc 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