KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servletunit > struts > ExceptionDuringTestError


1 // StrutsTestCase - a JUnit extension for testing Struts actions
2
// within the context of the ActionServlet.
3
// Copyright (C) 2002 Deryl Seale
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the Apache Software License as
7
// published by the Apache Software Foundation; either version 1.1
8
// of the License, or (at your option) any later version.
9
//
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 JavaDoc;
20 /**
21  * <p>Title: ExceptionDuringTestError</p>
22  * <p>Description: An error indicating an uncaught exception
23  * occurred during testing</p>
24  * <p>Copyright: Copyright (c) 2003</p>
25  * @author Sean Pritchard
26  * @version 1.0
27  */

28 public class ExceptionDuringTestError extends Error JavaDoc {
29
30     Throwable JavaDoc rootCause;
31
32     public ExceptionDuringTestError(String JavaDoc message, Throwable JavaDoc rootCause) {
33         super(message);
34         this.rootCause = rootCause;
35     }
36
37     public void printStackTrace(){
38         super.printStackTrace();
39         System.out.println("------------");
40         System.out.println("Root Cause:");
41         System.out.println("------------");
42         rootCause.printStackTrace();
43         if (rootCause instanceof ServletException JavaDoc){
44             Throwable JavaDoc root2 = ((ServletException JavaDoc)rootCause).getRootCause();
45             if(root2!=null){
46                 System.out.println("------------");
47                 System.out.println("Root Cause:");
48                 System.out.println("------------");
49                 root2.printStackTrace();
50             }
51         }
52     }
53
54     public void printStackTrace(PrintStream stream){
55         super.printStackTrace(stream);
56         stream.println("------------");
57         stream.println("Root Cause:");
58         stream.println("------------");
59         rootCause.printStackTrace(stream);
60         if (rootCause instanceof ServletException JavaDoc){
61             Throwable JavaDoc root2 = ((ServletException JavaDoc)rootCause).getRootCause();
62             if(root2!=null){
63                 stream.println("------------");
64                 stream.println("Root Cause:");
65                 stream.println("------------");
66                 root2.printStackTrace(stream);
67             }
68         }
69     }
70
71     public void printStackTrace(PrintWriter stream){
72         super.printStackTrace(stream);
73         stream.println("------------");
74         stream.println("Root Cause:");
75         stream.println("------------");
76         rootCause.printStackTrace(stream);
77         if (rootCause instanceof ServletException JavaDoc){
78             Throwable JavaDoc root2 = ((ServletException JavaDoc)rootCause).getRootCause();
79             if(root2!=null){
80                 stream.println("------------");
81                 stream.println("Root Cause:");
82                 stream.println("------------");
83                 root2.printStackTrace(stream);
84             }
85         }
86     }
87 }
Popular Tags