|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.cactus.server.AbstractServletContextWrapper
Abstract wrapper around ServletContext. This class provides
a common implementation of the wrapper for the different servlet API. In
addition to implementing the ServletContext interface it
provides additional features helpful for writing unit tests. More
specifically the getRequestDispatcher() method is overrided
to return an request dispatcher wrapper. In addition logs generated by
calls to the log() methods can be retrieved and asserted by
calling the getLogs() method.
| Field Summary | |
protected javax.servlet.ServletContext |
originalContext
The original servlet context object |
| Constructor Summary | |
AbstractServletContextWrapper(javax.servlet.ServletContext theOriginalContext)
|
|
| Method Summary | |
java.lang.Object |
getAttribute(java.lang.String theName)
|
java.util.Enumeration |
getAttributeNames()
|
javax.servlet.ServletContext |
getContext(java.lang.String theUripath)
|
java.lang.String |
getInitParameter(java.lang.String theName)
|
java.util.Enumeration |
getInitParameterNames()
|
java.util.Vector |
getLogs()
Returns all the text logs that have been generated using the log() methods so that it is possible to easily assert the
content of the logs. |
int |
getMajorVersion()
|
java.lang.String |
getMimeType(java.lang.String theFilename)
|
int |
getMinorVersion()
|
javax.servlet.RequestDispatcher |
getNamedDispatcher(java.lang.String theName)
|
java.lang.String |
getRealPath(java.lang.String thePath)
|
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String thePath)
|
java.net.URL |
getResource(java.lang.String thePath)
|
java.io.InputStream |
getResourceAsStream(java.lang.String thePath)
|
java.lang.String |
getServerInfo()
|
javax.servlet.Servlet |
getServlet(java.lang.String theName)
|
java.util.Enumeration |
getServletNames()
|
java.util.Enumeration |
getServlets()
|
void |
log(java.lang.Exception theException,
java.lang.String theMessage)
Deprecated. As of Java Servlet API 2.1, use log(String message, Throwable throwable) instead.
This method was originally defined to write an exception's
stack trace and an explanatory error message to the servlet
log file. |
void |
log(java.lang.String theMessage)
Intercept the log call and add the message to an internal vector of log messages that can then later be retrieved and asserted by the test case writer. |
void |
log(java.lang.String theMessage,
java.lang.Throwable theCause)
Intercept the log call and add the message to an internal vector of log messages that can then later be retrieved and asserted by the test case writer. |
void |
removeAttribute(java.lang.String theName)
|
void |
setAttribute(java.lang.String theName,
java.lang.Object theAttribute)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected javax.servlet.ServletContext originalContext
| Constructor Detail |
public AbstractServletContextWrapper(javax.servlet.ServletContext theOriginalContext)
theOriginalContext - the original servlet context object| Method Detail |
public java.util.Vector getLogs()
log() methods so that it is possible to easily assert the
content of the logs. This method does not return the exceptions or
throwable sent for logging; it only returns the messages.
public void setAttribute(java.lang.String theName,
java.lang.Object theAttribute)
setAttribute in interface javax.servlet.ServletContextServletContext.setAttribute(String, Object)public void removeAttribute(java.lang.String theName)
removeAttribute in interface javax.servlet.ServletContextServletContext.removeAttribute(String)
public void log(java.lang.String theMessage,
java.lang.Throwable theCause)
log in interface javax.servlet.ServletContexttheMessage - a String that describes the error or
exceptiontheCause - the Throwable error or exceptiongetLogs(),
ServletContext.log(String, Throwable)public void log(java.lang.String theMessage)
log in interface javax.servlet.ServletContexttheMessage - a String that describes the error or
exceptiongetLogs(),
ServletContext.log(String)
public void log(java.lang.Exception theException,
java.lang.String theMessage)
log(String message, Throwable throwable) instead.
This method was originally defined to write an exception's
stack trace and an explanatory error message to the servlet
log file.
log in interface javax.servlet.ServletContexttheException - the exception to logtheMessage - a String that describes the error or
exceptiongetLogs(),
ServletContext.log(Exception, String)public java.util.Enumeration getServlets()
getServlets in interface javax.servlet.ServletContextServletContext.getServlets()public java.util.Enumeration getServletNames()
getServletNames in interface javax.servlet.ServletContextServletContext.getServletNames()
public javax.servlet.Servlet getServlet(java.lang.String theName)
throws javax.servlet.ServletException
getServlet in interface javax.servlet.ServletContextjavax.servlet.ServletExceptionServletContext.getServlet(String)public java.lang.String getServerInfo()
getServerInfo in interface javax.servlet.ServletContextServletContext.getServerInfo()public java.io.InputStream getResourceAsStream(java.lang.String thePath)
getResourceAsStream in interface javax.servlet.ServletContextServletContext.getResourceAsStream(String)
public java.net.URL getResource(java.lang.String thePath)
throws java.net.MalformedURLException
getResource in interface javax.servlet.ServletContextjava.net.MalformedURLExceptionServletContext.getResource(String)public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String thePath)
getRequestDispatcher in interface javax.servlet.ServletContextthePath - a string specifying the pathname to the resource
ServletContext.getRequestDispatcher(String)public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String theName)
getNamedDispatcher in interface javax.servlet.ServletContexttheName - a string specifying the name of a servlet to wrap
ServletContext.getNamedDispatcher(String)public java.lang.String getRealPath(java.lang.String thePath)
getRealPath in interface javax.servlet.ServletContextServletContext.getRealPath(String)public int getMinorVersion()
getMinorVersion in interface javax.servlet.ServletContextServletContext.getMinorVersion()public java.lang.String getMimeType(java.lang.String theFilename)
getMimeType in interface javax.servlet.ServletContextServletContext.getMimeType(String)public int getMajorVersion()
getMajorVersion in interface javax.servlet.ServletContextServletContext.getMajorVersion()public java.util.Enumeration getInitParameterNames()
getInitParameterNames in interface javax.servlet.ServletContextServletContext.getInitParameterNames()public java.lang.String getInitParameter(java.lang.String theName)
getInitParameter in interface javax.servlet.ServletContextServletContext.getInitParameter(String)public javax.servlet.ServletContext getContext(java.lang.String theUripath)
getContext in interface javax.servlet.ServletContexttheUripath - a String specifying the context path of another web
application in the container
ServletContext.getContext(String)public java.util.Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletContextServletContext.getAttributeNames()public java.lang.Object getAttribute(java.lang.String theName)
getAttribute in interface javax.servlet.ServletContextServletContext.getAttribute(String)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||