KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > examples > SimpleWebTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.junit.examples;
8
9
10 import java.io.IOException JavaDoc;
11 import javax.servlet.RequestDispatcher JavaDoc;
12 import javax.servlet.ServletException JavaDoc;
13 import javax.servlet.http.HttpServletRequestWrapper JavaDoc;
14
15 import com.inversoft.junit.Request;
16 import com.inversoft.junit.Response;
17 import com.inversoft.junit.WebTestCase;
18
19
20 /**
21  * A simple test
22  */

23 public class SimpleWebTest extends WebTestCase {
24
25     private static int count = 0;
26
27
28     /**
29      * The constructor
30      */

31     public SimpleWebTest(String JavaDoc name) {
32         super(name);
33     }
34
35
36     /**
37      * A simple test for now
38      */

39     public void beginFoo(Request request) {
40         System.err.println("Inside begin foo: " + count);
41         count++;
42     }
43     public void testFoo() {
44         System.err.println("Inside test foo");
45     }
46     public void endFoo(Response response) {
47         System.err.println("Inside end foo");
48     }
49
50     /**
51      * A simple test for JSPs.
52      */

53     public void beginJSP(Request request) {
54         System.err.println("Inside begin JSP");
55     }
56     public void testJSP() throws IOException JavaDoc, ServletException JavaDoc {
57         System.err.println("Inside test JSP");
58         RequestDispatcher JavaDoc rd = request.getRequestDispatcher("/test.jsp");
59         rd.forward(request, response);
60     }
61     public void endJSP(Response response) {
62         System.err.println("Inside end JSP");
63     }
64
65     /**
66      * A failure test case
67      *
68      */

69     public void beginFailure(Request request) {
70         System.err.println("Inside begin failure");
71     }
72     public void testFailure() {
73         System.err.println("Inside test failure");
74         assertTrue("Failure", false);
75     }
76     public void endFailure(Response response) {
77         System.err.println("Inside end failure");
78     }
79 }
Popular Tags