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.cactus;
17:
18: import servletunit.struts.*;
19:
20: /**
21: * <p>Title: NullPointerActionTest</p>
22: * <p>Description: Tests to confirm a NullPointerException
23: * thrown from a misbehaving action reaches the test.</p>
24: * <p>Copyright: Copyright (c) 2003</p>
25: * @author Sean Pritchard
26: * @version 1.0
27: */
28: public class TestNullPointerAction extends CactusStrutsTestCase {
29:
30: public TestNullPointerAction() {
31: }
32:
33: public void setUp() throws Exception {
34: super .setUp();
35: }
36:
37: public void testNullPointer() throws Exception {
38: try {
39: this .setRequestPathInfo("test", "/testNullPointer");
40: this .actionPerform();
41: fail("Exception expected");
42: } catch (ExceptionDuringTestError e) {
43: //uncomment this to see a sample stack trace
44: //that users will see if their action throws an exception
45: // throw e;
46: }
47: }
48:
49: public void testNullPointerFromForm() throws Exception {
50: try {
51: this .setRequestPathInfo("test", "/testNullPointerForm");
52: this .actionPerform();
53: fail("Exception expected");
54: } catch (ExceptionDuringTestError e) {
55: //uncomment this to see a sample stack trace
56: //that users will see if their action throws an exception
57: // throw e;
58: }
59: }
60:
61: public static void main(String[] args) {
62: junit.textui.TestRunner.run(TestNullPointerAction.class);
63: }
64:
65: }
|