org.apache.cactus.client
Class ServletExceptionWrapper

java.lang.Object
  extended byjava.lang.Throwable
      extended byorg.apache.cactus.client.ServletExceptionWrapper
All Implemented Interfaces:
java.io.Serializable

public class ServletExceptionWrapper
extends java.lang.Throwable

Wrapper around a Throwable object. Whenever an exception occurs in a test case executed on the server side, the text of this exception along with the stack trace as a String are sent back in the HTTP response. This is because some exceptions are not serializable and because the stack trace is implemented as a transient variable by the JDK so it cannot be transported in the response. However, we need to send a real exception object to JUnit so that the exception stack trace will be printed in the JUnit console. This class does this by being a Throwable and overloading the printStackTrace() methods to print a text stack trace.

Version:
$Id: ServletExceptionWrapper.java,v 1.4 2003/05/26 11:45:25 cmlenz Exp $
Author:
Vincent Massol
See Also:
Serialized Form

Constructor Summary
ServletExceptionWrapper()
          Standard throwable constructor.
ServletExceptionWrapper(java.lang.String theMessage)
          Standard throwable constructor.
ServletExceptionWrapper(java.lang.String theMessage, java.lang.String theClassName, java.lang.String theStackTrace)
          The constructor to use to simulate a real exception.
 
Method Summary
 boolean instanceOf(java.lang.Class theClass)
          As all the server exceptions are wrapped into this ServletExceptionWrapper class, we need to be able to know the original server exception class.
 void printStackTrace(java.io.PrintStream thePs)
          Simulates a printing of a stack trace by printing the string stack trace
 void printStackTrace(java.io.PrintWriter thePw)
          Simulates a printing of a stack trace by printing the string stack trace
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServletExceptionWrapper

public ServletExceptionWrapper(java.lang.String theMessage)
Standard throwable constructor.

Parameters:
theMessage - the exception message

ServletExceptionWrapper

public ServletExceptionWrapper()
Standard throwable constructor.


ServletExceptionWrapper

public ServletExceptionWrapper(java.lang.String theMessage,
                               java.lang.String theClassName,
                               java.lang.String theStackTrace)
The constructor to use to simulate a real exception.

Parameters:
theMessage - the server exception message
theClassName - the server exception class name
theStackTrace - the server exception stack trace
Method Detail

printStackTrace

public void printStackTrace(java.io.PrintStream thePs)
Simulates a printing of a stack trace by printing the string stack trace

Parameters:
thePs - the stream to which to output the stack trace

printStackTrace

public void printStackTrace(java.io.PrintWriter thePw)
Simulates a printing of a stack trace by printing the string stack trace

Parameters:
thePw - the writer to which to output the stack trace

instanceOf

public boolean instanceOf(java.lang.Class theClass)
As all the server exceptions are wrapped into this ServletExceptionWrapper class, we need to be able to know the original server exception class.

Parameters:
theClass - the class to compare with the server exception class
Returns:
true if the class passed as parameter is an instance of ServletExceptionWrapper (this class)


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.