01: // StrutsTestCase - a JUnit extension for testing Struts actions
02: // within the context of the ActionServlet.
03: // Copyright (C) 2002 Deryl Seale
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the Apache Software License as
07: // published by the Apache Software Foundation; either version 1.1
08: // of the License, or (at your option) any later version.
09: //
10: // This library is distributed in the hope that it will be useful,
11: // but WITHOUT ANY WARRANTY; without even the implied warranty of
12: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: // Apache Software Foundation Licens for more details.
14: //
15: // You may view the full text here: http://www.apache.org/LICENSE.txt
16: package servletunit.struts;
17:
18: import java.io.*;
19: import javax.servlet.ServletException;
20:
21: /**
22: * <p>Title: ExceptionDuringTestError</p>
23: * <p>Description: An error indicating an uncaught exception
24: * occurred during testing</p>
25: * <p>Copyright: Copyright (c) 2003</p>
26: * @author Sean Pritchard
27: * @version 1.0
28: */
29: public class ExceptionDuringTestError extends Error {
30:
31: Throwable rootCause;
32:
33: public ExceptionDuringTestError(String message, Throwable rootCause) {
34: super (message);
35: this .rootCause = rootCause;
36: }
37:
38: public void printStackTrace() {
39: super .printStackTrace();
40: System.out.println("------------");
41: System.out.println("Root Cause:");
42: System.out.println("------------");
43: rootCause.printStackTrace();
44: if (rootCause instanceof ServletException) {
45: Throwable root2 = ((ServletException) rootCause)
46: .getRootCause();
47: if (root2 != null) {
48: System.out.println("------------");
49: System.out.println("Root Cause:");
50: System.out.println("------------");
51: root2.printStackTrace();
52: }
53: }
54: }
55:
56: public void printStackTrace(PrintStream stream) {
57: super .printStackTrace(stream);
58: stream.println("------------");
59: stream.println("Root Cause:");
60: stream.println("------------");
61: rootCause.printStackTrace(stream);
62: if (rootCause instanceof ServletException) {
63: Throwable root2 = ((ServletException) rootCause)
64: .getRootCause();
65: if (root2 != null) {
66: stream.println("------------");
67: stream.println("Root Cause:");
68: stream.println("------------");
69: root2.printStackTrace(stream);
70: }
71: }
72: }
73:
74: public void printStackTrace(PrintWriter stream) {
75: super .printStackTrace(stream);
76: stream.println("------------");
77: stream.println("Root Cause:");
78: stream.println("------------");
79: rootCause.printStackTrace(stream);
80: if (rootCause instanceof ServletException) {
81: Throwable root2 = ((ServletException) rootCause)
82: .getRootCause();
83: if (root2 != null) {
84: stream.println("------------");
85: stream.println("Root Cause:");
86: stream.println("------------");
87: root2.printStackTrace(stream);
88: }
89: }
90: }
91: }
|