|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.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 PageContextpublic void forward(String path)
forward in class PageContextpublic Object getAttribute(String name)
getAttribute in class PageContext
public Object getAttribute(String name,
int scope)
getAttribute in class PageContextpublic Enumeration getAttributeNamesInScope(int scope)
getAttributeNamesInScope in class PageContextpublic int getAttributesScope(String name)
getAttributesScope in class PageContextpublic Exception getException()
getException in class PageContextpublic JspWriter getOut()
Custom JspWriter that throws the specified exception (supplied on the constructor...if any), else it simply returns.
getOut in class PageContextpublic Object getPage()
getPage in class PageContextpublic ServletRequest getRequest()
getRequest in class PageContextpublic ServletResponse getResponse()
getResponse in class PageContextpublic ServletConfig getServletConfig()
getServletConfig in class PageContextpublic ServletContext getServletContext()
getServletContext in class PageContextpublic HttpSession getSession()
getSession in class PageContextpublic void handlePageException(Exception e)
handlePageException in class PageContextpublic void handlePageException(Throwable t)
handlePageException in class PageContextpublic 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 PageContextpublic JspWriter popBody()
popBody in class PageContextpublic BodyContent pushBody()
pushBody in class PageContextpublic void release()
release in class PageContextpublic 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 | |||||||||