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
FieldsModifier and TypeFieldDescriptionprotected ServletContextprotected ServletConfigprotected ServletRequestprotected ServletResponseprotected HttpSessionFields 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
ConstructorsConstructorDescriptionMockPageContext(boolean throwIOException, boolean returnBody) Construct a new PageContext impl.MockPageContext(ServletConfig config, ServletRequest request, ServletResponse response) -
Method Summary
Modifier and TypeMethodDescriptionfindAttribute(String name) voidgetAttribute(String name) getAttribute(String name, int scope) getAttributeNamesInScope(int scope) intgetAttributesScope(String name) Deprecated.getOut()Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.getPage()Deprecated.voidvoidvoidvoidvoidinitialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) popBody()pushBody()voidrelease()voidremoveAttribute(String name) voidremoveAttribute(String name, int scope) voidsetAttribute(String name, Object value) voidsetAttribute(String name, Object value, int scope) voidsetValues(ServletConfig config, ServletRequest request, ServletResponse response) Methods inherited from class jakarta.servlet.jsp.PageContext
getErrorDataMethods 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 newJspWriteror aBodyContent.
-
-
Method Details
-
setValues
-
setAttribute
- Specified by:
setAttributein classJspContext
-
setAttribute
- Specified by:
setAttributein classJspContext
-
getAttribute
- Specified by:
getAttributein classJspContext
-
getAttribute
- Specified by:
getAttributein classJspContext
-
findAttribute
- Specified by:
findAttributein classJspContext
-
removeAttribute
- Specified by:
removeAttributein classJspContext
-
removeAttribute
- Specified by:
removeAttributein classJspContext
-
getAttributesScope
- Specified by:
getAttributesScopein classJspContext
-
getAttributeNamesInScope
- Specified by:
getAttributeNamesInScopein classJspContext
-
getOut
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.- Specified by:
getOutin classJspContext
-
getExpressionEvaluator
Deprecated.- Specified by:
getExpressionEvaluatorin classJspContext
-
getVariableResolver
Deprecated.- Specified by:
getVariableResolverin classJspContext
-
getELContext
- Specified by:
getELContextin classJspContext
-
pushBody
- Overrides:
pushBodyin classPageContext
-
popBody
- Overrides:
popBodyin classJspContext
-
initialize
public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) - Specified by:
initializein classPageContext
-
release
public void release()- Specified by:
releasein classPageContext
-
getSession
- Specified by:
getSessionin classPageContext
-
getPage
- Specified by:
getPagein classPageContext
-
getRequest
- Specified by:
getRequestin classPageContext
-
getResponse
- Specified by:
getResponsein classPageContext
-
getException
- Specified by:
getExceptionin classPageContext
-
getServletConfig
- Specified by:
getServletConfigin classPageContext
-
getServletContext
- Specified by:
getServletContextin classPageContext
-
forward
- Specified by:
forwardin classPageContext- Throws:
ServletExceptionIOException
-
include
- Specified by:
includein classPageContext- Throws:
ServletExceptionIOException
-
include
- Specified by:
includein classPageContext- Throws:
ServletExceptionIOException
-
handlePageException
- Specified by:
handlePageExceptionin classPageContext- Throws:
ServletExceptionIOException
-
handlePageException
- Specified by:
handlePageExceptionin classPageContext- Throws:
ServletExceptionIOException
-