org.apache.cactus.server
Class AbstractServletContextWrapper
java.lang.Object
|
+--org.apache.cactus.server.AbstractServletContextWrapper
- All Implemented Interfaces:
- javax.servlet.ServletContext
- Direct Known Subclasses:
- ServletContextWrapper
- public abstract class AbstractServletContextWrapper
- extends java.lang.Object
- implements javax.servlet.ServletContext
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.
- Version:
- $Id: AbstractServletContextWrapper.java,v 1.3 2001/09/14 20:16:44 pier Exp $
- Author:
- Vincent Massol
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)
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)
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 |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AbstractServletContextWrapper
public AbstractServletContextWrapper(javax.servlet.ServletContext theOriginalContext)
- Parameters:
theOriginalContext
- the original servlet context object
getLogs
public 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. This method does not return the exceptions or
throwable sent for logging; it only returns the messages.
- Returns:
- the logs as a vector of strings (each string contains the
message that was sent for logging).
setAttribute
public void setAttribute(java.lang.String theName,
java.lang.Object theAttribute)
- Specified by:
setAttribute
in interface javax.servlet.ServletContext
removeAttribute
public void removeAttribute(java.lang.String theName)
- Specified by:
removeAttribute
in interface javax.servlet.ServletContext
log
public 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. Note that the throwable is not saved.
- Specified by:
log
in interface javax.servlet.ServletContext
- See Also:
getLogs()
log
public 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. Note that the throwable is not saved.
- Specified by:
log
in interface javax.servlet.ServletContext
- See Also:
getLogs()
log
public void log(java.lang.Exception theException,
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. Note that the throwable is not saved.
- Specified by:
log
in interface javax.servlet.ServletContext
- See Also:
getLogs()
getServlets
public java.util.Enumeration getServlets()
- Specified by:
getServlets
in interface javax.servlet.ServletContext
getServletNames
public java.util.Enumeration getServletNames()
- Specified by:
getServletNames
in interface javax.servlet.ServletContext
getServlet
public javax.servlet.Servlet getServlet(java.lang.String theName)
throws javax.servlet.ServletException
- Specified by:
getServlet
in interface javax.servlet.ServletContext
getServerInfo
public java.lang.String getServerInfo()
- Specified by:
getServerInfo
in interface javax.servlet.ServletContext
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String thePath)
- Specified by:
getResourceAsStream
in interface javax.servlet.ServletContext
getResource
public java.net.URL getResource(java.lang.String thePath)
throws java.net.MalformedURLException
- Specified by:
getResource
in interface javax.servlet.ServletContext
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String thePath)
- Specified by:
getRequestDispatcher
in interface javax.servlet.ServletContext
- Returns:
- our request dispatcher wrapper
getNamedDispatcher
public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String theName)
- Specified by:
getNamedDispatcher
in interface javax.servlet.ServletContext
- Returns:
- our request dispatcher wrapper
getRealPath
public java.lang.String getRealPath(java.lang.String thePath)
- Specified by:
getRealPath
in interface javax.servlet.ServletContext
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersion
in interface javax.servlet.ServletContext
getMimeType
public java.lang.String getMimeType(java.lang.String theFilename)
- Specified by:
getMimeType
in interface javax.servlet.ServletContext
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersion
in interface javax.servlet.ServletContext
getInitParameterNames
public java.util.Enumeration getInitParameterNames()
- Specified by:
getInitParameterNames
in interface javax.servlet.ServletContext
getInitParameter
public java.lang.String getInitParameter(java.lang.String theName)
- Specified by:
getInitParameter
in interface javax.servlet.ServletContext
getContext
public javax.servlet.ServletContext getContext(java.lang.String theUripath)
- Specified by:
getContext
in interface javax.servlet.ServletContext
- Returns:
- our servlet context wrapper
getAttributeNames
public java.util.Enumeration getAttributeNames()
- Specified by:
getAttributeNames
in interface javax.servlet.ServletContext
getAttribute
public java.lang.Object getAttribute(java.lang.String theName)
- Specified by:
getAttribute
in interface javax.servlet.ServletContext
Copyright © 2000-2001 Apache Software Foundation. All Rights Reserved.