KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > http > MockRequestDispatcher


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.internal.http;
8
9
10 import javax.servlet.RequestDispatcher JavaDoc;
11 import javax.servlet.ServletRequest JavaDoc;
12 import javax.servlet.ServletResponse JavaDoc;
13
14
15 /**
16  * This class is a Mock request dispatcher
17  *
18  * @author Brian Pontarelli
19  * @since 2.0
20  * @version 2.0
21  */

22 public class MockRequestDispatcher implements RequestDispatcher JavaDoc {
23
24     private String JavaDoc url;
25     private boolean forward;
26     private boolean include;
27
28
29     /**
30      * Constructs a new Mock request dispatcher
31      */

32     public MockRequestDispatcher(String JavaDoc url) {
33         this.url = url;
34     }
35
36
37     /**
38      */

39     public void forward(ServletRequest JavaDoc request, ServletResponse JavaDoc response) {
40         forward = true;
41         include = false;
42     }
43
44     /**
45      */

46     public void include(ServletRequest JavaDoc request, ServletResponse JavaDoc response) {
47         forward = false;
48         include = true;
49     }
50
51
52     //-------------------------------------------------------------------------
53
// Helper methods
54
//-------------------------------------------------------------------------
55

56
57     /**
58      * Returns whether or not this request dispatcher has been forwarded
59      */

60     public boolean isForwarded() {
61         return forward;
62     }
63
64     /**
65      * Returns whether or not this request dispatcher has been included
66      */

67     public boolean isIncluded() {
68         return include;
69     }
70
71     /**
72      * Returns the url that was dispatched
73      */

74     public String JavaDoc getURL() {
75         return url;
76     }
77
78     /**
79      * Clears out the old URL
80      */

81     public void clearURL() {
82         url = null;
83     }
84 }
Popular Tags