KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > context > servlet > ServletRequestMockImpl


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.context.servlet;
17
18 import org.apache.myfaces.util.IteratorEnumeration;
19
20 import javax.servlet.RequestDispatcher JavaDoc;
21 import javax.servlet.ServletInputStream JavaDoc;
22 import javax.servlet.http.Cookie JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpSession JavaDoc;
25 import java.io.BufferedReader JavaDoc;
26 import java.io.IOException JavaDoc;
27 import java.io.UnsupportedEncodingException JavaDoc;
28 import java.security.Principal JavaDoc;
29 import java.util.*;
30
31 /**
32  * DOCUMENT ME!
33  * @author Manfred Geiler (latest modification by $Author: matze $)
34  * @version $Revision: 1.4 $ $Date: 2004/10/13 11:50:59 $
35  */

36 public class ServletRequestMockImpl
37     implements HttpServletRequest JavaDoc
38 {
39
40     private static final Locale[] LOCALES = {Locale.US, Locale.GERMAN};
41
42     private Map _attributes = new HashMap();
43     private Cookie JavaDoc[] _cookies;
44     private String JavaDoc _servletPath = "/myfaces";
45     private String JavaDoc _pathInfo = "";
46     
47     private HttpSession JavaDoc _session;
48
49     public ServletRequestMockImpl(Cookie JavaDoc[] cookies)
50     {
51         _cookies = cookies;
52     }
53     
54     public String JavaDoc getAuthType()
55     {
56         throw new UnsupportedOperationException JavaDoc();
57     }
58
59     public Cookie JavaDoc[] getCookies()
60     {
61         return _cookies;
62     }
63
64     public long getDateHeader(String JavaDoc name)
65     {
66         throw new UnsupportedOperationException JavaDoc();
67     }
68
69     public String JavaDoc getHeader(String JavaDoc name)
70     {
71         throw new UnsupportedOperationException JavaDoc();
72     }
73
74     public Enumeration getHeaders(String JavaDoc name)
75     {
76         throw new UnsupportedOperationException JavaDoc();
77     }
78
79     public Enumeration getHeaderNames()
80     {
81         throw new UnsupportedOperationException JavaDoc();
82     }
83
84     public int getIntHeader(String JavaDoc name)
85     {
86         throw new UnsupportedOperationException JavaDoc();
87     }
88
89     public String JavaDoc getMethod()
90     {
91         throw new UnsupportedOperationException JavaDoc();
92     }
93
94     public String JavaDoc getPathInfo()
95     {
96         return _pathInfo;
97     }
98
99     public String JavaDoc getPathTranslated()
100     {
101         throw new UnsupportedOperationException JavaDoc();
102     }
103
104     public String JavaDoc getContextPath()
105     {
106         throw new UnsupportedOperationException JavaDoc();
107     }
108
109     public String JavaDoc getQueryString()
110     {
111         throw new UnsupportedOperationException JavaDoc();
112     }
113
114     public String JavaDoc getRemoteUser()
115     {
116         throw new UnsupportedOperationException JavaDoc();
117     }
118
119     public boolean isUserInRole(String JavaDoc name)
120     {
121         throw new UnsupportedOperationException JavaDoc();
122     }
123
124     public Principal JavaDoc getUserPrincipal()
125     {
126         throw new UnsupportedOperationException JavaDoc();
127     }
128
129     public String JavaDoc getRequestedSessionId()
130     {
131         throw new UnsupportedOperationException JavaDoc();
132     }
133
134     public String JavaDoc getRequestURI()
135     {
136         throw new UnsupportedOperationException JavaDoc();
137     }
138
139     public StringBuffer JavaDoc getRequestURL()
140     {
141         throw new UnsupportedOperationException JavaDoc();
142     }
143
144     public String JavaDoc getServletPath()
145     {
146         return _servletPath;
147     }
148
149     public HttpSession JavaDoc getSession(boolean b)
150     {
151         if (b && _session == null)
152         {
153             _session = new ServletSessionMock();
154         }
155         return _session;
156     }
157
158     public HttpSession JavaDoc getSession()
159     {
160         return null;
161     }
162
163     public boolean isRequestedSessionIdValid()
164     {
165         throw new UnsupportedOperationException JavaDoc();
166     }
167
168     public boolean isRequestedSessionIdFromCookie()
169     {
170         throw new UnsupportedOperationException JavaDoc();
171     }
172
173     public boolean isRequestedSessionIdFromURL()
174     {
175         throw new UnsupportedOperationException JavaDoc();
176     }
177
178     public boolean isRequestedSessionIdFromUrl()
179     {
180         throw new UnsupportedOperationException JavaDoc();
181     }
182
183     public Object JavaDoc getAttribute(String JavaDoc name)
184     {
185         return _attributes.get(name);
186     }
187
188     public Enumeration getAttributeNames()
189     {
190         return new IteratorEnumeration(_attributes.keySet().iterator());
191     }
192
193     public String JavaDoc getCharacterEncoding()
194     {
195         throw new UnsupportedOperationException JavaDoc();
196     }
197
198     public void setCharacterEncoding(String JavaDoc name) throws UnsupportedEncodingException JavaDoc
199     {
200         throw new UnsupportedOperationException JavaDoc();
201     }
202
203     public int getContentLength()
204     {
205         throw new UnsupportedOperationException JavaDoc();
206     }
207
208     public String JavaDoc getContentType()
209     {
210         throw new UnsupportedOperationException JavaDoc();
211     }
212
213     public ServletInputStream JavaDoc getInputStream() throws IOException JavaDoc
214     {
215         throw new UnsupportedOperationException JavaDoc();
216     }
217
218     public String JavaDoc getParameter(String JavaDoc name)
219     {
220         throw new UnsupportedOperationException JavaDoc();
221     }
222
223     public Enumeration getParameterNames()
224     {
225         throw new UnsupportedOperationException JavaDoc();
226     }
227
228     public String JavaDoc[] getParameterValues(String JavaDoc name)
229     {
230         throw new UnsupportedOperationException JavaDoc();
231     }
232
233     public Map getParameterMap()
234     {
235         throw new UnsupportedOperationException JavaDoc();
236     }
237
238     public String JavaDoc getProtocol()
239     {
240         throw new UnsupportedOperationException JavaDoc();
241     }
242
243     public String JavaDoc getScheme()
244     {
245         throw new UnsupportedOperationException JavaDoc();
246     }
247
248     public String JavaDoc getServerName()
249     {
250         throw new UnsupportedOperationException JavaDoc();
251     }
252
253     public int getServerPort()
254     {
255         throw new UnsupportedOperationException JavaDoc();
256     }
257
258     public BufferedReader JavaDoc getReader() throws IOException JavaDoc
259     {
260         throw new UnsupportedOperationException JavaDoc();
261     }
262
263     public String JavaDoc getRemoteAddr()
264     {
265         throw new UnsupportedOperationException JavaDoc();
266     }
267
268     public String JavaDoc getRemoteHost()
269     {
270         throw new UnsupportedOperationException JavaDoc();
271     }
272
273     public void setAttribute(String JavaDoc name, Object JavaDoc o)
274     {
275         _attributes.put(name, o);
276     }
277
278     public void removeAttribute(String JavaDoc name)
279     {
280         _attributes.remove(name);
281     }
282
283     public Locale getLocale()
284     {
285         return LOCALES[0];
286     }
287
288     public Enumeration getLocales()
289     {
290         return new IteratorEnumeration(Arrays.asList(LOCALES).iterator());
291     }
292
293     public boolean isSecure()
294     {
295         throw new UnsupportedOperationException JavaDoc();
296     }
297
298     public RequestDispatcher JavaDoc getRequestDispatcher(String JavaDoc name)
299     {
300         throw new UnsupportedOperationException JavaDoc();
301     }
302
303     public String JavaDoc getRealPath(String JavaDoc name)
304     {
305         throw new UnsupportedOperationException JavaDoc();
306     }
307
308     public int getRemotePort()
309     {
310         throw new UnsupportedOperationException JavaDoc();
311     }
312
313     public String JavaDoc getLocalName()
314     {
315         throw new UnsupportedOperationException JavaDoc();
316     }
317
318     public String JavaDoc getLocalAddr()
319     {
320         throw new UnsupportedOperationException JavaDoc();
321     }
322
323     public int getLocalPort()
324     {
325         throw new UnsupportedOperationException JavaDoc();
326     }
327
328
329
330
331     // mock setters
332

333     public void setServletPath(String JavaDoc servletPath)
334     {
335         _servletPath = servletPath;
336     }
337
338     public void setPathInfo(String JavaDoc pathInfo)
339     {
340         _pathInfo = pathInfo;
341     }
342
343 }
344
Popular Tags