org.jboss.jsfunit.context
Class JSFUnitDelegatingExternalContext

java.lang.Object
  extended by javax.faces.context.ExternalContext
      extended by org.jboss.jsfunit.context.JSFUnitDelegatingExternalContext

public class JSFUnitDelegatingExternalContext
extends javax.faces.context.ExternalContext

This ExternalContext will delegate everything to the real ExternalContext except for the getSession() method. For that, it will return a JSFUnitHttpSession that protects JSFUnit's session attributes.

Since:
1.0
Author:
Stan Silvert

Field Summary
 
Fields inherited from class javax.faces.context.ExternalContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Method Summary
 void addResponseCookie(String name, String value, Map<String,Object> properties)
           
 void addResponseHeader(String name, String value)
           
 void dispatch(String path)
           
 String encodeActionURL(String url)
           
 String encodeBookmarkableURL(String baseUrl, Map<String,List<String>> parameters)
           
 String encodeNamespace(String name)
           
 String encodePartialActionURL(String url)
           
 String encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
           
 String encodeResourceURL(String url)
           
 Map<String,Object> getApplicationMap()
           
 String getAuthType()
           
 Object getContext()
           
 String getContextName()
           
 javax.faces.context.Flash getFlash()
           
 String getInitParameter(String name)
           
 Map getInitParameterMap()
           
 String getMimeType(String file)
           
 String getRealPath(String path)
           
 String getRemoteUser()
           
 Object getRequest()
           
 String getRequestCharacterEncoding()
           
 int getRequestContentLength()
           
 String getRequestContentType()
           
 String getRequestContextPath()
           
 Map<String,Object> getRequestCookieMap()
           
 Map<String,String> getRequestHeaderMap()
           
 Map<String,String[]> getRequestHeaderValuesMap()
           
 Locale getRequestLocale()
           
 Iterator<Locale> getRequestLocales()
           
 Map<String,Object> getRequestMap()
           
 Map<String,String> getRequestParameterMap()
           
 Iterator<String> getRequestParameterNames()
           
 Map<String,String[]> getRequestParameterValuesMap()
           
 String getRequestPathInfo()
           
 String getRequestScheme()
           
 String getRequestServerName()
           
 int getRequestServerPort()
           
 String getRequestServletPath()
           
 URL getResource(String path)
           
 InputStream getResourceAsStream(String path)
           
 Set<String> getResourcePaths(String path)
           
 Object getResponse()
           
 int getResponseBufferSize()
           
 String getResponseCharacterEncoding()
           
 String getResponseContentType()
           
 OutputStream getResponseOutputStream()
           
 Writer getResponseOutputWriter()
           
 Object getSession(boolean create)
          Return a JSFUnitHttpSession.
 Map<String,Object> getSessionMap()
           
 Principal getUserPrincipal()
           
 void invalidateSession()
          Invalidate the session.
 boolean isResponseCommitted()
           
 boolean isUserInRole(String role)
           
 void log(String message)
           
 void log(String message, Throwable exception)
           
 void redirect(String url)
           
 void responseFlushBuffer()
           
 void responseReset()
           
 void responseSendError(int statusCode, String message)
           
 void setRequest(Object request)
           
 void setRequestCharacterEncoding(String encoding)
           
 void setResponse(Object response)
           
 void setResponseBufferSize(int size)
           
 void setResponseCharacterEncoding(String encoding)
           
 void setResponseContentLength(int length)
           
 void setResponseContentType(String contentType)
           
 void setResponseHeader(String name, String value)
           
 void setResponseStatus(int statusCode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUserPrincipal

public Principal getUserPrincipal()
Specified by:
getUserPrincipal in class javax.faces.context.ExternalContext

getSessionMap

public Map<String,Object> getSessionMap()
Specified by:
getSessionMap in class javax.faces.context.ExternalContext

getResponse

public Object getResponse()
Specified by:
getResponse in class javax.faces.context.ExternalContext

getRequestCookieMap

public Map<String,Object> getRequestCookieMap()
Specified by:
getRequestCookieMap in class javax.faces.context.ExternalContext

getRequestContextPath

public String getRequestContextPath()
Specified by:
getRequestContextPath in class javax.faces.context.ExternalContext

getRequest

public Object getRequest()
Specified by:
getRequest in class javax.faces.context.ExternalContext

getRemoteUser

public String getRemoteUser()
Specified by:
getRemoteUser in class javax.faces.context.ExternalContext

getInitParameterMap

public Map getInitParameterMap()
Specified by:
getInitParameterMap in class javax.faces.context.ExternalContext

getContext

public Object getContext()
Specified by:
getContext in class javax.faces.context.ExternalContext

getAuthType

public String getAuthType()
Specified by:
getAuthType in class javax.faces.context.ExternalContext

getApplicationMap

public Map<String,Object> getApplicationMap()
Specified by:
getApplicationMap in class javax.faces.context.ExternalContext

getRequestHeaderMap

public Map<String,String> getRequestHeaderMap()
Specified by:
getRequestHeaderMap in class javax.faces.context.ExternalContext

getRequestHeaderValuesMap

public Map<String,String[]> 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<Locale> getRequestLocales()
Specified by:
getRequestLocales in class javax.faces.context.ExternalContext

getRequestMap

public Map<String,Object> getRequestMap()
Specified by:
getRequestMap in class javax.faces.context.ExternalContext

getRequestParameterMap

public Map<String,String> getRequestParameterMap()
Specified by:
getRequestParameterMap in class javax.faces.context.ExternalContext

getRequestParameterNames

public Iterator<String> getRequestParameterNames()
Specified by:
getRequestParameterNames in class javax.faces.context.ExternalContext

getRequestParameterValuesMap

public Map<String,String[]> 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

getSession

public Object getSession(boolean create)
Return a JSFUnitHttpSession.

Specified by:
getSession in class javax.faces.context.ExternalContext
Parameters:
create - See superclass description.
Returns:
A JSFUnitHttpSession or null if create is false and there is no current session.

redirect

public void redirect(String url)
              throws IOException
Specified by:
redirect in class javax.faces.context.ExternalContext
Throws:
IOException

log

public void log(String message)
Specified by:
log in class javax.faces.context.ExternalContext

isUserInRole

public boolean isUserInRole(String role)
Specified by:
isUserInRole in class javax.faces.context.ExternalContext

getResourcePaths

public Set<String> getResourcePaths(String path)
Specified by:
getResourcePaths in class javax.faces.context.ExternalContext

getInitParameter

public String getInitParameter(String name)
Specified by:
getInitParameter in class javax.faces.context.ExternalContext

encodeResourceURL

public String encodeResourceURL(String url)
Specified by:
encodeResourceURL in class javax.faces.context.ExternalContext

encodeNamespace

public String encodeNamespace(String name)
Specified by:
encodeNamespace in class javax.faces.context.ExternalContext

encodeActionURL

public String encodeActionURL(String url)
Specified by:
encodeActionURL in class javax.faces.context.ExternalContext

dispatch

public void dispatch(String path)
              throws IOException
Specified by:
dispatch in class javax.faces.context.ExternalContext
Throws:
IOException

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

log

public void log(String message,
                Throwable exception)
Specified by:
log in class javax.faces.context.ExternalContext

getResponseContentType

public String getResponseContentType()
Overrides:
getResponseContentType in class javax.faces.context.ExternalContext

getResponseCharacterEncoding

public String getResponseCharacterEncoding()
Overrides:
getResponseCharacterEncoding in class javax.faces.context.ExternalContext

getRequestContentType

public String getRequestContentType()
Overrides:
getRequestContentType in class javax.faces.context.ExternalContext

getRequestCharacterEncoding

public String getRequestCharacterEncoding()
Overrides:
getRequestCharacterEncoding in class javax.faces.context.ExternalContext

setResponse

public void setResponse(Object response)
Overrides:
setResponse in class javax.faces.context.ExternalContext

setRequest

public void setRequest(Object request)
Overrides:
setRequest in class javax.faces.context.ExternalContext

setResponseCharacterEncoding

public void setResponseCharacterEncoding(String encoding)
Overrides:
setResponseCharacterEncoding in class javax.faces.context.ExternalContext

setRequestCharacterEncoding

public void setRequestCharacterEncoding(String encoding)
                                 throws UnsupportedEncodingException
Overrides:
setRequestCharacterEncoding in class javax.faces.context.ExternalContext
Throws:
UnsupportedEncodingException

addResponseCookie

public void addResponseCookie(String name,
                              String value,
                              Map<String,Object> properties)
Overrides:
addResponseCookie in class javax.faces.context.ExternalContext

getContextName

public String getContextName()
Overrides:
getContextName in class javax.faces.context.ExternalContext

getMimeType

public String getMimeType(String file)
Overrides:
getMimeType in class javax.faces.context.ExternalContext

getRealPath

public String getRealPath(String path)
Overrides:
getRealPath in class javax.faces.context.ExternalContext

getRequestContentLength

public int getRequestContentLength()
Overrides:
getRequestContentLength in class javax.faces.context.ExternalContext

getRequestScheme

public String getRequestScheme()
Overrides:
getRequestScheme in class javax.faces.context.ExternalContext

getRequestServerName

public String getRequestServerName()
Overrides:
getRequestServerName in class javax.faces.context.ExternalContext

getRequestServerPort

public int getRequestServerPort()
Overrides:
getRequestServerPort in class javax.faces.context.ExternalContext

getResponseOutputStream

public OutputStream getResponseOutputStream()
                                     throws IOException
Overrides:
getResponseOutputStream in class javax.faces.context.ExternalContext
Throws:
IOException

invalidateSession

public void invalidateSession()
Invalidate the session. This does not actually destroy the session. It leaves the session intact and removes all elements except those used by the JSFUnit framework.

Overrides:
invalidateSession in class javax.faces.context.ExternalContext

setResponseContentType

public void setResponseContentType(String contentType)
Overrides:
setResponseContentType in class javax.faces.context.ExternalContext

addResponseHeader

public void addResponseHeader(String name,
                              String value)
Overrides:
addResponseHeader in class javax.faces.context.ExternalContext

setResponseHeader

public void setResponseHeader(String name,
                              String value)
Overrides:
setResponseHeader in class javax.faces.context.ExternalContext

encodeBookmarkableURL

public String encodeBookmarkableURL(String baseUrl,
                                    Map<String,List<String>> parameters)
Overrides:
encodeBookmarkableURL in class javax.faces.context.ExternalContext

encodePartialActionURL

public String encodePartialActionURL(String url)
Overrides:
encodePartialActionURL in class javax.faces.context.ExternalContext

encodeRedirectURL

public String encodeRedirectURL(String baseUrl,
                                Map<String,List<String>> parameters)
Overrides:
encodeRedirectURL in class javax.faces.context.ExternalContext

getFlash

public javax.faces.context.Flash getFlash()
Overrides:
getFlash in class javax.faces.context.ExternalContext

getResponseBufferSize

public int getResponseBufferSize()
Overrides:
getResponseBufferSize in class javax.faces.context.ExternalContext

getResponseOutputWriter

public Writer getResponseOutputWriter()
                               throws IOException
Overrides:
getResponseOutputWriter in class javax.faces.context.ExternalContext
Throws:
IOException

isResponseCommitted

public boolean isResponseCommitted()
Overrides:
isResponseCommitted in class javax.faces.context.ExternalContext

responseFlushBuffer

public void responseFlushBuffer()
                         throws IOException
Overrides:
responseFlushBuffer in class javax.faces.context.ExternalContext
Throws:
IOException

responseReset

public void responseReset()
Overrides:
responseReset in class javax.faces.context.ExternalContext

responseSendError

public void responseSendError(int statusCode,
                              String message)
                       throws IOException
Overrides:
responseSendError in class javax.faces.context.ExternalContext
Throws:
IOException

setResponseBufferSize

public void setResponseBufferSize(int size)
Overrides:
setResponseBufferSize in class javax.faces.context.ExternalContext

setResponseContentLength

public void setResponseContentLength(int length)
Overrides:
setResponseContentLength in class javax.faces.context.ExternalContext

setResponseStatus

public void setResponseStatus(int statusCode)
Overrides:
setResponseStatus in class javax.faces.context.ExternalContext


Copyright © 2007-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.