1 16 package org.apache.myfaces.context.servlet; 17 18 import org.apache.myfaces.util.IteratorEnumeration; 19 20 import javax.servlet.RequestDispatcher ; 21 import javax.servlet.ServletInputStream ; 22 import javax.servlet.http.Cookie ; 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpSession ; 25 import java.io.BufferedReader ; 26 import java.io.IOException ; 27 import java.io.UnsupportedEncodingException ; 28 import java.security.Principal ; 29 import java.util.*; 30 31 36 public class ServletRequestMockImpl 37 implements HttpServletRequest 38 { 39 40 private static final Locale[] LOCALES = {Locale.US, Locale.GERMAN}; 41 42 private Map _attributes = new HashMap(); 43 private Cookie [] _cookies; 44 private String _servletPath = "/myfaces"; 45 private String _pathInfo = ""; 46 47 private HttpSession _session; 48 49 public ServletRequestMockImpl(Cookie [] cookies) 50 { 51 _cookies = cookies; 52 } 53 54 public String getAuthType() 55 { 56 throw new UnsupportedOperationException (); 57 } 58 59 public Cookie [] getCookies() 60 { 61 return _cookies; 62 } 63 64 public long getDateHeader(String name) 65 { 66 throw new UnsupportedOperationException (); 67 } 68 69 public String getHeader(String name) 70 { 71 throw new UnsupportedOperationException (); 72 } 73 74 public Enumeration getHeaders(String name) 75 { 76 throw new UnsupportedOperationException (); 77 } 78 79 public Enumeration getHeaderNames() 80 { 81 throw new UnsupportedOperationException (); 82 } 83 84 public int getIntHeader(String name) 85 { 86 throw new UnsupportedOperationException (); 87 } 88 89 public String getMethod() 90 { 91 throw new UnsupportedOperationException (); 92 } 93 94 public String getPathInfo() 95 { 96 return _pathInfo; 97 } 98 99 public String getPathTranslated() 100 { 101 throw new UnsupportedOperationException (); 102 } 103 104 public String getContextPath() 105 { 106 throw new UnsupportedOperationException (); 107 } 108 109 public String getQueryString() 110 { 111 throw new UnsupportedOperationException (); 112 } 113 114 public String getRemoteUser() 115 { 116 throw new UnsupportedOperationException (); 117 } 118 119 public boolean isUserInRole(String name) 120 { 121 throw new UnsupportedOperationException (); 122 } 123 124 public Principal getUserPrincipal() 125 { 126 throw new UnsupportedOperationException (); 127 } 128 129 public String getRequestedSessionId() 130 { 131 throw new UnsupportedOperationException (); 132 } 133 134 public String getRequestURI() 135 { 136 throw new UnsupportedOperationException (); 137 } 138 139 public StringBuffer getRequestURL() 140 { 141 throw new UnsupportedOperationException (); 142 } 143 144 public String getServletPath() 145 { 146 return _servletPath; 147 } 148 149 public HttpSession getSession(boolean b) 150 { 151 if (b && _session == null) 152 { 153 _session = new ServletSessionMock(); 154 } 155 return _session; 156 } 157 158 public HttpSession getSession() 159 { 160 return null; 161 } 162 163 public boolean isRequestedSessionIdValid() 164 { 165 throw new UnsupportedOperationException (); 166 } 167 168 public boolean isRequestedSessionIdFromCookie() 169 { 170 throw new UnsupportedOperationException (); 171 } 172 173 public boolean isRequestedSessionIdFromURL() 174 { 175 throw new UnsupportedOperationException (); 176 } 177 178 public boolean isRequestedSessionIdFromUrl() 179 { 180 throw new UnsupportedOperationException (); 181 } 182 183 public Object getAttribute(String 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 getCharacterEncoding() 194 { 195 throw new UnsupportedOperationException (); 196 } 197 198 public void setCharacterEncoding(String name) throws UnsupportedEncodingException 199 { 200 throw new UnsupportedOperationException (); 201 } 202 203 public int getContentLength() 204 { 205 throw new UnsupportedOperationException (); 206 } 207 208 public String getContentType() 209 { 210 throw new UnsupportedOperationException (); 211 } 212 213 public ServletInputStream getInputStream() throws IOException 214 { 215 throw new UnsupportedOperationException (); 216 } 217 218 public String getParameter(String name) 219 { 220 throw new UnsupportedOperationException (); 221 } 222 223 public Enumeration getParameterNames() 224 { 225 throw new UnsupportedOperationException (); 226 } 227 228 public String [] getParameterValues(String name) 229 { 230 throw new UnsupportedOperationException (); 231 } 232 233 public Map getParameterMap() 234 { 235 throw new UnsupportedOperationException (); 236 } 237 238 public String getProtocol() 239 { 240 throw new UnsupportedOperationException (); 241 } 242 243 public String getScheme() 244 { 245 throw new UnsupportedOperationException (); 246 } 247 248 public String getServerName() 249 { 250 throw new UnsupportedOperationException (); 251 } 252 253 public int getServerPort() 254 { 255 throw new UnsupportedOperationException (); 256 } 257 258 public BufferedReader getReader() throws IOException 259 { 260 throw new UnsupportedOperationException (); 261 } 262 263 public String getRemoteAddr() 264 { 265 throw new UnsupportedOperationException (); 266 } 267 268 public String getRemoteHost() 269 { 270 throw new UnsupportedOperationException (); 271 } 272 273 public void setAttribute(String name, Object o) 274 { 275 _attributes.put(name, o); 276 } 277 278 public void removeAttribute(String 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 (); 296 } 297 298 public RequestDispatcher getRequestDispatcher(String name) 299 { 300 throw new UnsupportedOperationException (); 301 } 302 303 public String getRealPath(String name) 304 { 305 throw new UnsupportedOperationException (); 306 } 307 308 public int getRemotePort() 309 { 310 throw new UnsupportedOperationException (); 311 } 312 313 public String getLocalName() 314 { 315 throw new UnsupportedOperationException (); 316 } 317 318 public String getLocalAddr() 319 { 320 throw new UnsupportedOperationException (); 321 } 322 323 public int getLocalPort() 324 { 325 throw new UnsupportedOperationException (); 326 } 327 328 329 330 331 333 public void setServletPath(String servletPath) 334 { 335 _servletPath = servletPath; 336 } 337 338 public void setPathInfo(String pathInfo) 339 { 340 _pathInfo = pathInfo; 341 } 342 343 } 344 | Popular Tags |