Source Code Cross Referenced for MockHttpServletRequest.java in  » Net » apache-common-FileUpload » org » apache » commons » fileupload » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » apache common FileUpload » org.apache.commons.fileupload 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.fileupload;
018:
019:        import java.io.BufferedReader;
020:        import java.io.ByteArrayInputStream;
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:        import java.io.UnsupportedEncodingException;
024:        import java.security.Principal;
025:        import java.util.Enumeration;
026:        import java.util.Locale;
027:        import java.util.Map;
028:
029:        import javax.servlet.RequestDispatcher;
030:        import javax.servlet.ServletInputStream;
031:        import javax.servlet.http.Cookie;
032:        import javax.servlet.http.HttpServletRequest;
033:        import javax.servlet.http.HttpSession;
034:
035:        /**
036:         *
037:         *
038:         *
039:         *
040:         *
041:         *
042:         */
043:        class MockHttpServletRequest implements  HttpServletRequest {
044:
045:            private final InputStream m_requestData;
046:            private final int length;
047:            private String m_strContentType;
048:            private Map m_headers = new java.util.HashMap();
049:
050:            /**
051:             * Creates a new instance with the given request data
052:             * and content type.
053:             */
054:            public MockHttpServletRequest(final byte[] requestData,
055:                    final String strContentType) {
056:                this (new ByteArrayInputStream(requestData), requestData.length,
057:                        strContentType);
058:            }
059:
060:            /**
061:             * Creates a new instance with the given request data
062:             * and content type.
063:             */
064:            public MockHttpServletRequest(final InputStream requestData,
065:                    final int requestLength, final String strContentType) {
066:                m_requestData = requestData;
067:                length = requestLength;
068:                m_strContentType = strContentType;
069:                m_headers.put(FileUploadBase.CONTENT_TYPE, strContentType);
070:            }
071:
072:            /**
073:             * @see javax.servlet.http.HttpServletRequest#getAuthType()
074:             */
075:            public String getAuthType() {
076:                return null;
077:            }
078:
079:            /**
080:             * @see javax.servlet.http.HttpServletRequest#getCookies()
081:             */
082:            public Cookie[] getCookies() {
083:                return null;
084:            }
085:
086:            /**
087:             * @see javax.servlet.http.HttpServletRequest#getDateHeader(String)
088:             */
089:            public long getDateHeader(String arg0) {
090:                return 0;
091:            }
092:
093:            /**
094:             * @see javax.servlet.http.HttpServletRequest#getHeader(String)
095:             */
096:            public String getHeader(String headerName) {
097:                return (String) m_headers.get(headerName);
098:            }
099:
100:            /**
101:             * @see javax.servlet.http.HttpServletRequest#getHeaders(String)
102:             */
103:            public Enumeration getHeaders(String arg0) {
104:                // todo - implement
105:                return null;
106:            }
107:
108:            /**
109:             * @see javax.servlet.http.HttpServletRequest#getHeaderNames()
110:             */
111:            public Enumeration getHeaderNames() {
112:                // todo - implement
113:                return null;
114:            }
115:
116:            /**
117:             * @see javax.servlet.http.HttpServletRequest#getIntHeader(String)
118:             */
119:            public int getIntHeader(String arg0) {
120:                return 0;
121:            }
122:
123:            /**
124:             * @see javax.servlet.http.HttpServletRequest#getMethod()
125:             */
126:            public String getMethod() {
127:                return null;
128:            }
129:
130:            /**
131:             * @see javax.servlet.http.HttpServletRequest#getPathInfo()
132:             */
133:            public String getPathInfo() {
134:                return null;
135:            }
136:
137:            /**
138:             * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
139:             */
140:            public String getPathTranslated() {
141:                return null;
142:            }
143:
144:            /**
145:             * @see javax.servlet.http.HttpServletRequest#getContextPath()
146:             */
147:            public String getContextPath() {
148:                return null;
149:            }
150:
151:            /**
152:             * @see javax.servlet.http.HttpServletRequest#getQueryString()
153:             */
154:            public String getQueryString() {
155:                return null;
156:            }
157:
158:            /**
159:             * @see javax.servlet.http.HttpServletRequest#getRemoteUser()
160:             */
161:            public String getRemoteUser() {
162:                return null;
163:            }
164:
165:            /**
166:             * @see javax.servlet.http.HttpServletRequest#isUserInRole(String)
167:             */
168:            public boolean isUserInRole(String arg0) {
169:                return false;
170:            }
171:
172:            /**
173:             * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
174:             */
175:            public Principal getUserPrincipal() {
176:                return null;
177:            }
178:
179:            /**
180:             * @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
181:             */
182:            public String getRequestedSessionId() {
183:                return null;
184:            }
185:
186:            /**
187:             * @see javax.servlet.http.HttpServletRequest#getRequestURI()
188:             */
189:            public String getRequestURI() {
190:                return null;
191:            }
192:
193:            /**
194:             * @see javax.servlet.http.HttpServletRequest#getRequestURL()
195:             */
196:            public StringBuffer getRequestURL() {
197:                return null;
198:            }
199:
200:            /**
201:             * @see javax.servlet.http.HttpServletRequest#getServletPath()
202:             */
203:            public String getServletPath() {
204:                return null;
205:            }
206:
207:            /**
208:             * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
209:             */
210:            public HttpSession getSession(boolean arg0) {
211:                return null;
212:            }
213:
214:            /**
215:             * @see javax.servlet.http.HttpServletRequest#getSession()
216:             */
217:            public HttpSession getSession() {
218:                return null;
219:            }
220:
221:            /**
222:             * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
223:             */
224:            public boolean isRequestedSessionIdValid() {
225:                return false;
226:            }
227:
228:            /**
229:             * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromCookie()
230:             */
231:            public boolean isRequestedSessionIdFromCookie() {
232:                return false;
233:            }
234:
235:            /**
236:             * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromURL()
237:             */
238:            public boolean isRequestedSessionIdFromURL() {
239:                return false;
240:            }
241:
242:            /**
243:             * @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl()
244:             * @deprecated
245:             */
246:            public boolean isRequestedSessionIdFromUrl() {
247:                return false;
248:            }
249:
250:            /**
251:             * @see javax.servlet.ServletRequest#getAttribute(String)
252:             */
253:            public Object getAttribute(String arg0) {
254:                return null;
255:            }
256:
257:            /**
258:             * @see javax.servlet.ServletRequest#getAttributeNames()
259:             */
260:            public Enumeration getAttributeNames() {
261:                return null;
262:            }
263:
264:            /**
265:             * @see javax.servlet.ServletRequest#getCharacterEncoding()
266:             */
267:            public String getCharacterEncoding() {
268:                return null;
269:            }
270:
271:            /**
272:             * @see javax.servlet.ServletRequest#setCharacterEncoding(String)
273:             */
274:            public void setCharacterEncoding(String arg0)
275:                    throws UnsupportedEncodingException {
276:            }
277:
278:            /**
279:             * @see javax.servlet.ServletRequest#getContentLength()
280:             */
281:            public int getContentLength() {
282:                int iLength = 0;
283:
284:                if (null == m_requestData) {
285:                    iLength = -1;
286:                } else {
287:                    iLength = length;
288:                }
289:                return iLength;
290:            }
291:
292:            /**
293:             * @see javax.servlet.ServletRequest#getContentType()
294:             */
295:            public String getContentType() {
296:                return m_strContentType;
297:            }
298:
299:            /**
300:             * @see javax.servlet.ServletRequest#getInputStream()
301:             */
302:            public ServletInputStream getInputStream() throws IOException {
303:                ServletInputStream sis = new MyServletInputStream(m_requestData);
304:                return sis;
305:            }
306:
307:            /**
308:             * @see javax.servlet.ServletRequest#getParameter(String)
309:             */
310:            public String getParameter(String arg0) {
311:                return null;
312:            }
313:
314:            /**
315:             * @see javax.servlet.ServletRequest#getParameterNames()
316:             */
317:            public Enumeration getParameterNames() {
318:                return null;
319:            }
320:
321:            /**
322:             * @see javax.servlet.ServletRequest#getParameterValues(String)
323:             */
324:            public String[] getParameterValues(String arg0) {
325:                return null;
326:            }
327:
328:            /**
329:             * @see javax.servlet.ServletRequest#getParameterMap()
330:             */
331:            public Map getParameterMap() {
332:                return null;
333:            }
334:
335:            /**
336:             * @see javax.servlet.ServletRequest#getProtocol()
337:             */
338:            public String getProtocol() {
339:                return null;
340:            }
341:
342:            /**
343:             * @see javax.servlet.ServletRequest#getScheme()
344:             */
345:            public String getScheme() {
346:                return null;
347:            }
348:
349:            /**
350:             * @see javax.servlet.ServletRequest#getServerName()
351:             */
352:            public String getServerName() {
353:                return null;
354:            }
355:
356:            /**
357:             * @see javax.servlet.ServletRequest#getServerPort()
358:             */
359:            public int getServerPort() {
360:                return 0;
361:            }
362:
363:            /**
364:             * @see javax.servlet.ServletRequest#getReader()
365:             */
366:            public BufferedReader getReader() throws IOException {
367:                return null;
368:            }
369:
370:            /**
371:             * @see javax.servlet.ServletRequest#getRemoteAddr()
372:             */
373:            public String getRemoteAddr() {
374:                return null;
375:            }
376:
377:            /**
378:             * @see javax.servlet.ServletRequest#getRemoteHost()
379:             */
380:            public String getRemoteHost() {
381:                return null;
382:            }
383:
384:            /**
385:             * @see javax.servlet.ServletRequest#setAttribute(String, Object)
386:             */
387:            public void setAttribute(String arg0, Object arg1) {
388:            }
389:
390:            /**
391:             * @see javax.servlet.ServletRequest#removeAttribute(String)
392:             */
393:            public void removeAttribute(String arg0) {
394:            }
395:
396:            /**
397:             * @see javax.servlet.ServletRequest#getLocale()
398:             */
399:            public Locale getLocale() {
400:                return null;
401:            }
402:
403:            /**
404:             * @see javax.servlet.ServletRequest#getLocales()
405:             */
406:            public Enumeration getLocales() {
407:                return null;
408:            }
409:
410:            /**
411:             * @see javax.servlet.ServletRequest#isSecure()
412:             */
413:            public boolean isSecure() {
414:                return false;
415:            }
416:
417:            /**
418:             * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
419:             */
420:            public RequestDispatcher getRequestDispatcher(String arg0) {
421:                return null;
422:            }
423:
424:            /**
425:             * @see javax.servlet.ServletRequest#getRealPath(String)
426:             * @deprecated
427:             */
428:            public String getRealPath(String arg0) {
429:                return null;
430:            }
431:
432:            /**
433:             *
434:             *
435:             *
436:             *
437:             */
438:            private static class MyServletInputStream extends
439:                    javax.servlet.ServletInputStream {
440:                private final InputStream in;
441:
442:                /**
443:                 * Creates a new instance, which returns the given
444:                 * streams data.
445:                 */
446:                public MyServletInputStream(InputStream pStream) {
447:                    in = pStream;
448:                }
449:
450:                public int read() throws IOException {
451:                    return in.read();
452:                }
453:            }
454:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.