KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servletunit > struts > tests > cactus > TestNullPointerAction


1 // StrutsTestCase - a JUnit extension for testing Struts actions
2
// within the context of the ActionServlet.
3
// Copyright (C) 2002 Deryl Seale
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the Apache Software License as
7
// published by the Apache Software Foundation; either version 1.1
8
// of the License, or (at your option) any later version.
9
//
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 JavaDoc {
34         super.setUp();
35     }
36
37     public void testNullPointer() throws Exception JavaDoc{
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 JavaDoc{
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
62     public static void main(String JavaDoc[] args) {
63         junit.textui.TestRunner.run(TestNullPointerAction.class);
64     }
65
66 }
Popular Tags