1
|
|
/*
|
2
|
|
* Angkor Web Framework
|
3
|
|
*
|
4
|
|
* Distributable under LGPL license.
|
5
|
|
* See terms of license at gnu.org.
|
6
|
|
*/
|
7
|
|
|
8
|
|
package com.tirsen.angkor.test.unit.mock;
|
9
|
|
|
10
|
|
import org.apache.commons.logging.Log;
|
11
|
|
import org.apache.commons.logging.LogFactory;
|
12
|
|
|
13
|
|
import javax.servlet.RequestDispatcher;
|
14
|
|
import javax.servlet.ServletInputStream;
|
15
|
|
import javax.servlet.http.Cookie;
|
16
|
|
import javax.servlet.http.HttpServletRequest;
|
17
|
|
import javax.servlet.http.HttpSession;
|
18
|
|
import java.io.BufferedReader;
|
19
|
|
import java.io.IOException;
|
20
|
|
import java.io.UnsupportedEncodingException;
|
21
|
|
import java.security.Principal;
|
22
|
|
import java.util.Enumeration;
|
23
|
|
import java.util.Locale;
|
24
|
|
import java.util.Map;
|
25
|
|
|
26
|
|
import com.tirsen.angkor.Application;
|
27
|
|
import com.tirsen.angkor.ApplicationFactory;
|
28
|
|
|
29
|
|
/**
|
30
|
|
* TODO document MockServletRequest
|
31
|
|
*
|
32
|
|
* <!-- $Id: MockServletRequest.java,v 1.4 2002/10/13 19:59:23 tirsen Exp $ -->
|
33
|
|
*
|
34
|
|
* @author $Author: tirsen $
|
35
|
|
* @version $Revision: 1.4 $
|
36
|
|
*/
|
37
|
|
public class MockServletRequest implements HttpServletRequest
|
38
|
|
{
|
39
|
|
private static Log logger = LogFactory.getLog(MockServletRequest.class);
|
40
|
|
|
41
|
|
private String requestURI = "/app";
|
42
|
|
|
43
|
19
|
public MockServletRequest()
|
44
|
|
{
|
45
|
|
}
|
46
|
|
|
47
|
0
|
public MockServletRequest(String requestURI)
|
48
|
|
{
|
49
|
0
|
this.requestURI = requestURI;
|
50
|
|
}
|
51
|
|
|
52
|
1
|
public MockServletRequest(Application application, String requestURI)
|
53
|
|
{
|
54
|
1
|
this(application);
|
55
|
1
|
this.requestURI = requestURI;
|
56
|
|
}
|
57
|
|
|
58
|
1
|
public MockServletRequest(Application application)
|
59
|
|
{
|
60
|
1
|
ApplicationFactory applicationFactory = new ApplicationFactory(getSession());
|
61
|
1
|
applicationFactory.setApplication(application);
|
62
|
|
}
|
63
|
|
|
64
|
|
private MockHttpSession session = new MockHttpSession();
|
65
|
|
|
66
|
0
|
public Object getAttribute(String s)
|
67
|
|
{
|
68
|
|
// TODO implement MockServletRequest.getAttribute
|
69
|
0
|
throw new RuntimeException("MockServletRequest.getAttribute is not implemented yet.");
|
70
|
|
}
|
71
|
|
|
72
|
0
|
public Enumeration getAttributeNames()
|
73
|
|
{
|
74
|
|
// TODO implement MockServletRequest.getAttributeNames
|
75
|
0
|
throw new RuntimeException("MockServletRequest.getAttributeNames is not implemented yet.");
|
76
|
|
}
|
77
|
|
|
78
|
0
|
public String getCharacterEncoding()
|
79
|
|
{
|
80
|
|
// TODO implement MockServletRequest.getCharacterEncoding
|
81
|
0
|
throw new RuntimeException("MockServletRequest.getCharacterEncoding is not implemented yet.");
|
82
|
|
}
|
83
|
|
|
84
|
0
|
public void setCharacterEncoding(String s) throws UnsupportedEncodingException
|
85
|
|
{
|
86
|
|
// TODO implement MockServletRequest.setCharacterEncoding
|
87
|
0
|
throw new RuntimeException("MockServletRequest.setCharacterEncoding is not implemented yet.");
|
88
|
|
}
|
89
|
|
|
90
|
0
|
public int getContentLength()
|
91
|
|
{
|
92
|
|
// TODO implement MockServletRequest.getContentLength
|
93
|
0
|
throw new RuntimeException("MockServletRequest.getContentLength is not implemented yet.");
|
94
|
|
}
|
95
|
|
|
96
|
0
|
public String getContentType()
|
97
|
|
{
|
98
|
|
// TODO implement MockServletRequest.getContentType
|
99
|
0
|
throw new RuntimeException("MockServletRequest.getContentType is not implemented yet.");
|
100
|
|
}
|
101
|
|
|
102
|
0
|
public ServletInputStream getInputStream() throws IOException
|
103
|
|
{
|
104
|
|
// TODO implement MockServletRequest.getInputStream
|
105
|
0
|
throw new RuntimeException("MockServletRequest.getInputStream is not implemented yet.");
|
106
|
|
}
|
107
|
|
|
108
|
0
|
public String getParameter(String s)
|
109
|
|
{
|
110
|
|
// TODO implement MockServletRequest.getParameter
|
111
|
0
|
throw new RuntimeException("MockServletRequest.getParameter is not implemented yet.");
|
112
|
|
}
|
113
|
|
|
114
|
0
|
public Enumeration getParameterNames()
|
115
|
|
{
|
116
|
|
// TODO implement MockServletRequest.getParameterNames
|
117
|
0
|
throw new RuntimeException("MockServletRequest.getParameterNames is not implemented yet.");
|
118
|
|
}
|
119
|
|
|
120
|
0
|
public String[] getParameterValues(String s)
|
121
|
|
{
|
122
|
|
// TODO implement MockServletRequest.getParameterValues
|
123
|
0
|
throw new RuntimeException("MockServletRequest.getParameterValues is not implemented yet.");
|
124
|
|
}
|
125
|
|
|
126
|
0
|
public Map getParameterMap()
|
127
|
|
{
|
128
|
|
// TODO implement MockServletRequest.getParameterMap
|
129
|
0
|
throw new RuntimeException("MockServletRequest.getParameterMap is not implemented yet.");
|
130
|
|
}
|
131
|
|
|
132
|
0
|
public String getProtocol()
|
133
|
|
{
|
134
|
|
// TODO implement MockServletRequest.getProtocol
|
135
|
0
|
throw new RuntimeException("MockServletRequest.getProtocol is not implemented yet.");
|
136
|
|
}
|
137
|
|
|
138
|
1
|
public String getScheme()
|
139
|
|
{
|
140
|
1
|
return "http";
|
141
|
|
}
|
142
|
|
|
143
|
1
|
public String getServerName()
|
144
|
|
{
|
145
|
1
|
return "localhost";
|
146
|
|
}
|
147
|
|
|
148
|
1
|
public int getServerPort()
|
149
|
|
{
|
150
|
1
|
return 80;
|
151
|
|
}
|
152
|
|
|
153
|
0
|
public BufferedReader getReader() throws IOException
|
154
|
|
{
|
155
|
|
// TODO implement MockServletRequest.getReader
|
156
|
0
|
throw new RuntimeException("MockServletRequest.getReader is not implemented yet.");
|
157
|
|
}
|
158
|
|
|
159
|
0
|
public String getRemoteAddr()
|
160
|
|
{
|
161
|
|
// TODO implement MockServletRequest.getRemoteAddr
|
162
|
0
|
throw new RuntimeException("MockServletRequest.getRemoteAddr is not implemented yet.");
|
163
|
|
}
|
164
|
|
|
165
|
0
|
public String getRemoteHost()
|
166
|
|
{
|
167
|
|
// TODO implement MockServletRequest.getRemoteHost
|
168
|
0
|
throw new RuntimeException("MockServletRequest.getRemoteHost is not implemented yet.");
|
169
|
|
}
|
170
|
|
|
171
|
0
|
public void setAttribute(String s, Object o)
|
172
|
|
{
|
173
|
|
// TODO implement MockServletRequest.setAttribute
|
174
|
0
|
throw new RuntimeException("MockServletRequest.setAttribute is not implemented yet.");
|
175
|
|
}
|
176
|
|
|
177
|
0
|
public void removeAttribute(String s)
|
178
|
|
{
|
179
|
|
// TODO implement MockServletRequest.removeAttribute
|
180
|
0
|
throw new RuntimeException("MockServletRequest.removeAttribute is not implemented yet.");
|
181
|
|
}
|
182
|
|
|
183
|
0
|
public Locale getLocale()
|
184
|
|
{
|
185
|
|
// TODO implement MockServletRequest.getLocale
|
186
|
0
|
throw new RuntimeException("MockServletRequest.getLocale is not implemented yet.");
|
187
|
|
}
|
188
|
|
|
189
|
0
|
public Enumeration getLocales()
|
190
|
|
{
|
191
|
|
// TODO implement MockServletRequest.getLocales
|
192
|
0
|
throw new RuntimeException("MockServletRequest.getLocales is not implemented yet.");
|
193
|
|
}
|
194
|
|
|
195
|
0
|
public boolean isSecure()
|
196
|
|
{
|
197
|
|
// TODO implement MockServletRequest.isSecure
|
198
|
0
|
throw new RuntimeException("MockServletRequest.isSecure is not implemented yet.");
|
199
|
|
}
|
200
|
|
|
201
|
0
|
public RequestDispatcher getRequestDispatcher(String s)
|
202
|
|
{
|
203
|
|
// TODO implement MockServletRequest.getRequestDispatcher
|
204
|
0
|
throw new RuntimeException("MockServletRequest.getRequestDispatcher is not implemented yet.");
|
205
|
|
}
|
206
|
|
|
207
|
0
|
public String getRealPath(String s)
|
208
|
|
{
|
209
|
|
// TODO implement MockServletRequest.getRealPath
|
210
|
0
|
throw new RuntimeException("MockServletRequest.getRealPath is not implemented yet.");
|
211
|
|
}
|
212
|
|
|
213
|
0
|
public String getAuthType()
|
214
|
|
{
|
215
|
|
// TODO implement MockServletRequest.getAuthType
|
216
|
0
|
throw new RuntimeException("MockServletRequest.getAuthType is not implemented yet.");
|
217
|
|
}
|
218
|
|
|
219
|
0
|
public Cookie[] getCookies()
|
220
|
|
{
|
221
|
|
// TODO implement MockServletRequest.getCookies
|
222
|
0
|
throw new RuntimeException("MockServletRequest.getCookies is not implemented yet.");
|
223
|
|
}
|
224
|
|
|
225
|
0
|
public long getDateHeader(String s)
|
226
|
|
{
|
227
|
|
// TODO implement MockServletRequest.getDateHeader
|
228
|
0
|
throw new RuntimeException("MockServletRequest.getDateHeader is not implemented yet.");
|
229
|
|
}
|
230
|
|
|
231
|
0
|
public String getHeader(String s)
|
232
|
|
{
|
233
|
|
// TODO implement MockServletRequest.getHeader
|
234
|
0
|
throw new RuntimeException("MockServletRequest.getHeader is not implemented yet.");
|
235
|
|
}
|
236
|
|
|
237
|
0
|
public Enumeration getHeaders(String s)
|
238
|
|
{
|
239
|
|
// TODO implement MockServletRequest.getHeaders
|
240
|
0
|
throw new RuntimeException("MockServletRequest.getHeaders is not implemented yet.");
|
241
|
|
}
|
242
|
|
|
243
|
0
|
public Enumeration getHeaderNames()
|
244
|
|
{
|
245
|
|
// TODO implement MockServletRequest.getHeaderNames
|
246
|
0
|
throw new RuntimeException("MockServletRequest.getHeaderNames is not implemented yet.");
|
247
|
|
}
|
248
|
|
|
249
|
0
|
public int getIntHeader(String s)
|
250
|
|
{
|
251
|
|
// TODO implement MockServletRequest.getIntHeader
|
252
|
0
|
throw new RuntimeException("MockServletRequest.getIntHeader is not implemented yet.");
|
253
|
|
}
|
254
|
|
|
255
|
0
|
public String getMethod()
|
256
|
|
{
|
257
|
|
// TODO implement MockServletRequest.getMethod
|
258
|
0
|
throw new RuntimeException("MockServletRequest.getMethod is not implemented yet.");
|
259
|
|
}
|
260
|
|
|
261
|
0
|
public boolean isRequestedSessionIdFromUrl()
|
262
|
|
{
|
263
|
|
// TODO implement MockServletRequest.isRequestedSessionIdFromUrl
|
264
|
0
|
throw new RuntimeException("MockServletRequest.isRequestedSessionIdFromUrl is not implemented yet.");
|
265
|
|
}
|
266
|
|
|
267
|
0
|
public boolean isRequestedSessionIdFromURL()
|
268
|
|
{
|
269
|
|
// TODO implement MockServletRequest.isRequestedSessionIdFromURL
|
270
|
0
|
throw new RuntimeException("MockServletRequest.isRequestedSessionIdFromURL is not implemented yet.");
|
271
|
|
}
|
272
|
|
|
273
|
0
|
public boolean isRequestedSessionIdFromCookie()
|
274
|
|
{
|
275
|
|
// TODO implement MockServletRequest.isRequestedSessionIdFromCookie
|
276
|
0
|
throw new RuntimeException("MockServletRequest.isRequestedSessionIdFromCookie is not implemented yet.");
|
277
|
|
}
|
278
|
|
|
279
|
0
|
public boolean isRequestedSessionIdValid()
|
280
|
|
{
|
281
|
|
// TODO implement MockServletRequest.isRequestedSessionIdValid
|
282
|
0
|
throw new RuntimeException("MockServletRequest.isRequestedSessionIdValid is not implemented yet.");
|
283
|
|
}
|
284
|
|
|
285
|
11
|
public HttpSession getSession()
|
286
|
|
{
|
287
|
11
|
return session;
|
288
|
|
}
|
289
|
|
|
290
|
0
|
public HttpSession getSession(boolean b)
|
291
|
|
{
|
292
|
|
// TODO implement MockServletRequest.getSession
|
293
|
0
|
throw new RuntimeException("MockServletRequest.getSession is not implemented yet.");
|
294
|
|
}
|
295
|
|
|
296
|
0
|
public String getServletPath()
|
297
|
|
{
|
298
|
|
// TODO implement MockServletRequest.getServletPath
|
299
|
0
|
throw new RuntimeException("MockServletRequest.getServletPath is not implemented yet.");
|
300
|
|
}
|
301
|
|
|
302
|
0
|
public StringBuffer getRequestURL()
|
303
|
|
{
|
304
|
|
// TODO implement MockServletRequest.getRequestURL
|
305
|
0
|
throw new RuntimeException("MockServletRequest.getRequestURL is not implemented yet.");
|
306
|
|
}
|
307
|
|
|
308
|
2
|
public String getRequestURI()
|
309
|
|
{
|
310
|
2
|
return requestURI;
|
311
|
|
}
|
312
|
|
|
313
|
2
|
public void setRequestURI(String requestURI)
|
314
|
|
{
|
315
|
2
|
this.requestURI = requestURI;
|
316
|
|
}
|
317
|
|
|
318
|
0
|
public String getRequestedSessionId()
|
319
|
|
{
|
320
|
|
// TODO implement MockServletRequest.getRequestedSessionId
|
321
|
0
|
throw new RuntimeException("MockServletRequest.getRequestedSessionId is not implemented yet.");
|
322
|
|
}
|
323
|
|
|
324
|
0
|
public Principal getUserPrincipal()
|
325
|
|
{
|
326
|
|
// TODO implement MockServletRequest.getUserPrincipal
|
327
|
0
|
throw new RuntimeException("MockServletRequest.getUserPrincipal is not implemented yet.");
|
328
|
|
}
|
329
|
|
|
330
|
0
|
public boolean isUserInRole(String s)
|
331
|
|
{
|
332
|
|
// TODO implement MockServletRequest.isUserInRole
|
333
|
0
|
throw new RuntimeException("MockServletRequest.isUserInRole is not implemented yet.");
|
334
|
|
}
|
335
|
|
|
336
|
0
|
public String getRemoteUser()
|
337
|
|
{
|
338
|
|
// TODO implement MockServletRequest.getRemoteUser
|
339
|
0
|
throw new RuntimeException("MockServletRequest.getRemoteUser is not implemented yet.");
|
340
|
|
}
|
341
|
|
|
342
|
0
|
public String getQueryString()
|
343
|
|
{
|
344
|
|
// TODO implement MockServletRequest.getQueryString
|
345
|
0
|
throw new RuntimeException("MockServletRequest.getQueryString is not implemented yet.");
|
346
|
|
}
|
347
|
|
|
348
|
1
|
public String getContextPath()
|
349
|
|
{
|
350
|
1
|
return "TODO";
|
351
|
|
}
|
352
|
|
|
353
|
0
|
public String getPathTranslated()
|
354
|
|
{
|
355
|
|
// TODO implement MockServletRequest.getPathTranslated
|
356
|
0
|
throw new RuntimeException("MockServletRequest.getPathTranslated is not implemented yet.");
|
357
|
|
}
|
358
|
|
|
359
|
0
|
public String getPathInfo()
|
360
|
|
{
|
361
|
|
// TODO implement MockServletRequest.getPathInfo
|
362
|
0
|
throw new RuntimeException("MockServletRequest.getPathInfo is not implemented yet.");
|
363
|
|
}
|
364
|
|
}
|
365
|
|
|