org.apache.myfaces.test.mock
Class MockExternalContext

java.lang.Object
  extended by javax.faces.context.ExternalContext
      extended by org.apache.myfaces.test.mock.MockExternalContext
Direct Known Subclasses:
MockExternalContext12

public class MockExternalContext
extends javax.faces.context.ExternalContext

Mock implementation of ExternalContext.

$Id$

Since:
1.0.0

Field Summary
protected  javax.servlet.ServletContext context
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
 
Fields inherited from class javax.faces.context.ExternalContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
MockExternalContext(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Construct a wrapper instance.
 
Method Summary
 void addRequestCookieMap(javax.servlet.http.Cookie cookie)
          Add a new cookie for this request.
 void addRequestHeader(String key, String value)
          Add the specified request header for this request.
 void addRequestParameterMap(String key, String value)
          Add the specified request parameter for this request.
 void dispatch(String requestURI)
          
 String encodeActionURL(String sb)
          
 String encodeNamespace(String aValue)
          
 String encodeResourceURL(String sb)
          
 Map getApplicationMap()
          
 String getAuthType()
          
 Object getContext()
          
 String getInitParameter(String name)
          
 Map getInitParameterMap()
          
 String getRemoteUser()
          
 Object getRequest()
          
 String getRequestContextPath()
          
 Map getRequestCookieMap()
          
 Map getRequestHeaderMap()
          
 Map getRequestHeaderValuesMap()
          
 Locale getRequestLocale()
          
 Iterator getRequestLocales()
          
 Map getRequestMap()
          
 Map getRequestParameterMap()
          
 Iterator getRequestParameterNames()
          
 Map getRequestParameterValuesMap()
          
 String getRequestPathInfo()
          
 String getRequestServletPath()
          
 URL getResource(String path)
          
 InputStream getResourceAsStream(String path)
          
 Set getResourcePaths(String path)
          
 Object getResponse()
          
 Object getSession(boolean create)
          
 Map getSessionMap()
          
 Principal getUserPrincipal()
          
 boolean isUserInRole(String role)
          
 void log(String message)
          
 void log(String message, Throwable throwable)
          
 void redirect(String requestURI)
          
 void setRequestCookieMap(Map map)
          Set the request cookie map for this request.
 void setRequestHeaderMap(Map map)
          Set the request header map for this request.
 void setRequestParameterMap(Map map)
          Set the request parameter map for this request.
 
Methods inherited from class javax.faces.context.ExternalContext
addResponseCookie, addResponseHeader, encodeBookmarkableURL, encodePartialActionURL, encodeRedirectURL, getContextName, getFlash, getMimeType, getRealPath, getRequestCharacterEncoding, getRequestContentLength, getRequestContentType, getRequestScheme, getRequestServerName, getRequestServerPort, getResponseBufferSize, getResponseCharacterEncoding, getResponseContentType, getResponseOutputStream, getResponseOutputWriter, invalidateSession, isResponseCommitted, responseFlushBuffer, responseReset, responseSendError, setRequest, setRequestCharacterEncoding, setResponse, setResponseBufferSize, setResponseCharacterEncoding, setResponseContentLength, setResponseContentType, setResponseHeader, setResponseStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected javax.servlet.ServletContext context

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response
Constructor Detail

MockExternalContext

public MockExternalContext(javax.servlet.ServletContext context,
                           javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)

Construct a wrapper instance.

Parameters:
context - ServletContext for this application
request - HttpServetRequest for this request
response - HttpServletResponse for this request
Method Detail

addRequestCookieMap

public void addRequestCookieMap(javax.servlet.http.Cookie cookie)

Add a new cookie for this request.

Parameters:
cookie - The new cookie

setRequestCookieMap

public void setRequestCookieMap(Map map)

Set the request cookie map for this request.

Parameters:
map - The new request cookie map

addRequestParameterMap

public void addRequestParameterMap(String key,
                                   String value)

Add the specified request parameter for this request.

Parameters:
key - Parameter name
value - Parameter value

setRequestParameterMap

public void setRequestParameterMap(Map map)

Set the request parameter map for this request.

Parameters:
map - The new request parameter map

addRequestHeader

public void addRequestHeader(String key,
                             String value)

Add the specified request header for this request.

Parameters:
key - Parameter name
value - Parameter value

setRequestHeaderMap

public void setRequestHeaderMap(Map map)

Set the request header map for this request.

Parameters:
map - The new request header map

dispatch

public void dispatch(String requestURI)
              throws IOException,
                     javax.faces.FacesException

Specified by:
dispatch in class javax.faces.context.ExternalContext
Throws:
IOException
javax.faces.FacesException

encodeActionURL

public String encodeActionURL(String sb)

Specified by:
encodeActionURL in class javax.faces.context.ExternalContext

encodeNamespace

public String encodeNamespace(String aValue)

Specified by:
encodeNamespace in class javax.faces.context.ExternalContext

encodeResourceURL

public String encodeResourceURL(String sb)

Specified by:
encodeResourceURL in class javax.faces.context.ExternalContext

getApplicationMap

public Map getApplicationMap()

Specified by:
getApplicationMap in class javax.faces.context.ExternalContext

getAuthType

public String getAuthType()

Specified by:
getAuthType in class javax.faces.context.ExternalContext

getContext

public Object getContext()

Specified by:
getContext in class javax.faces.context.ExternalContext

getInitParameter

public String getInitParameter(String name)

Specified by:
getInitParameter in class javax.faces.context.ExternalContext

getInitParameterMap

public Map getInitParameterMap()

Specified by:
getInitParameterMap in class javax.faces.context.ExternalContext

getRemoteUser

public String getRemoteUser()

Specified by:
getRemoteUser in class javax.faces.context.ExternalContext

getRequest

public Object getRequest()

Specified by:
getRequest in class javax.faces.context.ExternalContext

getRequestContextPath

public String getRequestContextPath()

Specified by:
getRequestContextPath in class javax.faces.context.ExternalContext

getRequestCookieMap

public Map getRequestCookieMap()

Specified by:
getRequestCookieMap in class javax.faces.context.ExternalContext

getRequestHeaderMap

public Map getRequestHeaderMap()

Specified by:
getRequestHeaderMap in class javax.faces.context.ExternalContext

getRequestHeaderValuesMap

public Map getRequestHeaderValuesMap()

Specified by:
getRequestHeaderValuesMap in class javax.faces.context.ExternalContext

getRequestLocale

public Locale getRequestLocale()

Specified by:
getRequestLocale in class javax.faces.context.ExternalContext

getRequestLocales

public Iterator getRequestLocales()

Specified by:
getRequestLocales in class javax.faces.context.ExternalContext

getRequestMap

public Map getRequestMap()

Specified by:
getRequestMap in class javax.faces.context.ExternalContext

getRequestParameterMap

public Map getRequestParameterMap()

Specified by:
getRequestParameterMap in class javax.faces.context.ExternalContext

getRequestParameterNames

public Iterator getRequestParameterNames()

Specified by:
getRequestParameterNames in class javax.faces.context.ExternalContext

getRequestParameterValuesMap

public Map getRequestParameterValuesMap()

Specified by:
getRequestParameterValuesMap in class javax.faces.context.ExternalContext

getRequestPathInfo

public String getRequestPathInfo()

Specified by:
getRequestPathInfo in class javax.faces.context.ExternalContext

getRequestServletPath

public String getRequestServletPath()

Specified by:
getRequestServletPath in class javax.faces.context.ExternalContext

getResource

public URL getResource(String path)
                throws MalformedURLException

Specified by:
getResource in class javax.faces.context.ExternalContext
Throws:
MalformedURLException

getResourceAsStream

public InputStream getResourceAsStream(String path)

Specified by:
getResourceAsStream in class javax.faces.context.ExternalContext

getResourcePaths

public Set getResourcePaths(String path)

Specified by:
getResourcePaths in class javax.faces.context.ExternalContext

getResponse

public Object getResponse()

Specified by:
getResponse in class javax.faces.context.ExternalContext

getSession

public Object getSession(boolean create)

Specified by:
getSession in class javax.faces.context.ExternalContext

getSessionMap

public Map getSessionMap()

Specified by:
getSessionMap in class javax.faces.context.ExternalContext

getUserPrincipal

public Principal getUserPrincipal()

Specified by:
getUserPrincipal in class javax.faces.context.ExternalContext

isUserInRole

public boolean isUserInRole(String role)

Specified by:
isUserInRole in class javax.faces.context.ExternalContext

log

public void log(String message)

Specified by:
log in class javax.faces.context.ExternalContext

log

public void log(String message,
                Throwable throwable)

Specified by:
log in class javax.faces.context.ExternalContext

redirect

public void redirect(String requestURI)
              throws IOException

Specified by:
redirect in class javax.faces.context.ExternalContext
Throws:
IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.