Clover coverage report - Cactus 1.4.1 for J2EE API 13
Coverage timestamp: Sat Aug 31 2002 22:02:23 BST
file stats: LOC: 103   Methods: 6
NCLOC: 40   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ServletExceptionWrapper.java 16.7% 35.7% 33.3% 30.8%
 1   
 /*   Generated by AspectJ version 1.0.5 */
 2   
 package org.apache.cactus.client;
 3   
 import java.io.PrintStream;
 4   
 import java.io.PrintWriter;
 5   
 
 6   
 /** 
 7   
  * Wrapper around a <code>Throwable</code> object. Whenever an exception occurs 
 8   
  * in a test case executed on the server side, the text of this exception 
 9   
  * along with the stack trace as a String are sent back in the HTTP response. 
 10   
  * This is because some exceptions are not serializable and because the stack 
 11   
  * trace is implemented as a <code>transient</code> variable by the JDK so it 
 12   
  * cannot be transported in the response. However, we need to send a real 
 13   
  * exception object to JUnit so that the exception stack trace will be printed 
 14   
  * in the JUnit console. This class does this by being a <code>Throwable</code> 
 15   
  * and overloading the <code>printStackTrace()</code> methods to print a 
 16   
  * text stack trace. 
 17   
  * 
 18   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 19   
  * 
 20   
  * @version $Id: ServletExceptionWrapper.html,v 1.1 2003/04/14 12:27:31 sinisa Exp $ 
 21   
  */
 22   
 public class ServletExceptionWrapper extends Throwable {
 23   
   /** 
 24   
        * The stack trace that was sent back from the servlet redirector as a 
 25   
        * string. 
 26   
        */
 27   
   private String stackTrace;
 28   
   /** 
 29   
        * The class name of the exception that was raised on the server side. 
 30   
        */
 31   
   private String className;
 32   
   /** 
 33   
        * Standard throwable constructor. 
 34   
        * 
 35   
        * @param theMessage the exception message 
 36   
        */
 37  0
   public ServletExceptionWrapper(String theMessage) {
 38  0
     super(theMessage);
 39   
     ;
 40   
   } 
 41   
   /** 
 42   
        * Standard throwable constructor. 
 43   
        */
 44  0
   public ServletExceptionWrapper() {
 45  0
     super();
 46   
     ;
 47   
   } 
 48   
   /** 
 49   
        * The constructor to use to simulate a real exception. 
 50   
        * 
 51   
        * @param theMessage the server exception message 
 52   
        * @param theClassName the server exception class name 
 53   
        * @param theStackTrace the server exception stack trace 
 54   
        */
 55  10
   public ServletExceptionWrapper(String theMessage, String theClassName, String theStackTrace) {
 56  10
     super(theMessage);
 57   
     ;
 58  10
     this.className = theClassName;
 59  10
     this.stackTrace = theStackTrace;
 60   
   } 
 61   
   /** 
 62   
        * Simulates a printing of a stack trace by printing the string stack trace 
 63   
        * 
 64   
        * @param thePs the stream to which to output the stack trace 
 65   
        */
 66  0
   public void printStackTrace(PrintStream thePs) {
 67  0
     if (this.stackTrace == null) {
 68  0
       thePs.print(this.getMessage());
 69   
     } else {
 70  0
       thePs.print(this.stackTrace);
 71   
     } 
 72   
   } 
 73   
 
 74   
   /** 
 75   
        * Simulates a printing of a stack trace by printing the string stack trace 
 76   
        * 
 77   
        * @param thePw the writer to which to output the stack trace 
 78   
        */
 79  0
   public void printStackTrace(PrintWriter thePw) {
 80  0
     if (this.stackTrace == null) {
 81  0
       thePw.print(this.getMessage());
 82   
     } else {
 83  0
       thePw.print(this.stackTrace);
 84   
     } 
 85   
   } 
 86   
 
 87   
   /** 
 88   
        * As all the server exceptions are wrapped into this 
 89   
        * <code>ServletExceptionWrapper</code> class, we need to be able to 
 90   
        * know the original server exception class. 
 91   
        * 
 92   
        * @param theClass the class to compare with the server exception class 
 93   
        * @return true if the class passed as parameter is an instance of 
 94   
        *         <code>ServletExceptionWrapper</code> (this class) 
 95   
        */
 96  10
   public boolean instanceOf(Class theClass) {
 97  10
     if (this.className == null) {
 98  0
       return false;
 99   
     } 
 100  10
     return theClass.getName().equals(this.className);
 101   
   } 
 102   
 
 103   
 }