001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.lang.exception;
018:
019: import java.io.EOFException;
020:
021: import junit.framework.Test;
022: import junit.framework.TestSuite;
023: import junit.textui.TestRunner;
024:
025: /**
026: * Tests the org.apache.commons.lang.exception.NestableError class.
027: *
028: * @author <a href="mailto:steven@caswell.name">Steven Caswell</a>
029: * @version $Id: NestableErrorTestCase.java 437554 2006-08-28 06:21:41Z bayard $
030: */
031: public class NestableErrorTestCase extends AbstractNestableTestCase {
032:
033: /**
034: * Construct a new instance of
035: * <code>NestableErrorTestCase</code>.
036: *
037: * @param name test case name
038: */
039: public NestableErrorTestCase(String name) {
040: super (name);
041: }
042:
043: /**
044: * Sets up instance variables required by this test case.
045: */
046: public void setUp() {
047: }
048:
049: /**
050: * Returns the test suite
051: *
052: * @return the test suite
053: */
054: public static Test suite() {
055: return new TestSuite(NestableErrorTestCase.class);
056: }
057:
058: /**
059: * Tears down instance variables required by this test case.
060: */
061: public void tearDown() {
062: }
063:
064: /**
065: * Command line entry point for running the test suite.
066: *
067: * @param args array of command line arguments
068: */
069: public static void main(String args[]) {
070: TestRunner.run(suite());
071: }
072:
073: /**
074: * @see AbstractNestableTestCase#getNestable()
075: */
076: public Nestable getNestable() {
077: return new NestableError();
078: }
079:
080: /**
081: * @see AbstractNestableTestCase#getNestable(Nestable)
082: */
083: public Nestable getNestable(Nestable n) {
084: return new NestableError((Throwable) n);
085: }
086:
087: /**
088: * @see AbstractNestableTestCase#getNestable(String)
089: */
090: public Nestable getNestable(String msg) {
091: return new NestableError(msg);
092: }
093:
094: /**
095: * @see AbstractNestableTestCase#getNestable(Throwable)
096: */
097: public Nestable getNestable(Throwable t) {
098: return new NestableError(t);
099: }
100:
101: /**
102: * @see AbstractNestableTestCase#getNestable(String, Throwable)
103: */
104: public Nestable getNestable(String msg, Throwable t) {
105: return new NestableError(msg, t);
106: }
107:
108: /**
109: * @see AbstractNestableTestCase#getNestable(String, Nestable)
110: */
111: public Nestable getNestable(String msg, Nestable n) {
112: return new NestableError(msg, (Throwable) n);
113: }
114:
115: /**
116: * @see AbstractNestableTestCase#getTester1(Throwable)
117: */
118: public Nestable getTester1(Throwable t) {
119: return new NestableErrorTester1(t);
120: }
121:
122: /**
123: * @see AbstractNestableTestCase#getTester1(Nestable)
124: */
125: public Nestable getTester1(Nestable n) {
126: return new NestableErrorTester1((Throwable) n);
127: }
128:
129: /**
130: * @see AbstractNestableTestCase#getTester1(String, Throwable)
131: */
132: public Nestable getTester1(String msg, Throwable t) {
133: return new NestableErrorTester1(msg, t);
134: }
135:
136: /**
137: * @see AbstractNestableTestCase#getTester1(String, Nestable)
138: */
139: public Nestable getTester1(String msg, Nestable n) {
140: return new NestableErrorTester1(msg, (Throwable) n);
141: }
142:
143: /**
144: * @see AbstractNestableTestCase#getTester1Class()
145: */
146: public Class getTester1Class() {
147: return NestableErrorTester1.class;
148: }
149:
150: /**
151: * @see AbstractNestableTestCase#getTester2(String, Throwable)
152: */
153: public Nestable getTester2(String msg, Throwable t) {
154: return new NestableErrorTester2(msg, t);
155: }
156:
157: /**
158: * @see AbstractNestableTestCase#getTester2(String, Nestable)
159: */
160: public Nestable getTester2(String msg, Nestable n) {
161: return new NestableErrorTester2(msg, (Throwable) n);
162: }
163:
164: /**
165: * @see AbstractNestableTestCase#getTester2Class()
166: */
167: public Class getTester2Class() {
168: return NestableErrorTester2.class;
169: }
170:
171: /**
172: * @see AbstractNestableTestCase#getThrowable(String)
173: */
174: public Throwable getThrowable(String msg) {
175: return new EOFException(msg);
176: }
177:
178: /**
179: * @see AbstractNestableTestCase#getThrowableClass()
180: */
181: public Class getThrowableClass() {
182: return EOFException.class;
183: }
184:
185: /**
186: * @see AbstractNestableTestCase#getBaseThrowableClass()
187: */
188: public Class getBaseThrowableClass() {
189: return Error.class;
190: }
191:
192: }
193:
194: /**
195: * First nestable tester implementation for use in test cases.
196: */
197: class NestableErrorTester1 extends NestableError {
198: public NestableErrorTester1() {
199: super ();
200: }
201:
202: public NestableErrorTester1(String reason, Throwable cause) {
203: super (reason, cause);
204: }
205:
206: public NestableErrorTester1(String reason) {
207: super (reason);
208: }
209:
210: public NestableErrorTester1(Throwable cause) {
211: super (cause);
212: }
213:
214: }
215:
216: /**
217: * Second nestable tester implementation for use in test cases.
218: */
219: class NestableErrorTester2 extends NestableError {
220: public NestableErrorTester2() {
221: super ();
222: }
223:
224: public NestableErrorTester2(String reason, Throwable cause) {
225: super (reason, cause);
226: }
227:
228: public NestableErrorTester2(String reason) {
229: super (reason);
230: }
231:
232: public NestableErrorTester2(Throwable cause) {
233: super(cause);
234: }
235:
236: }
|