|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 objectMethod 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.ServletContext
ServletContext.setAttribute(String, Object)
public void removeAttribute(java.lang.String theName)
removeAttribute
in interface javax.servlet.ServletContext
ServletContext.removeAttribute(String)
public void log(java.lang.String theMessage, java.lang.Throwable theCause)
log
in interface javax.servlet.ServletContext
theMessage
- 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.ServletContext
theMessage
- 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.ServletContext
theException
- 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.ServletContext
ServletContext.getServlets()
public java.util.Enumeration getServletNames()
getServletNames
in interface javax.servlet.ServletContext
ServletContext.getServletNames()
public javax.servlet.Servlet getServlet(java.lang.String theName) throws javax.servlet.ServletException
getServlet
in interface javax.servlet.ServletContext
javax.servlet.ServletException
ServletContext.getServlet(String)
public java.lang.String getServerInfo()
getServerInfo
in interface javax.servlet.ServletContext
ServletContext.getServerInfo()
public java.io.InputStream getResourceAsStream(java.lang.String thePath)
getResourceAsStream
in interface javax.servlet.ServletContext
ServletContext.getResourceAsStream(String)
public java.net.URL getResource(java.lang.String thePath) throws java.net.MalformedURLException
getResource
in interface javax.servlet.ServletContext
java.net.MalformedURLException
ServletContext.getResource(String)
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String thePath)
getRequestDispatcher
in interface javax.servlet.ServletContext
thePath
- 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.ServletContext
theName
- 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.ServletContext
ServletContext.getRealPath(String)
public int getMinorVersion()
getMinorVersion
in interface javax.servlet.ServletContext
ServletContext.getMinorVersion()
public java.lang.String getMimeType(java.lang.String theFilename)
getMimeType
in interface javax.servlet.ServletContext
ServletContext.getMimeType(String)
public int getMajorVersion()
getMajorVersion
in interface javax.servlet.ServletContext
ServletContext.getMajorVersion()
public java.util.Enumeration getInitParameterNames()
getInitParameterNames
in interface javax.servlet.ServletContext
ServletContext.getInitParameterNames()
public java.lang.String getInitParameter(java.lang.String theName)
getInitParameter
in interface javax.servlet.ServletContext
ServletContext.getInitParameter(String)
public javax.servlet.ServletContext getContext(java.lang.String theUripath)
getContext
in interface javax.servlet.ServletContext
theUripath
- 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.ServletContext
ServletContext.getAttributeNames()
public java.lang.Object getAttribute(java.lang.String theName)
getAttribute
in interface javax.servlet.ServletContext
ServletContext.getAttribute(String)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |