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: package servletunit.struts.tests;
17:
18: import servletunit.struts.MockStrutsTestCase;
19: import java.io.File;
20:
21: /**
22: *
23: * <p>Title: TestNoRequestPathInfo</p>
24: * <p>Description: Confirms correct behavior if
25: * actionPerfoem() is called prior to calling
26: * setRequestPathInfo().</p>
27: * <p>Copyright: Copyright (c) 2003</p>
28: * @author Sean Pritchard
29: * @version 1.0
30: */
31: public class TestNoRequestPathInfo extends MockStrutsTestCase {
32:
33: public TestNoRequestPathInfo() {
34: }
35:
36: public void setUp() throws Exception {
37: super .setUp();
38: this .setContextDirectory(new File(System.getProperty("basedir")
39: + "/src/examples"));
40: setConfigFile("/WEB-INF/struts-config-test.xml");
41: }
42:
43: /**
44: * this test assumes that web.xml and struts-config.xml
45: * can be found. If these files are found,
46: * but no request path is set prior to calling
47: * actionPerform(), we expect an IllegalStateException
48: */
49: public void testNoRequestPathInfo() {
50: try {
51: actionPerform();
52: fail("IllegalStateException expected");
53: } catch (IllegalStateException e) {
54: //expected
55: }
56: }
57: }
|