public class MockPageContext
extends javax.servlet.jsp.PageContext
Mock ServletContext object for low-level unit tests of Struts controller components. Coarser grained tests should be implemented in terms of the Cactus framework, instead of the mock object classes.
WARNING - Only the minimal set of methods needed to
create unit tests is provided, plus additional methods to configure this
object as necessary. Methods for unsupported operations will throw
UnsupportedOperationException.
WARNING - Because unit tests operate in a single threaded environment, no synchronization is performed.
| Modifier and Type | Field and Description |
|---|---|
protected javax.servlet.ServletContext |
application |
protected java.util.HashMap |
attributes |
protected javax.servlet.ServletConfig |
config |
protected javax.servlet.ServletRequest |
request |
protected javax.servlet.ServletResponse |
response |
protected javax.servlet.http.HttpSession |
session |
| Constructor and Description |
|---|
MockPageContext() |
MockPageContext(boolean throwIOException,
boolean returnBody)
Construct a new PageContext impl.
|
MockPageContext(javax.servlet.ServletConfig config,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
| Modifier and Type | Method and Description |
|---|---|
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()
Custom JspWriter that throws the specified exception (supplied on
the constructor...if any), else it simply returns.
|
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 e) |
void |
handlePageException(java.lang.Throwable t) |
void |
include(java.lang.String path) |
void |
include(java.lang.String relativeUrlPath,
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() |
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 |
setValues(javax.servlet.ServletConfig config,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response) |
protected javax.servlet.ServletContext application
protected java.util.HashMap attributes
protected javax.servlet.ServletConfig config
protected javax.servlet.ServletRequest request
protected javax.servlet.ServletResponse response
protected javax.servlet.http.HttpSession session
public MockPageContext()
public MockPageContext(javax.servlet.ServletConfig config,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
public MockPageContext(boolean throwIOException,
boolean returnBody)
Construct a new PageContext impl.
throwIOException - Determines if the returned JspWriter should
throw an IOException on any method call.returnBody - Determines if getOut() should return a new
JspWriter or a BodyContent.public void setValues(javax.servlet.ServletConfig config,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
public java.lang.Object findAttribute(java.lang.String name)
findAttribute in class javax.servlet.jsp.JspContextpublic void forward(java.lang.String path)
forward in class javax.servlet.jsp.PageContextpublic java.lang.Object getAttribute(java.lang.String name)
getAttribute in class javax.servlet.jsp.JspContextpublic java.lang.Object getAttribute(java.lang.String name,
int scope)
getAttribute in class javax.servlet.jsp.JspContextpublic java.util.Enumeration getAttributeNamesInScope(int scope)
getAttributeNamesInScope in class javax.servlet.jsp.JspContextpublic int getAttributesScope(java.lang.String name)
getAttributesScope in class javax.servlet.jsp.JspContextpublic java.lang.Exception getException()
getException in class javax.servlet.jsp.PageContextpublic javax.servlet.jsp.JspWriter getOut()
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.
getOut in class javax.servlet.jsp.JspContextpublic java.lang.Object getPage()
getPage in class javax.servlet.jsp.PageContextpublic javax.servlet.ServletRequest getRequest()
getRequest in class javax.servlet.jsp.PageContextpublic javax.servlet.ServletResponse getResponse()
getResponse in class javax.servlet.jsp.PageContextpublic javax.servlet.ServletConfig getServletConfig()
getServletConfig in class javax.servlet.jsp.PageContextpublic javax.servlet.ServletContext getServletContext()
getServletContext in class javax.servlet.jsp.PageContextpublic javax.servlet.http.HttpSession getSession()
getSession in class javax.servlet.jsp.PageContextpublic void handlePageException(java.lang.Exception e)
handlePageException in class javax.servlet.jsp.PageContextpublic void handlePageException(java.lang.Throwable t)
handlePageException in class javax.servlet.jsp.PageContextpublic void include(java.lang.String path)
include in class javax.servlet.jsp.PageContextpublic void include(java.lang.String relativeUrlPath,
boolean flush)
include in class javax.servlet.jsp.PageContextpublic javax.servlet.jsp.el.VariableResolver getVariableResolver()
getVariableResolver in class javax.servlet.jsp.JspContextpublic javax.el.ELContext getELContext()
getELContext in class javax.servlet.jsp.JspContextpublic javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator()
getExpressionEvaluator in class javax.servlet.jsp.JspContextpublic void initialize(javax.servlet.Servlet servlet,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
java.lang.String errorPageURL,
boolean needsSession,
int bufferSize,
boolean autoFlush)
initialize in class javax.servlet.jsp.PageContextpublic javax.servlet.jsp.JspWriter popBody()
popBody in class javax.servlet.jsp.JspContextpublic javax.servlet.jsp.tagext.BodyContent pushBody()
pushBody in class javax.servlet.jsp.PageContextpublic void release()
release in class javax.servlet.jsp.PageContextpublic void removeAttribute(java.lang.String name)
removeAttribute in class javax.servlet.jsp.JspContextpublic void removeAttribute(java.lang.String name,
int scope)
removeAttribute in class javax.servlet.jsp.JspContextpublic void setAttribute(java.lang.String name,
java.lang.Object value)
setAttribute in class javax.servlet.jsp.JspContextpublic void setAttribute(java.lang.String name,
java.lang.Object value,
int scope)
setAttribute in class javax.servlet.jsp.JspContextCopyright © 2000–2025 Apache Software Foundation. All rights reserved.