KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > servlet > http > MockHttpServletRequest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package javax.servlet.http;
5
6 import com.tc.exception.ImplementMe;
7
8 import java.io.BufferedReader JavaDoc;
9 import java.security.Principal JavaDoc;
10 import java.util.Enumeration JavaDoc;
11 import java.util.Locale JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import javax.servlet.RequestDispatcher JavaDoc;
15 import javax.servlet.ServletInputStream JavaDoc;
16
17 public class MockHttpServletRequest implements HttpServletRequest JavaDoc {
18
19   private final String JavaDoc contextPath;
20   private String JavaDoc requestUrl;
21   private HttpSession JavaDoc session;
22   private String JavaDoc requestedSessionId;
23   private boolean sidFromCookie;
24   private boolean sidValid;
25   private String JavaDoc scheme;
26   private String JavaDoc serverName;
27   private int serverPort;
28
29   public MockHttpServletRequest() {
30     this.contextPath = "/";
31   }
32
33   public MockHttpServletRequest(String JavaDoc contextPath, String JavaDoc requestedSessionId) {
34     this.contextPath = contextPath;
35     this.requestedSessionId = requestedSessionId;
36   }
37
38   public void setSession(HttpSession JavaDoc session) {
39     this.session = session;
40   }
41
42   public void setRequestedSessionId(String JavaDoc requestedSessionId) {
43     this.requestedSessionId = requestedSessionId;
44   }
45
46   public void setRequestUrl(String JavaDoc requestUrl) {
47     this.requestUrl = requestUrl;
48   }
49
50   public void setSidFromCookie(boolean sidFromCookie) {
51     this.sidFromCookie = sidFromCookie;
52   }
53
54   public void setSidValid(boolean sidValid) {
55     this.sidValid = sidValid;
56   }
57
58   public void setScheme(String JavaDoc scheme) {
59     this.scheme = scheme;
60   }
61
62   public void setServerName(String JavaDoc serverName) {
63     this.serverName = serverName;
64   }
65
66   public void setServerPort(int serverPort) {
67     this.serverPort = serverPort;
68   }
69
70   public String JavaDoc getAuthType() {
71     throw new ImplementMe();
72   }
73
74   public String JavaDoc getContextPath() {
75     return contextPath;
76   }
77
78   public Cookie JavaDoc[] getCookies() {
79     throw new ImplementMe();
80   }
81
82   public long getDateHeader(String JavaDoc arg0) {
83     throw new ImplementMe();
84   }
85
86   public String JavaDoc getHeader(String JavaDoc arg0) {
87     throw new ImplementMe();
88   }
89
90   public Enumeration JavaDoc getHeaderNames() {
91     throw new ImplementMe();
92   }
93
94   public Enumeration JavaDoc getHeaders(String JavaDoc arg0) {
95     throw new ImplementMe();
96   }
97
98   public int getIntHeader(String JavaDoc arg0) {
99     throw new ImplementMe();
100   }
101
102   public String JavaDoc getMethod() {
103     throw new ImplementMe();
104   }
105
106   public String JavaDoc getPathInfo() {
107     throw new ImplementMe();
108   }
109
110   public String JavaDoc getPathTranslated() {
111     throw new ImplementMe();
112   }
113
114   public String JavaDoc getQueryString() {
115     throw new ImplementMe();
116   }
117
118   public String JavaDoc getRemoteUser() {
119     throw new ImplementMe();
120   }
121
122   public String JavaDoc getRequestURI() {
123     throw new ImplementMe();
124   }
125
126   public StringBuffer JavaDoc getRequestURL() {
127     return new StringBuffer JavaDoc(requestUrl);
128   }
129
130   public String JavaDoc getRequestedSessionId() {
131     throw new ImplementMe();
132   }
133
134   public String JavaDoc getServletPath() {
135     throw new ImplementMe();
136   }
137
138   public HttpSession JavaDoc getSession() {
139     return getSession(true);
140   }
141
142   public HttpSession JavaDoc getSession(boolean create) {
143     if (!create && requestedSessionId == null) return session;
144     if (session == null) session = new MockHttpSession JavaDoc(requestedSessionId);
145     return session;
146   }
147
148   public Principal JavaDoc getUserPrincipal() {
149     throw new ImplementMe();
150   }
151
152   public boolean isRequestedSessionIdFromCookie() {
153     return sidFromCookie;
154   }
155
156   public boolean isRequestedSessionIdFromURL() {
157     return !sidFromCookie;
158   }
159
160   public boolean isRequestedSessionIdFromUrl() {
161     return isRequestedSessionIdFromURL();
162   }
163
164   public boolean isRequestedSessionIdValid() {
165     return sidValid;
166   }
167
168   public boolean isUserInRole(String JavaDoc arg0) {
169     throw new ImplementMe();
170   }
171
172   public Object JavaDoc getAttribute(String JavaDoc arg0) {
173     throw new ImplementMe();
174   }
175
176   public Enumeration JavaDoc getAttributeNames() {
177     throw new ImplementMe();
178   }
179
180   public String JavaDoc getCharacterEncoding() {
181     throw new ImplementMe();
182   }
183
184   public int getContentLength() {
185     throw new ImplementMe();
186   }
187
188   public String JavaDoc getContentType() {
189     throw new ImplementMe();
190   }
191
192   public ServletInputStream JavaDoc getInputStream() {
193     throw new ImplementMe();
194   }
195
196   public String JavaDoc getLocalAddr() {
197     throw new ImplementMe();
198   }
199
200   public String JavaDoc getLocalName() {
201     throw new ImplementMe();
202   }
203
204   public int getLocalPort() {
205     throw new ImplementMe();
206   }
207
208   public Locale JavaDoc getLocale() {
209     throw new ImplementMe();
210   }
211
212   public Enumeration JavaDoc getLocales() {
213     throw new ImplementMe();
214   }
215
216   public String JavaDoc getParameter(String JavaDoc arg0) {
217     throw new ImplementMe();
218   }
219
220   public Map JavaDoc getParameterMap() {
221     throw new ImplementMe();
222   }
223
224   public Enumeration JavaDoc getParameterNames() {
225     throw new ImplementMe();
226   }
227
228   public String JavaDoc[] getParameterValues(String JavaDoc arg0) {
229     throw new ImplementMe();
230   }
231
232   public String JavaDoc getProtocol() {
233     throw new ImplementMe();
234   }
235
236   public BufferedReader JavaDoc getReader() {
237     throw new ImplementMe();
238   }
239
240   public String JavaDoc getRealPath(String JavaDoc arg0) {
241     throw new ImplementMe();
242   }
243
244   public String JavaDoc getRemoteAddr() {
245     throw new ImplementMe();
246   }
247
248   public String JavaDoc getRemoteHost() {
249     throw new ImplementMe();
250   }
251
252   public int getRemotePort() {
253     throw new ImplementMe();
254   }
255
256   public RequestDispatcher JavaDoc getRequestDispatcher(String JavaDoc arg0) {
257     throw new ImplementMe();
258   }
259
260   public String JavaDoc getScheme() {
261     return scheme;
262   }
263
264   public String JavaDoc getServerName() {
265     return serverName;
266   }
267
268   public int getServerPort() {
269     return serverPort;
270   }
271
272   public boolean isSecure() {
273     throw new ImplementMe();
274   }
275
276   public void removeAttribute(String JavaDoc arg0) {
277     throw new ImplementMe();
278
279   }
280
281   public void setAttribute(String JavaDoc arg0, Object JavaDoc arg1) {
282     throw new ImplementMe();
283
284   }
285
286   public void setCharacterEncoding(String JavaDoc arg0) {
287     throw new ImplementMe();
288
289   }
290
291 }
292
Popular Tags