01: package servletunit.struts.tests;
02:
03: import servletunit.struts.MockStrutsTestCase;
04:
05: /**
06: * Created by IntelliJ IDEA.
07: * User: deryl
08: * Date: Apr 12, 2003
09: * 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 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 {
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: }
|