001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package javax.servlet.http;
005:
006: import com.tc.exception.ImplementMe;
007:
008: import java.io.BufferedReader;
009: import java.security.Principal;
010: import java.util.Enumeration;
011: import java.util.Locale;
012: import java.util.Map;
013:
014: import javax.servlet.RequestDispatcher;
015: import javax.servlet.ServletInputStream;
016:
017: public class MockHttpServletRequest implements HttpServletRequest {
018:
019: private final String contextPath;
020: private String requestUrl;
021: private HttpSession session;
022: private String requestedSessionId;
023: private boolean sidFromCookie;
024: private boolean sidValid;
025: private String scheme;
026: private String serverName;
027: private int serverPort;
028:
029: public MockHttpServletRequest() {
030: this .contextPath = "/";
031: }
032:
033: public MockHttpServletRequest(String contextPath,
034: String requestedSessionId) {
035: this .contextPath = contextPath;
036: this .requestedSessionId = requestedSessionId;
037: }
038:
039: public void setSession(HttpSession session) {
040: this .session = session;
041: }
042:
043: public void setRequestedSessionId(String requestedSessionId) {
044: this .requestedSessionId = requestedSessionId;
045: }
046:
047: public void setRequestUrl(String requestUrl) {
048: this .requestUrl = requestUrl;
049: }
050:
051: public void setSidFromCookie(boolean sidFromCookie) {
052: this .sidFromCookie = sidFromCookie;
053: }
054:
055: public void setSidValid(boolean sidValid) {
056: this .sidValid = sidValid;
057: }
058:
059: public void setScheme(String scheme) {
060: this .scheme = scheme;
061: }
062:
063: public void setServerName(String serverName) {
064: this .serverName = serverName;
065: }
066:
067: public void setServerPort(int serverPort) {
068: this .serverPort = serverPort;
069: }
070:
071: public String getAuthType() {
072: throw new ImplementMe();
073: }
074:
075: public String getContextPath() {
076: return contextPath;
077: }
078:
079: public Cookie[] getCookies() {
080: throw new ImplementMe();
081: }
082:
083: public long getDateHeader(String arg0) {
084: throw new ImplementMe();
085: }
086:
087: public String getHeader(String arg0) {
088: throw new ImplementMe();
089: }
090:
091: public Enumeration getHeaderNames() {
092: throw new ImplementMe();
093: }
094:
095: public Enumeration getHeaders(String arg0) {
096: throw new ImplementMe();
097: }
098:
099: public int getIntHeader(String arg0) {
100: throw new ImplementMe();
101: }
102:
103: public String getMethod() {
104: throw new ImplementMe();
105: }
106:
107: public String getPathInfo() {
108: throw new ImplementMe();
109: }
110:
111: public String getPathTranslated() {
112: throw new ImplementMe();
113: }
114:
115: public String getQueryString() {
116: throw new ImplementMe();
117: }
118:
119: public String getRemoteUser() {
120: throw new ImplementMe();
121: }
122:
123: public String getRequestURI() {
124: throw new ImplementMe();
125: }
126:
127: public StringBuffer getRequestURL() {
128: return new StringBuffer(requestUrl);
129: }
130:
131: public String getRequestedSessionId() {
132: throw new ImplementMe();
133: }
134:
135: public String getServletPath() {
136: throw new ImplementMe();
137: }
138:
139: public HttpSession getSession() {
140: return getSession(true);
141: }
142:
143: public HttpSession getSession(boolean create) {
144: if (!create && requestedSessionId == null)
145: return session;
146: if (session == null)
147: session = new MockHttpSession(requestedSessionId);
148: return session;
149: }
150:
151: public Principal getUserPrincipal() {
152: throw new ImplementMe();
153: }
154:
155: public boolean isRequestedSessionIdFromCookie() {
156: return sidFromCookie;
157: }
158:
159: public boolean isRequestedSessionIdFromURL() {
160: return !sidFromCookie;
161: }
162:
163: public boolean isRequestedSessionIdFromUrl() {
164: return isRequestedSessionIdFromURL();
165: }
166:
167: public boolean isRequestedSessionIdValid() {
168: return sidValid;
169: }
170:
171: public boolean isUserInRole(String arg0) {
172: throw new ImplementMe();
173: }
174:
175: public Object getAttribute(String arg0) {
176: throw new ImplementMe();
177: }
178:
179: public Enumeration getAttributeNames() {
180: throw new ImplementMe();
181: }
182:
183: public String getCharacterEncoding() {
184: throw new ImplementMe();
185: }
186:
187: public int getContentLength() {
188: throw new ImplementMe();
189: }
190:
191: public String getContentType() {
192: throw new ImplementMe();
193: }
194:
195: public ServletInputStream getInputStream() {
196: throw new ImplementMe();
197: }
198:
199: public String getLocalAddr() {
200: throw new ImplementMe();
201: }
202:
203: public String getLocalName() {
204: throw new ImplementMe();
205: }
206:
207: public int getLocalPort() {
208: throw new ImplementMe();
209: }
210:
211: public Locale getLocale() {
212: throw new ImplementMe();
213: }
214:
215: public Enumeration getLocales() {
216: throw new ImplementMe();
217: }
218:
219: public String getParameter(String arg0) {
220: throw new ImplementMe();
221: }
222:
223: public Map getParameterMap() {
224: throw new ImplementMe();
225: }
226:
227: public Enumeration getParameterNames() {
228: throw new ImplementMe();
229: }
230:
231: public String[] getParameterValues(String arg0) {
232: throw new ImplementMe();
233: }
234:
235: public String getProtocol() {
236: throw new ImplementMe();
237: }
238:
239: public BufferedReader getReader() {
240: throw new ImplementMe();
241: }
242:
243: public String getRealPath(String arg0) {
244: throw new ImplementMe();
245: }
246:
247: public String getRemoteAddr() {
248: throw new ImplementMe();
249: }
250:
251: public String getRemoteHost() {
252: throw new ImplementMe();
253: }
254:
255: public int getRemotePort() {
256: throw new ImplementMe();
257: }
258:
259: public RequestDispatcher getRequestDispatcher(String arg0) {
260: throw new ImplementMe();
261: }
262:
263: public String getScheme() {
264: return scheme;
265: }
266:
267: public String getServerName() {
268: return serverName;
269: }
270:
271: public int getServerPort() {
272: return serverPort;
273: }
274:
275: public boolean isSecure() {
276: throw new ImplementMe();
277: }
278:
279: public void removeAttribute(String arg0) {
280: throw new ImplementMe();
281:
282: }
283:
284: public void setAttribute(String arg0, Object arg1) {
285: throw new ImplementMe();
286:
287: }
288:
289: public void setCharacterEncoding(String arg0) {
290: throw new ImplementMe();
291:
292: }
293:
294: }
|