|
||||||||||
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 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
|
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(javax.servlet.ServletConfig config,
javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response)
|
Method Summary | |
---|---|
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)
|
java.lang.Exception |
getException()
|
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()
|
void |
handlePageException(java.lang.Exception e)
|
void |
handlePageException(java.lang.Throwable t)
|
void |
include(java.lang.String path)
|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 Detail |
---|
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
.Method Detail |
---|
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.PageContext
public void forward(java.lang.String path)
forward
in class javax.servlet.jsp.PageContext
public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in class javax.servlet.jsp.PageContext
public java.lang.Object getAttribute(java.lang.String name, int scope)
getAttribute
in class javax.servlet.jsp.PageContext
public java.util.Enumeration getAttributeNamesInScope(int scope)
getAttributeNamesInScope
in class javax.servlet.jsp.PageContext
public int getAttributesScope(java.lang.String name)
getAttributesScope
in class javax.servlet.jsp.PageContext
public java.lang.Exception getException()
getException
in class javax.servlet.jsp.PageContext
public 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.PageContext
public java.lang.Object getPage()
getPage
in class javax.servlet.jsp.PageContext
public javax.servlet.ServletRequest getRequest()
getRequest
in class javax.servlet.jsp.PageContext
public javax.servlet.ServletResponse getResponse()
getResponse
in class javax.servlet.jsp.PageContext
public javax.servlet.ServletConfig getServletConfig()
getServletConfig
in class javax.servlet.jsp.PageContext
public javax.servlet.ServletContext getServletContext()
getServletContext
in class javax.servlet.jsp.PageContext
public javax.servlet.http.HttpSession getSession()
getSession
in class javax.servlet.jsp.PageContext
public void handlePageException(java.lang.Exception e)
handlePageException
in class javax.servlet.jsp.PageContext
public void handlePageException(java.lang.Throwable t)
handlePageException
in class javax.servlet.jsp.PageContext
public void include(java.lang.String path)
include
in class javax.servlet.jsp.PageContext
public 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.PageContext
public javax.servlet.jsp.JspWriter popBody()
popBody
in class javax.servlet.jsp.PageContext
public javax.servlet.jsp.tagext.BodyContent pushBody()
pushBody
in class javax.servlet.jsp.PageContext
public void release()
release
in class javax.servlet.jsp.PageContext
public void removeAttribute(java.lang.String name)
removeAttribute
in class javax.servlet.jsp.PageContext
public void removeAttribute(java.lang.String name, int scope)
removeAttribute
in class javax.servlet.jsp.PageContext
public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in class javax.servlet.jsp.PageContext
public void setAttribute(java.lang.String name, java.lang.Object value, int scope)
setAttribute
in class javax.servlet.jsp.PageContext
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |