com.mockrunner.mock.web
Class MockPageContext

java.lang.Object
  extended by javax.servlet.jsp.JspContext
      extended by javax.servlet.jsp.PageContext
          extended by com.mockrunner.mock.web.MockPageContext

public class MockPageContext
extends javax.servlet.jsp.PageContext

Mock implementation of PageContext. Please note that EL support using the the Unified Expression Language API is only available, if the JasperJspFactory is configured as the default JspFactory. By default, getELContext() returns null.


Field Summary
protected  javax.servlet.ServletConfig config
           
protected  javax.servlet.ServletRequest request
           
protected  javax.servlet.ServletResponse response
           
 
Fields inherited from class javax.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
 
Constructor Summary
MockPageContext()
           
MockPageContext(javax.servlet.ServletConfig config, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
           
 
Method Summary
 java.lang.Object findAttribute(java.lang.String name)
           
 void forward(java.lang.String path)
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.lang.Object getAttribute(java.lang.String name, int scope)
           
 java.util.Enumeration getAttributeNamesInScope(int scope)
           
 int getAttributesScope(java.lang.String name)
           
 javax.el.ELContext getELContext()
           
 java.lang.Exception getException()
           
 javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator()
           
 javax.servlet.jsp.JspWriter getOut()
           
 java.lang.Object getPage()
           
 javax.servlet.ServletRequest getRequest()
           
 javax.servlet.ServletResponse getResponse()
           
 javax.servlet.ServletConfig getServletConfig()
           
 javax.servlet.ServletContext getServletContext()
           
 javax.servlet.http.HttpSession getSession()
           
 javax.servlet.jsp.el.VariableResolver getVariableResolver()
           
 void handlePageException(java.lang.Exception exc)
           
 void handlePageException(java.lang.Throwable thr)
           
 void include(java.lang.String path)
           
 void include(java.lang.String path, boolean flush)
           
 void initialize(javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
           
 javax.servlet.jsp.JspWriter popBody()
           
 javax.servlet.jsp.tagext.BodyContent pushBody()
           
 javax.servlet.jsp.JspWriter pushBody(java.io.Writer writer)
           
 void release()
           
 void removeAttribute(java.lang.String name)
           
 void removeAttribute(java.lang.String name, int scope)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setAttribute(java.lang.String name, java.lang.Object value, int scope)
           
 void setELContext(javax.el.ELContext elContext)
          Sets the ELContext.
 void setException(java.lang.Exception exception)
           
 void setExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator evaluator)
          Sets the expression evaluator.
 void setJspWriter(javax.servlet.jsp.JspWriter jspWriter)
          This method allows to set custom implementations of JspWriter.
 void setPage(java.lang.Object page)
           
 void setServletConfig(javax.servlet.ServletConfig config)
          Sets the ServletConfig.
 void setServletRequest(javax.servlet.ServletRequest request)
          Sets the ServletRequest.
 void setServletResponse(javax.servlet.ServletResponse response)
          Sets the ServletResponse.
 void setVariableResolver(javax.servlet.jsp.el.VariableResolver resolver)
          Sets the variable resolver.
 
Methods inherited from class javax.servlet.jsp.PageContext
getErrorData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

protected javax.servlet.ServletConfig config

request

protected javax.servlet.ServletRequest request

response

protected javax.servlet.ServletResponse response
Constructor Detail

MockPageContext

public MockPageContext()

MockPageContext

public MockPageContext(javax.servlet.ServletConfig config,
                       javax.servlet.ServletRequest request,
                       javax.servlet.ServletResponse response)
Method Detail

setJspWriter

public void setJspWriter(javax.servlet.jsp.JspWriter jspWriter)
This method allows to set custom implementations of JspWriter. Per default, MockJspWriter is used.

Parameters:
jspWriter - the JspWriter

setPage

public void setPage(java.lang.Object page)

setServletConfig

public void setServletConfig(javax.servlet.ServletConfig config)
Sets the ServletConfig.

Parameters:
config - the ServletConfig

setServletRequest

public void setServletRequest(javax.servlet.ServletRequest request)
Sets the ServletRequest.

Parameters:
request - the ServletRequest

setServletResponse

public void setServletResponse(javax.servlet.ServletResponse response)
Sets the ServletResponse.

Parameters:
response - the ServletResponse

setException

public void setException(java.lang.Exception exception)

findAttribute

public java.lang.Object findAttribute(java.lang.String name)
Specified by:
findAttribute in class javax.servlet.jsp.JspContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in class javax.servlet.jsp.JspContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Specified by:
getAttribute in class javax.servlet.jsp.JspContext

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in class javax.servlet.jsp.JspContext

removeAttribute

public void removeAttribute(java.lang.String name,
                            int scope)
Specified by:
removeAttribute in class javax.servlet.jsp.JspContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in class javax.servlet.jsp.JspContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value,
                         int scope)
