KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > lang > exception > NestableErrorTestCase


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.lang.exception;
17
18 import java.io.EOFException JavaDoc;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22 import junit.textui.TestRunner;
23
24 /**
25  * Tests the org.apache.commons.lang.exception.NestableError class.
26  *
27  * @author <a HREF="mailto:steven@caswell.name">Steven Caswell</a>
28  * @version $Id: NestableErrorTestCase.java 161244 2005-04-14 06:16:36Z ggregory $
29  */

30 public class NestableErrorTestCase extends AbstractNestableTestCase {
31     
32     /**
33      * Construct a new instance of
34      * <code>NestableErrorTestCase</code>.
35      *
36      * @param name test case name
37      */

38     public NestableErrorTestCase(String JavaDoc name)
39     {
40         super(name);
41     }
42
43     /**
44      * Sets up instance variables required by this test case.
45      */

46     public void setUp()
47     {
48     }
49
50     /**
51      * Returns the test suite
52      *
53      * @return the test suite
54      */

55     public static Test suite()
56     {
57         return new TestSuite(NestableErrorTestCase.class);
58     }
59     
60     /**
61      * Tears down instance variables required by this test case.
62      */

63     public void tearDown()
64     {
65     }
66
67     /**
68      * Command line entry point for running the test suite.
69      *
70      * @param args array of command line arguments
71      */

72     public static void main(String JavaDoc args[])
73     {
74         TestRunner.run(suite());
75     }
76
77     /**
78      * @see AbstractNestableTestCase#getNestable()
79      */

80     public Nestable getNestable()
81     {
82         return new NestableError();
83     }
84     
85     /**
86      * @see AbstractNestableTestCase#getNestable(Nestable)
87      */

88     public Nestable getNestable(Nestable n)
89     {
90         return new NestableError((Throwable JavaDoc) n);
91     }
92     
93     /**
94      * @see AbstractNestableTestCase#getNestable(String)
95      */

96     public Nestable getNestable(String JavaDoc msg)
97     {
98         return new NestableError(msg);
99     }
100     
101     /**
102      * @see AbstractNestableTestCase#getNestable(Throwable)
103      */

104     public Nestable getNestable(Throwable JavaDoc t)
105     {
106         return new NestableError(t);
107     }
108     
109     /**
110      * @see AbstractNestableTestCase#getNestable(String, Throwable)
111      */

112     public Nestable getNestable(String JavaDoc msg, Throwable JavaDoc t)
113     {
114         return new NestableError(msg, t);
115     }
116     
117     /**
118      * @see AbstractNestableTestCase#getNestable(String, Nestable)
119      */

120     public Nestable getNestable(String JavaDoc msg, Nestable n)
121     {
122         return new NestableError(msg, (Throwable JavaDoc) n);
123     }
124     
125     /**
126      * @see AbstractNestableTestCase#getTester1(Throwable)
127      */

128     public Nestable getTester1(Throwable JavaDoc t)
129     {
130         return new NestableErrorTester1(t);
131     }
132     
133     /**
134      * @see AbstractNestableTestCase#getTester1(Nestable)
135      */

136     public Nestable getTester1(Nestable n)
137     {
138         return new NestableErrorTester1((Throwable JavaDoc) n);
139     }
140     
141     /**
142      * @see AbstractNestableTestCase#getTester1(String, Throwable)
143      */

144     public Nestable getTester1(String JavaDoc msg, Throwable JavaDoc t)
145     {
146         return new NestableErrorTester1(msg, t);
147     }
148     
149     /**
150      * @see AbstractNestableTestCase#getTester1(String, Nestable)
151      */

152     public Nestable getTester1(String JavaDoc msg, Nestable n)
153     {
154         return new NestableErrorTester1(msg, (Throwable JavaDoc) n);
155     }
156     
157     /**
158      * @see AbstractNestableTestCase#getTester1Class()
159      */

160     public Class JavaDoc getTester1Class()
161     {
162         return NestableErrorTester1.class;
163     }
164     
165     /**
166      * @see AbstractNestableTestCase#getTester2(String, Throwable)
167      */

168     public Nestable getTester2(String JavaDoc msg, Throwable JavaDoc t)
169     {
170         return new NestableErrorTester2(msg, t);
171     }
172     
173     /**
174      * @see AbstractNestableTestCase#getTester2(String, Nestable)
175      */

176     public Nestable getTester2(String JavaDoc msg, Nestable n)
177     {
178         return new NestableErrorTester2(msg, (Throwable JavaDoc) n);
179     }
180     
181     /**
182      * @see AbstractNestableTestCase#getTester2Class()
183      */

184     public Class JavaDoc getTester2Class()
185     {
186         return NestableErrorTester2.class;
187     }
188     
189     /**
190      * @see AbstractNestableTestCase#getThrowable(String)
191      */

192     public Throwable JavaDoc getThrowable(String JavaDoc msg)
193     {
194         return new EOFException JavaDoc(msg);
195     }
196     
197     /**
198      * @see AbstractNestableTestCase#getThrowableClass()
199      */

200     public Class JavaDoc getThrowableClass()
201     {
202         return EOFException JavaDoc.class;
203     }
204     
205     /**
206      * @see AbstractNestableTestCase#getBaseThrowableClass()
207      */

208     public Class JavaDoc getBaseThrowableClass()
209     {
210         return Error JavaDoc.class;
211     }
212     
213 }
214
215 /**
216  * First nestable tester implementation for use in test cases.
217  */

218 class NestableErrorTester1 extends NestableError
219 {
220     public NestableErrorTester1()
221     {
222         super();
223     }
224
225     public NestableErrorTester1(String JavaDoc reason, Throwable JavaDoc cause)
226     {
227         super(reason, cause);
228     }
229     
230     public NestableErrorTester1(String JavaDoc reason)
231     {
232         super(reason);
233     }
234     
235     public NestableErrorTester1(Throwable JavaDoc cause)
236     {
237         super(cause);
238     }
239     
240 }
241
242 /**
243  * Second nestable tester implementation for use in test cases.
244  */

245 class NestableErrorTester2 extends NestableError
246 {
247     public NestableErrorTester2()
248     {
249         super();
250     }
251     
252     public NestableErrorTester2(String JavaDoc reason, Throwable JavaDoc cause)
253     {
254         super(reason, cause);
255     }
256     
257     public NestableErrorTester2(String JavaDoc reason)
258     {
259         super(reason);
260     }
261     
262     public NestableErrorTester2(Throwable JavaDoc cause)
263     {
264         super(cause);
265     }
266     
267 }
268
Popular Tags