|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.struts.mock.MockServletContext
public class MockServletContext
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 HashMap |
attributes
The set of servlet context attributes. |
protected Log |
log
Default destination for LOG() output. |
protected HashMap |
parameters
The set of context initialization parameters. |
| Constructor Summary | |
|---|---|
MockServletContext()
|
|
| Method Summary | |
|---|---|
void |
addInitParameter(String name,
String value)
|
Object |
getAttribute(String name)
|
Enumeration |
getAttributeNames()
|
ServletContext |
getContext(String uripath)
|
String |
getInitParameter(String name)
|
Enumeration |
getInitParameterNames()
|
int |
getMajorVersion()
|
String |
getMimeType(String file)
|
int |
getMinorVersion()
|
RequestDispatcher |
getNamedDispatcher(String name)
|
String |
getRealPath(String path)
|
RequestDispatcher |
getRequestDispatcher(String path)
|
URL |
getResource(String path)
|
InputStream |
getResourceAsStream(String path)
|
Set |
getResourcePaths(String path)
|
String |
getServerInfo()
|
Servlet |
getServlet(String name)
|
String |
getServletContextName()
|
Enumeration |
getServletNames()
|
Enumeration |
getServlets()
|
void |
log(Exception exception,
String message)
|
void |
log(String message)
|
void |
log(String message,
Throwable throwable)
|
void |
removeAttribute(String name)
|
void |
setAttribute(String name,
Object value)
|
void |
setLog(Log log)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected HashMap attributes
The set of servlet context attributes.
protected Log log
Default destination for LOG() output.
protected HashMap parameters
The set of context initialization parameters.
| Constructor Detail |
|---|
public MockServletContext()
| Method Detail |
|---|
public void addInitParameter(String name,
String value)
public void setLog(Log log)
public Object getAttribute(String name)
getAttribute in interface ServletContextpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletContextpublic ServletContext getContext(String uripath)
getContext in interface ServletContextpublic String getInitParameter(String name)
getInitParameter in interface ServletContextpublic Enumeration getInitParameterNames()
getInitParameterNames in interface ServletContextpublic int getMajorVersion()
getMajorVersion in interface ServletContextpublic String getMimeType(String file)
getMimeType in interface ServletContextpublic int getMinorVersion()
getMinorVersion in interface ServletContextpublic RequestDispatcher getNamedDispatcher(String name)
getNamedDispatcher in interface ServletContextpublic String getRealPath(String path)
getRealPath in interface ServletContextpublic RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface ServletContextpublic URL getResource(String path)
getResource in interface ServletContextpublic InputStream getResourceAsStream(String path)
getResourceAsStream in interface ServletContextpublic Set getResourcePaths(String path)
getResourcePaths in interface ServletContextpublic String getServerInfo()
getServerInfo in interface ServletContextpublic Servlet getServlet(String name)
getServlet in interface ServletContextpublic String getServletContextName()
getServletContextName in interface ServletContextpublic Enumeration getServletNames()
getServletNames in interface ServletContextpublic Enumeration getServlets()
getServlets in interface ServletContext
public void log(Exception exception,
String message)
log in interface ServletContextpublic void log(String message)
log in interface ServletContext
public void log(String message,
Throwable throwable)
log in interface ServletContextpublic void removeAttribute(String name)
removeAttribute in interface ServletContext
public void setAttribute(String name,
Object value)
setAttribute in interface ServletContext
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||