Specified by:
setAttribute in class javax.servlet.jsp.JspContext

getAttributesScope

public int getAttributesScope(java.lang.String name)
Specified by:
getAttributesScope in class javax.servlet.jsp.JspContext

getAttributeNamesInScope

public java.util.Enumeration getAttributeNamesInScope(int scope)
Specified by:
getAttributeNamesInScope in class javax.servlet.jsp.JspContext

getOut

public javax.servlet.jsp.JspWriter getOut()
Specified by:
getOut in class javax.servlet.jsp.JspContext

getException

public java.lang.Exception getException()
Specified by:
getException in class javax.servlet.jsp.PageContext

getPage

public java.lang.Object getPage()
Specified by:
getPage in class javax.servlet.jsp.PageContext

getRequest

public javax.servlet.ServletRequest getRequest()
Specified by:
getRequest in class javax.servlet.jsp.PageContext

getResponse

public javax.servlet.ServletResponse getResponse()
Specified by:
getResponse in class javax.servlet.jsp.PageContext

getServletConfig

public javax.servlet.ServletConfig getServletConfig()
Specified by:
getServletConfig in class javax.servlet.jsp.PageContext

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in class javax.servlet.jsp.PageContext

getSession

public javax.servlet.http.HttpSession getSession()
Specified by:
getSession in class javax.servlet.jsp.PageContext

handlePageException

public void handlePageException(java.lang.Exception exc)
Specified by:
handlePageException in class javax.servlet.jsp.PageContext

handlePageException

public void handlePageException(java.lang.Throwable thr)
Specified by:
handlePageException in class javax.servlet.jsp.PageContext

forward

public void forward(java.lang.String path)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
forward in class javax.servlet.jsp.PageContext
Throws:
javax.servlet.ServletException
java.io.IOException

include

public void include(java.lang.String path)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
include in class javax.servlet.jsp.PageContext
Throws:
javax.servlet.ServletException
java.io.IOException

include

public void include(java.lang.String path,
                    boolean flush)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
include in class javax.servlet.jsp.PageContext
Throws:
javax.servlet.ServletException
java.io.IOException

initialize

public void initialize(javax.servlet.Servlet servlet,
                       javax.servlet.ServletRequest request,
                       javax.servlet.ServletResponse response,
                       java.lang.String errorPageURL,
                       boolean needsSession,
                       int bufferSize,
                       boolean autoFlush)
Specified by:
initialize in class javax.servlet.jsp.PageContext

popBody

public javax.servlet.jsp.JspWriter popBody()
Overrides:
popBody in class javax.servlet.jsp.JspContext

pushBody

public javax.servlet.jsp.tagext.BodyContent pushBody()
Overrides:
pushBody in class javax.servlet.jsp.PageContext

pushBody

public javax.servlet.jsp.JspWriter pushBody(java.io.Writer writer)
Overrides:
pushBody in class javax.servlet.jsp.JspContext

release

public void release()
Specified by:
release in class javax.servlet.jsp.PageContext

setExpressionEvaluator

public void setExpressionEvaluator(javax.servlet.jsp.el.ExpressionEvaluator evaluator)
Sets the expression evaluator. The default expression evaluator is MockExpressionEvaluator.

Parameters:
evaluator - the ExpressionEvaluator

setVariableResolver

public void setVariableResolver(javax.servlet.jsp.el.VariableResolver resolver)
Sets the variable resolver. The default variable resolver is MockVariableResolver.

Parameters:
resolver - the VariableResolver

setELContext

public void setELContext(javax.el.ELContext elContext)
Sets the ELContext. There is no default ELContext. Configure the JasperJspFactory to set one.

Parameters:
elContext - the ELContext

getExpressionEvaluator

public javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator()
Specified by:
getExpressionEvaluator in class javax.servlet.jsp.JspContext

getVariableResolver

public javax.servlet.jsp.el.VariableResolver getVariableResolver()
Specified by:
getVariableResolver in class javax.servlet.jsp.JspContext

getELContext

public javax.el.ELContext getELContext()
Specified by:
getELContext in class javax.servlet.jsp.JspContext