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;
18:
19: import servletunit.struts.MockStrutsTestCase;
20: import junit.framework.AssertionFailedError;
21:
22: public class TestTilesForward extends MockStrutsTestCase {
23:
24: public TestTilesForward(String testName) {
25: super (testName);
26: }
27:
28: public void setUp() throws Exception {
29: super .setUp();
30: setConfigFile("tiles", "/WEB-INF/struts-config-tiles.xml");
31: setServletConfigFile("/WEB-INF/web.xml");
32: setConfigFile("/WEB-INF/struts-config.xml");
33: }
34:
35: public void testTilesForward() {
36: addRequestParameter("username", "deryl");
37: addRequestParameter("password", "radar");
38: setRequestPathInfo("tiles", "/tilesForward.do");
39: actionPerform();
40: verifyForward("success");
41: verifyForwardPath("/layouts/pageLayout.jsp");
42: verifyTilesForward("success", "page.library");
43: }
44:
45: public void testTilesInputForward() {
46: setRequestPathInfo("tiles", "/tilesInputForward.do");
47: actionPerform();
48: verifyInputForward();
49: verifyInputTilesForward("page.library");
50: }
51:
52: public void testTileForwardFail() {
53: addRequestParameter("username", "deryl");
54: addRequestParameter("password", "radar");
55: setRequestPathInfo("tiles", "/tilesForward.do");
56: actionPerform();
57: verifyForward("success");
58: verifyForwardPath("/layouts/pageLayout.jsp");
59: try {
60: verifyTilesForward("success", "foo.fail");
61: } catch (AssertionFailedError afe) {
62: return;
63: }
64: fail("Should have failed.");
65: }
66:
67: // todo: this test is failing because tiles verify doesn't work properly
68: // public void testTileForwardFailDefinitionExists() {
69: // addRequestParameter("username","deryl");
70: // addRequestParameter("password","radar");
71: // setRequestPathInfo("tiles","/tilesForward.do");
72: // actionPerform();
73: // verifyForward("success");
74: // verifyForwardPath("/layouts/pageLayout.jsp");
75: // try {
76: // verifyTilesForward("failure","another.page");
77: // } catch (AssertionFailedError afe) {
78: // return;
79: // }
80: // fail("Should have failed.");
81: // }
82:
83: }
|