01: // StrutsTestCase - a JUnit extension for testing Struts actions
02: // within the context of the ActionServlet.
03: // Copyright (C) 2002 Deryl Seale
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the Apache Software License as
07: // published by the Apache Software Foundation; either version 1.1
08: // of the License, or (at your option) any later version.
09: //
10: // This library is distributed in the hope that it will be useful,
11: // but WITHOUT ANY WARRANTY; without even the implied warranty of
12: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: // Apache Software Foundation Licens for more details.
14: //
15: // You may view the full text here: http://www.apache.org/LICENSE.txt
16:
17: package servletunit.struts.tests.cactus;
18:
19: import servletunit.struts.CactusStrutsTestCase;
20: import junit.framework.AssertionFailedError;
21:
22: public class TestTilesForward extends CactusStrutsTestCase {
23:
24: public TestTilesForward(String testName) {
25: super (testName);
26: }
27:
28: public void setUp() throws Exception {
29: super .setUp();
30: }
31:
32: public void testTilesForward() {
33: addRequestParameter("username", "deryl");
34: addRequestParameter("password", "radar");
35: setRequestPathInfo("tiles", "/tilesForward");
36: actionPerform();
37: verifyForward("success");
38: verifyForwardPath("/layouts/pageLayout.jsp");
39: verifyTilesForward("success", "page.library");
40: }
41:
42: public void testTilesInputForward() {
43: setRequestPathInfo("tiles", "/tilesInputForward.do");
44: actionPerform();
45: verifyInputForward();
46: }
47:
48: public void testTileForwardFail() {
49: addRequestParameter("username", "deryl");
50: addRequestParameter("password", "radar");
51: setRequestPathInfo("tiles", "/tilesForward.do");
52: actionPerform();
53: verifyForward("success");
54: verifyForwardPath("/layouts/pageLayout.jsp");
55: try {
56: verifyTilesForward("success", "foo.fail");
57: } catch (AssertionFailedError afe) {
58: return;
59: }
60: fail("Should have failed.");
61: }
62:
63: // public void testTileForwardFailDefinitionExists() {
64: // addRequestParameter("username","deryl");
65: // addRequestParameter("password","radar");
66: // setRequestPathInfo("tiles","/tilesForward.do");
67: // actionPerform();
68: // verifyForward("success");
69: // verifyForwardPath("/layouts/pageLayout.jsp");
70: // try {
71: // verifyTilesForward("failure","another.page");
72: // } catch (AssertionFailedError afe) {
73: // return;
74: // }
75: // fail("Should have failed.");
76: // }
77:
78: }
|