001: /*
002: * Copyright (c) 2003, Rafael Steil
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on 04/12/2004 15:57:26
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.http;
044:
045: import java.io.BufferedReader;
046: import java.io.IOException;
047: import java.io.UnsupportedEncodingException;
048: import java.security.Principal;
049: import java.util.Enumeration;
050: import java.util.HashMap;
051: import java.util.Hashtable;
052: import java.util.Locale;
053: import java.util.Map;
054:
055: import javax.servlet.RequestDispatcher;
056: import javax.servlet.ServletInputStream;
057: import javax.servlet.http.Cookie;
058: import javax.servlet.http.HttpServletRequest;
059: import javax.servlet.http.HttpSession;
060:
061: /**
062: * @author Rafael Steil
063: * @version $Id: FakeHttpRequest.java,v 1.5 2007/08/01 22:30:04 rafaelsteil Exp $
064: */
065: public class FakeHttpRequest implements HttpServletRequest {
066: private HttpSession session = new FakeHttpSession();
067: private Hashtable params = new Hashtable();
068: private Map attributes = new HashMap();
069:
070: public String getAuthType() {
071:
072: return null;
073: }
074:
075: public String getContextPath() {
076: return "";
077: }
078:
079: public Cookie[] getCookies() {
080:
081: return null;
082: }
083:
084: public long getDateHeader(String arg0) {
085:
086: return 0;
087: }
088:
089: public String getHeader(String arg0) {
090:
091: return null;
092: }
093:
094: public Enumeration getHeaderNames() {
095:
096: return null;
097: }
098:
099: public Enumeration getHeaders(String arg0) {
100:
101: return null;
102: }
103:
104: public int getIntHeader(String arg0) {
105:
106: return 0;
107: }
108:
109: public String getMethod() {
110: return "dummy-method";
111: }
112:
113: public String getPathInfo() {
114:
115: return null;
116: }
117:
118: public String getPathTranslated() {
119:
120: return null;
121: }
122:
123: public String getQueryString() {
124:
125: return null;
126: }
127:
128: public String getRemoteUser() {
129:
130: return null;
131: }
132:
133: public String getRequestedSessionId() {
134:
135: return null;
136: }
137:
138: public String getRequestURI() {
139: return "";
140: }
141:
142: public StringBuffer getRequestURL() {
143:
144: return null;
145: }
146:
147: public String getServletPath() {
148:
149: return null;
150: }
151:
152: public HttpSession getSession() {
153: return this .session;
154: }
155:
156: public HttpSession getSession(boolean arg0) {
157: return this .getSession();
158: }
159:
160: public Principal getUserPrincipal() {
161:
162: return null;
163: }
164:
165: public boolean isRequestedSessionIdFromCookie() {
166:
167: return false;
168: }
169:
170: public boolean isRequestedSessionIdFromUrl() {
171:
172: return false;
173: }
174:
175: public boolean isRequestedSessionIdFromURL() {
176:
177: return false;
178: }
179:
180: public boolean isRequestedSessionIdValid() {
181:
182: return false;
183: }
184:
185: public boolean isUserInRole(String arg0) {
186:
187: return false;
188: }
189:
190: public Object getAttribute(String arg0) {
191: return this .attributes.get(arg0);
192: }
193:
194: public Enumeration getAttributeNames() {
195:
196: return null;
197: }
198:
199: public String getCharacterEncoding() {
200:
201: return null;
202: }
203:
204: public int getContentLength() {
205:
206: return 0;
207: }
208:
209: public String getContentType() {
210:
211: return null;
212: }
213:
214: public ServletInputStream getInputStream() throws IOException {
215:
216: return null;
217: }
218:
219: public String getLocalAddr() {
220:
221: return null;
222: }
223:
224: public Locale getLocale() {
225:
226: return null;
227: }
228:
229: public Enumeration getLocales() {
230:
231: return null;
232: }
233:
234: public String getLocalName() {
235:
236: return null;
237: }
238:
239: public int getLocalPort() {
240:
241: return 0;
242: }
243:
244: public String getParameter(String arg0) {
245:
246: return null;
247: }
248:
249: public Map getParameterMap() {
250:
251: return null;
252: }
253:
254: public Enumeration getParameterNames() {
255: return this .params.elements();
256: }
257:
258: public String[] getParameterValues(String arg0) {
259:
260: return null;
261: }
262:
263: public String getProtocol() {
264:
265: return null;
266: }
267:
268: public BufferedReader getReader() throws IOException {
269:
270: return null;
271: }
272:
273: public String getRealPath(String arg0) {
274:
275: return null;
276: }
277:
278: public String getRemoteAddr() {
279:
280: return null;
281: }
282:
283: public String getRemoteHost() {
284:
285: return null;
286: }
287:
288: public int getRemotePort() {
289:
290: return 0;
291: }
292:
293: public RequestDispatcher getRequestDispatcher(String arg0) {
294:
295: return null;
296: }
297:
298: public String getScheme() {
299:
300: return null;
301: }
302:
303: public String getServerName() {
304:
305: return null;
306: }
307:
308: public int getServerPort() {
309:
310: return 0;
311: }
312:
313: public boolean isSecure() {
314:
315: return false;
316: }
317:
318: public void removeAttribute(String arg0) {
319: this .attributes.remove(arg0);
320: }
321:
322: public void setAttribute(String arg0, Object arg1) {
323: this .attributes.put(arg0, arg1);
324: }
325:
326: public void setCharacterEncoding(String arg0)
327: throws UnsupportedEncodingException {
328:
329: }
330: }
|