1 5 package org.exoplatform.test.mocks.jsf; 6 7 import java.util.*; 8 import java.io.IOException ; 9 import java.io.InputStream ; 10 import java.net.MalformedURLException ; 11 import java.net.URL ; 12 import javax.faces.context.ExternalContext; 13 import javax.servlet.http.*; 14 import org.exoplatform.commons.map.*; 15 16 17 public class MockExternalContext extends ExternalContext { 18 protected HttpServletRequest request_ ; 19 protected HttpServletResponse response_ ; 20 protected Map requestMap_ ; 21 protected Map requestParameterMap_ ; 22 23 public void init(HttpServletRequest request, HttpServletResponse response) { 24 request_ = request ; 25 response_ = response ; 26 requestMap_ = null ; 27 requestParameterMap_ = null ; 28 } 29 30 public Object getSession( boolean create ) { return request_.getSession(create) ; } 31 32 public Object getContext() { return null ; } 33 34 public Object getRequest() { return request_ ; } 35 36 public Object getResponse() { return response_ ; } 37 38 public ResourceBundle getApplicationResourceBundle() { return null ; } 39 40 public String getInitParameter( String s ) { return null ; } 41 42 public Map getInitParameterMap() { return null ; } 43 44 public Map getApplicationMap() { return null ; } 45 46 public Map getSessionMap() { return null ; } 47 48 public Map getRequestMap() { 49 if(requestMap_ == null ) requestMap_ = new RequestMap(request_) ; 50 return requestMap_ ; 51 } 52 53 public Map getRequestParameterMap() { 54 if(requestParameterMap_ == null ) requestParameterMap_ = new RequestParameterMap(request_) ; 55 return requestParameterMap_ ; 56 } 57 58 public Map getRequestParameterValuesMap() { return null ; } 59 60 public Iterator getRequestParameterNames() { return null ; } 61 62 public Map getRequestHeaderMap() { return null ; } 63 64 public Map getRequestHeaderValuesMap() { return null ; } 65 66 public Map getRequestCookieMap() { return null ; } 67 68 public Locale getRequestLocale() { return null ; } 69 public Iterator getRequestLocales() { return null ; } 70 71 public String getRequestContextPath() { return null ; } 72 73 public String getRequestPathInfo() { return request_.getRequestURI() ; } 74 75 public Cookie[] getRequestCookies() { return null ; } 76 77 public Set getResourcePaths( String s ) { return null ; } 78 public InputStream getResourceAsStream( String s ) { return null ; } 79 80 public URL getResource( String s ) throws MalformedURLException { 81 return null ; 82 } 83 84 public String encodeActionURL( String s ) { return s ; } 85 86 public String encodeResourceURL( String s ) { return s; } 87 88 public String encodeURL( String s ) { return s ; } 89 90 public String encodeNamespace( String s ) { return s; } 91 92 public void dispatch( String requestURI ) throws IOException { 93 } 94 95 public void redirect( String sI ) throws IOException { 96 } 97 98 public void log(String message) { 99 System.out.println(message); 100 } 101 102 public void log(String message, Throwable throwable) { 103 System.out.println(message); 104 throwable.printStackTrace() ; 105 } 106 107 public String getRequestServletPath() { 108 throw new UnsupportedOperationException (); 109 } 110 111 public java.lang.String getAuthType() { return null ; } 112 113 public java.lang.String getRemoteUser() { return "anonymous" ; } 114 115 final public java.security.Principal getUserPrincipal() { return null ; } 116 117 final public boolean isUserInRole(java.lang.String role) { return false ; } 118 119 public void reset() { 120 } 121 } 122 | Popular Tags |