Clover coverage report - Cactus 1.4.1 for J2EE API 13
Coverage timestamp: Sat Aug 31 2002 22:02:23 BST
file stats: LOC: 281   Methods: 24
NCLOC: 112   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractServletContextWrapper.java 40% 41.5% 20.8% 34.7%
 1   
 /*   Generated by AspectJ version 1.0.5 */
 2   
 package org.apache.cactus.server;
 3   
 import java.io.InputStream;
 4   
 import java.net.MalformedURLException;
 5   
 import java.net.URL;
 6   
 import java.util.Enumeration;
 7   
 import java.util.Vector;
 8   
 import javax.servlet.RequestDispatcher;
 9   
 import javax.servlet.Servlet;
 10   
 import javax.servlet.ServletContext;
 11   
 import javax.servlet.ServletException;
 12   
 
 13   
 /** 
 14   
  * Abstract wrapper around <code>ServletContext</code>. This class provides 
 15   
  * a common implementation of the wrapper for the different servlet API. In 
 16   
  * addition to implementing the <code>ServletContext</code> interface it 
 17   
  * provides additional features helpful for writing unit tests. More 
 18   
  * specifically the <code>getRequestDispatcher()</code> method is overrided 
 19   
  * to return an request dispatcher wrapper. In addition logs generated by 
 20   
  * calls to the <code>log()</code> methods can be retrieved and asserted by 
 21   
  * calling the <code>getLogs()</code> method. 
 22   
  * 
 23   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 24   
  * 
 25   
  * @version $Id: AbstractServletContextWrapper.html,v 1.1 2003/04/14 12:27:31 sinisa Exp $ 
 26   
  */
 27   
 public abstract class AbstractServletContextWrapper implements ServletContext {
 28   
   /** 
 29   
        * The original servlet context object 
 30   
        */
 31   
   protected ServletContext originalContext;
 32   
   /** 
 33   
        * The logs resulting from calling the <code>log()</code> methods 
 34   
        */
 35   
   private Vector logs;
 36   
   /** 
 37   
        * Returns all the text logs that have been generated using the 
 38   
        * <code>log()</code> methods so that it is possible to easily assert the 
 39   
        * content of the logs. This method does not return the exceptions or 
 40   
        * throwable sent for logging; it only returns the messages. 
 41   
        * 
 42   
        * @return the logs as a vector of strings (each string contains the 
 43   
        *         message that was sent for logging). 
 44   
        */
 45  5
   public Vector getLogs() {
 46  5
     return this.logs;
 47   
   } 
 48   
 
 49   
   /** 
 50   
        * @param theOriginalContext the original servlet context object 
 51   
        */
 52  30
   public AbstractServletContextWrapper(ServletContext theOriginalContext) {
 53  30
     super();
 54   
     {
 55   
       /** 
 56   
            * The logs resulting from calling the <code>log()</code> methods 
 57   
            */
 58  30
       this.logs = new Vector();
 59   
     } 
 60  30
     this.originalContext = theOriginalContext;
 61   
   } 
 62   
   /** 
 63   
        * @see ServletContext#setAttribute(String, Object) 
 64   
        */
 65  0
   public void setAttribute(String theName, Object theAttribute) {
 66  0
     this.originalContext.setAttribute(theName, theAttribute);
 67   
   } 
 68   
 
 69   
   /** 
 70   
        * @see ServletContext#removeAttribute(String) 
 71   
        */
 72  0
   public void removeAttribute(String theName) {
 73  0
     this.originalContext.removeAttribute(theName);
 74   
   } 
 75   
 
 76   
   /** 
 77   
        * Intercept the log call and add the message to an internal vector of 
 78   
        * log messages that can then later be retrieved and asserted by the 
 79   
        * test case writer. Note that the throwable is not saved. 
 80   
        * 
 81   
        * @param theMessage a <code>String</code> that describes the error or 
 82   
        *        exception 
 83   
        * @param theCause the <code>Throwable</code> error or exception 
 84   
        * 
 85   
        * @see #getLogs() 
 86   
        * @see ServletContext#log(String, Throwable) 
 87   
        */
 88  0
   public void log(String theMessage, Throwable theCause) {
 89  0
     if (theMessage != null) {
 90  0
       this.logs.addElement(theMessage);
 91   
     } 
 92  0
     this.originalContext.log(theMessage, theCause);
 93   
   } 
 94   
 
 95   
   /** 
 96   
        * Intercept the log call and add the message to an internal vector of 
 97   
        * log messages that can then later be retrieved and asserted by the 
 98   
        * test case writer. Note that the throwable is not saved. 
 99   
        * 
 100   
        * @param theMessage a <code>String</code> that describes the error or 
 101   
        *        exception 
 102   
        * 
 103   
        * @see #getLogs() 
 104   
        * @see ServletContext#log(String) 
 105   
        */
 106  10
   public void log(String theMessage) {
 107  10
     if (theMessage != null) {
 108  10
       this.logs.addElement(theMessage);
 109   
     } 
 110  10
     this.originalContext.log(theMessage);
 111   
   } 
 112   
 
 113   
   /** 
 114   
        * Intercept the log call and add the message to an internal vector of 
 115   
        * log messages that can then later be retrieved and asserted by the 
 116   
        * test case writer. Note that the throwable is not saved. 
 117   
        * 
 118   
        * @param theException the exception to log 
 119   
        * @param theMessage a <code>String</code> that describes the error or 
 120   
        *        exception 
 121   
        * 
 122   
        * @see #getLogs() 
 123   
        * @see ServletContext#log(Exception, String) 
 124   
        * 
 125   
        * @deprecated As of Java Servlet API 2.1, use 
 126   
        *             {@link #log(String message, Throwable throwable)} instead. 
 127   
        *             This method was originally defined to write an exception's 
 128   
        *             stack trace and an explanatory error message to the servlet 
 129   
        *             log file. 
 130   
        */
 131  0
   public void log(Exception theException, String theMessage) {
 132  0
     if (theMessage != null) {
 133  0
       this.logs.addElement(theMessage);
 134   
     } 
 135  0
     this.originalContext.log(theException, theMessage);
 136   
   } 
 137   
 
 138   
   /** 
 139   
        * @see ServletContext#getServlets() 
 140   
        */
 141  0
   public Enumeration getServlets() {
 142  0
     return this.originalContext.getServlets();
 143   
   } 
 144   
 
 145   
   /** 
 146   
        * @see ServletContext#getServletNames() 
 147   
        */
 148  0
   public Enumeration getServletNames() {
 149  0
     return this.originalContext.getServletNames();
 150   
   } 
 151   
 
 152   
   /** 
 153   
        * @see ServletContext#getServlet(String) 
 154   
        */
 155  0
   public Servlet getServlet(String theName) throws ServletException {
 156  0
     return this.originalContext.getServlet(theName);
 157   
   } 
 158   
 
 159   
   /** 
 160   
        * @see ServletContext#getServerInfo() 
 161   
        */
 162  0
   public String getServerInfo() {
 163  0
     return this.originalContext.getServerInfo();
 164   
   } 
 165   
 
 166   
   /** 
 167   
        * @see ServletContext#getResourceAsStream(String) 
 168   
        */
 169  0
   public InputStream getResourceAsStream(String thePath) {
 170  0
     return this.originalContext.getResourceAsStream(thePath);
 171   
   } 
 172   
 
 173   
   /** 
 174   
        * @see ServletContext#getResource(String) 
 175   
        */
 176  0
   public URL getResource(String thePath) throws MalformedURLException {
 177  0
     return this.originalContext.getResource(thePath);
 178   
   } 
 179   
 
 180   
   /** 
 181   
        * @param thePath a string specifying the pathname to the resource 
 182   
        * @return our request dispatcher wrapper 
 183   
        * @see ServletContext#getRequestDispatcher(String) 
 184   
        */
 185  10
   public RequestDispatcher getRequestDispatcher(String thePath) {
 186  10
     RequestDispatcher wrappedDispatcher = null;
 187  10
     RequestDispatcher originalDispatcher = this.originalContext.getRequestDispatcher(thePath);
 188  10
     if (originalDispatcher != null) {
 189  10
       wrappedDispatcher = new RequestDispatcherWrapper(originalDispatcher);
 190   
     } 
 191  10
     return wrappedDispatcher;
 192   
   } 
 193   
 
 194   
   /** 
 195   
        * @param theName a string specifying the name of a servlet to wrap 
 196   
        * @return our request dispatcher wrapper or null if the servlet cannot 
 197   
        *         be found. 
 198   
        * @see ServletContext#getNamedDispatcher(String) 
 199   
        */
 200  10
   public RequestDispatcher getNamedDispatcher(String theName) {
 201  10
     RequestDispatcher wrappedDispatcher = null;
 202  10
     RequestDispatcher originalDispatcher = this.originalContext.getNamedDispatcher(theName);
 203  10
     if (originalDispatcher != null) {
 204  5
       wrappedDispatcher = new RequestDispatcherWrapper(originalDispatcher);
 205   
     } 
 206  10
     return wrappedDispatcher;
 207   
   } 
 208   
 
 209   
   /** 
 210   
        * @see ServletContext#getRealPath(String) 
 211   
        */
 212  0
   public String getRealPath(String thePath) {
 213  0
     return this.originalContext.getRealPath(thePath);
 214   
   } 
 215   
 
 216   
   /** 
 217   
        * @see ServletContext#getMinorVersion() 
 218   
        */
 219  0
   public int getMinorVersion() {
 220  0
     return this.originalContext.getMinorVersion();
 221   
   } 
 222   
 
 223   
   /** 
 224   
        * @see ServletContext#getMimeType(String) 
 225   
        */
 226  0
   public String getMimeType(String theFilename) {
 227  0
     return this.originalContext.getMimeType(theFilename);
 228   
   } 
 229   
 
 230   
   /** 
 231   
        * @see ServletContext#getMajorVersion() 
 232   
        */
 233  0
   public int getMajorVersion() {
 234  0
     return this.originalContext.getMajorVersion();
 235   
   } 
 236   
 
 237   
   /** 
 238   
        * @see ServletContext#getInitParameterNames() 
 239   
        */
 240  0
   public Enumeration getInitParameterNames() {
 241  0
     return this.originalContext.getInitParameterNames();
 242   
   } 
 243   
 
 244   
   /** 
 245   
        * @see ServletContext#getInitParameter(String) 
 246   
        */
 247  0
   public String getInitParameter(String theName) {
 248  0
     return this.originalContext.getInitParameter(theName);
 249   
   } 
 250   
 
 251   
   /** 
 252   
        * @param theUripath a String specifying the context path of another web 
 253   
        *        application in the container 
 254   
        * @return our servlet context wrapper 
 255   
        * @see ServletContext#getContext(String) 
 256   
        */
 257  0
   public ServletContext getContext(String theUripath) {
 258  0
     ServletContext context = new ServletContextWrapper(this.originalContext.getContext(
 259   
         theUripath));
 260  0
     return context;
 261   
   } 
 262   
 
 263   
   /** 
 264   
        * @see ServletContext#getAttributeNames() 
 265   
        */
 266  0
   public Enumeration getAttributeNames() {
 267  0
     return this.originalContext.getAttributeNames();
 268   
   } 
 269   
 
 270   
   /** 
 271   
        * @see ServletContext#getAttribute(String) 
 272   
        */
 273  0
   public Object getAttribute(String theName) {
 274  0
     return this.originalContext.getAttribute(theName);
 275   
   } 
 276   
 
 277   
   public abstract java.util.Set getResourcePaths(String __0);
 278   
 
 279   
   public abstract String getServletContextName();
 280   
 
 281   
 }