|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.jsp.PageContext org.apache.struts.mock.MockPageContext
public class 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.
Field Summary | |
---|---|
protected ServletContext |
application
|
protected HashMap |
attributes
|
protected ServletConfig |
config
|
protected ServletRequest |
request
|
protected ServletResponse |
response
|
protected HttpSession |
session
|
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(boolean throwIOException,
boolean returnBody)
Construct a new PageContext impl. |
|
MockPageContext(ServletConfig config,
ServletRequest request,
ServletResponse response)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ServletContext application
protected HashMap attributes
protected ServletConfig config
protected ServletRequest request
protected ServletResponse response
protected HttpSession session
Constructor Detail |
---|
public MockPageContext()
public MockPageContext(ServletConfig config, ServletRequest request, 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
.Method Detail |
---|
public void setValues(ServletConfig config, ServletRequest request, ServletResponse response)
public Object findAttribute(String name)
findAttribute
in class PageContext
public void forward(String path)
forward
in class PageContext
public Object getAttribute(String name)
getAttribute
in class PageContext
public Object getAttribute(String name, int scope)
getAttribute
in class PageContext
public Enumeration getAttributeNamesInScope(int scope)
getAttributeNamesInScope
in class PageContext
public int getAttributesScope(String name)
getAttributesScope
in class PageContext
public Exception getException()
getException
in class PageContext
public JspWriter getOut()
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.
getOut
in class PageContext
public Object getPage()
getPage
in class PageContext
public ServletRequest getRequest()
getRequest
in class PageContext
public ServletResponse getResponse()
getResponse
in class PageContext
public ServletConfig getServletConfig()
getServletConfig
in class PageContext
public ServletContext getServletContext()
getServletContext
in class PageContext
public HttpSession getSession()
getSession
in class PageContext
public void handlePageException(Exception e)
handlePageException
in class PageContext
public void handlePageException(Throwable t)
handlePageException
in class PageContext
public void include(String path)
include
in class PageContext
public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
initialize
in class PageContext
public JspWriter popBody()
popBody
in class PageContext
public BodyContent pushBody()
pushBody
in class PageContext
public void release()
release
in class PageContext
public void removeAttribute(String name)
removeAttribute
in class PageContext
public void removeAttribute(String name, int scope)
removeAttribute
in class PageContext
public void setAttribute(String name, Object value)
setAttribute
in class PageContext
public void setAttribute(String name, Object value, int scope)
setAttribute
in class PageContext
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |