Package org.apache.struts.mock
Class MockPageContext
java.lang.Object
jakarta.servlet.jsp.JspContext
jakarta.servlet.jsp.PageContext
org.apache.struts.mock.MockPageContext
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.
- Version:
- $Rev$ $Date: 2005-05-07 12:45:39 -0400 (Sat, 07 May 2005) $
-
Field Summary
Modifier and TypeFieldDescriptionprotected ServletContext
protected ServletConfig
protected ServletRequest
protected ServletResponse
protected HttpSession
Fields inherited from class jakarta.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
-
Constructor Summary
ConstructorDescriptionMockPageContext
(boolean throwIOException, boolean returnBody) Construct a new PageContext impl.MockPageContext
(ServletConfig config, ServletRequest request, ServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptionfindAttribute
(String name) void
getAttribute
(String name) getAttribute
(String name, int scope) getAttributeNamesInScope
(int scope) int
getAttributesScope
(String name) Deprecated.getOut()
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.getPage()
Deprecated.void
void
void
void
void
initialize
(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) popBody()
pushBody()
void
release()
void
removeAttribute
(String name) void
removeAttribute
(String name, int scope) void
setAttribute
(String name, Object value) void
setAttribute
(String name, Object value, int scope) void
setValues
(ServletConfig config, ServletRequest request, ServletResponse response) Methods inherited from class jakarta.servlet.jsp.PageContext
getErrorData
Methods inherited from class jakarta.servlet.jsp.JspContext
pushBody
-
Field Details
-
application
-
attributes
-
config
-
request
-
response
-
session
-
-
Constructor Details
-
MockPageContext
public MockPageContext() -
MockPageContext
-
MockPageContext
public MockPageContext(boolean throwIOException, boolean returnBody) Construct a new PageContext impl.- Parameters:
throwIOException
- Determines if the returned JspWriter should throw an IOException on any method call.returnBody
- Determines if getOut() should return a newJspWriter
or aBodyContent
.
-
-
Method Details
-
setValues
-
setAttribute
- Specified by:
setAttribute
in classJspContext
-
setAttribute
- Specified by:
setAttribute
in classJspContext
-
getAttribute
- Specified by:
getAttribute
in classJspContext
-
getAttribute
- Specified by:
getAttribute
in classJspContext
-
findAttribute
- Specified by:
findAttribute
in classJspContext
-
removeAttribute
- Specified by:
removeAttribute
in classJspContext
-
removeAttribute
- Specified by:
removeAttribute
in classJspContext
-
getAttributesScope
- Specified by:
getAttributesScope
in classJspContext
-
getAttributeNamesInScope
- Specified by:
getAttributeNamesInScope
in classJspContext
-
getOut
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.- Specified by:
getOut
in classJspContext
-
getExpressionEvaluator
Deprecated.- Specified by:
getExpressionEvaluator
in classJspContext
-
getVariableResolver
Deprecated.- Specified by:
getVariableResolver
in classJspContext
-
getELContext
- Specified by:
getELContext
in classJspContext
-
pushBody
- Overrides:
pushBody
in classPageContext
-
popBody
- Overrides:
popBody
in classJspContext
-
initialize
public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) - Specified by:
initialize
in classPageContext
-
release
public void release()- Specified by:
release
in classPageContext
-
getSession
- Specified by:
getSession
in classPageContext
-
getPage
- Specified by:
getPage
in classPageContext
-
getRequest
- Specified by:
getRequest
in classPageContext
-
getResponse
- Specified by:
getResponse
in classPageContext
-
getException
- Specified by:
getException
in classPageContext
-
getServletConfig
- Specified by:
getServletConfig
in classPageContext
-
getServletContext
- Specified by:
getServletContext
in classPageContext
-
forward
- Specified by:
forward
in classPageContext
- Throws:
ServletException
IOException
-
include
- Specified by:
include
in classPageContext
- Throws:
ServletException
IOException
-
include
- Specified by:
include
in classPageContext
- Throws:
ServletException
IOException
-
handlePageException
- Specified by:
handlePageException
in classPageContext
- Throws:
ServletException
IOException
-
handlePageException
- Specified by:
handlePageException
in classPageContext
- Throws:
ServletException
IOException
-