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
|
|
import junit.framework.AssertionFailedError;
|
6
|
|
|
7
|
|
/**
|
8
|
|
* Same as <code>ServletExceptionWrapper</code> except that this exception class
|
9
|
|
* extends JUnit <code>AssertionFailedError</code> so that JUnit will
|
10
|
|
* print a different message in it's runner console.
|
11
|
|
*
|
12
|
|
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
13
|
|
*
|
14
|
|
* @version $Id: AssertionFailedErrorWrapper.java,v 1.1 2002/03/01 00:43:46 vmassol Exp $
|
15
|
|
*/
|
16
|
|
public class AssertionFailedErrorWrapper extends AssertionFailedError {
|
17
|
|
/**
|
18
|
|
* The stack trace that was sent back from the servlet redirector as a
|
19
|
|
* string.
|
20
|
|
*/
|
21
|
|
private String stackTrace;
|
22
|
|
/**
|
23
|
|
* The class name of the exception that was raised on the server side.
|
24
|
|
*/
|
25
|
|
private String className;
|
26
|
|
/**
|
27
|
|
* Standard throwable constructor.
|
28
|
|
*
|
29
|
|
* @param theMessage the exception message
|
30
|
|
*/
|
31
|
0
|
public AssertionFailedErrorWrapper(String theMessage) {
|
32
|
0
|
super(theMessage);
|
33
|
|
;
|
34
|
|
}
|
35
|
|
/**
|
36
|
|
* Standard throwable constructor.
|
37
|
|
*/
|
38
|
0
|
public AssertionFailedErrorWrapper() {
|
39
|
0
|
super();
|
40
|
|
;
|
41
|
|
}
|
42
|
|
/**
|
43
|
|
* The constructor to use to simulate a real exception.
|
44
|
|
*
|
45
|
|
* @param theMessage the server exception message
|
46
|
|
* @param theClassName the server exception class name
|
47
|
|
* @param theStackTrace the server exception stack trace
|
48
|
|
*/
|
49
|
2
|
public AssertionFailedErrorWrapper(String theMessage, String theClassName,
|
50
|
|
String theStackTrace) {
|
51
|
2
|
super(theMessage);
|
52
|
|
;
|
53
|
2
|
this.className = theClassName;
|
54
|
2
|
this.stackTrace = theStackTrace;
|
55
|
|
}
|
56
|
|
/**
|
57
|
|
* Simulates a printing of a stack trace by printing the string stack trace
|
58
|
|
*
|
59
|
|
* @param thePs the stream to which to output the stack trace
|
60
|
|
*/
|
61
|
0
|
public void printStackTrace(PrintStream thePs) {
|
62
|
0
|
if (this.stackTrace == null) {
|
63
|
0
|
thePs.print(this.getMessage());
|
64
|
|
} else {
|
65
|
0
|
thePs.print(this.stackTrace);
|
66
|
|
}
|
67
|
|
}
|
68
|
|
|
69
|
|
/**
|
70
|
|
* Simulates a printing of a stack trace by printing the string stack trace
|
71
|
|
*
|
72
|
|
* @param thePw the writer to which to output the stack trace
|
73
|
|
*/
|
74
|
0
|
public void printStackTrace(PrintWriter thePw) {
|
75
|
0
|
if (this.stackTrace == null) {
|
76
|
0
|
thePw.print(this.getMessage());
|
77
|
|
} else {
|
78
|
0
|
thePw.print(this.stackTrace);
|
79
|
|
}
|
80
|
|
}
|
81
|
|
|
82
|
|
/**
|
83
|
|
* As all the server exceptions are wrapped into this
|
84
|
|
* <code>ServletExceptionWrapper</code> class, we need to be able to
|
85
|
|
* know the original server exception class.
|
86
|
|
*
|
87
|
|
* @param theClass the class to compare with the server exception class
|
88
|
|
* @return true if the current exception class is of the same type as the
|
89
|
|
* class passed as parameter.
|
90
|
|
*/
|
91
|
1
|
public boolean instanceOf(Class theClass) {
|
92
|
1
|
if (this.className == null) {
|
93
|
0
|
return false;
|
94
|
|
}
|
95
|
1
|
return theClass.getName().equals(this.className);
|
96
|
|
}
|
97
|
|
|
98
|
|
}
|