KickJava   Java API By Example, From Geeks To Geeks.

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


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.ByteArrayOutputStream JavaDoc;
19 import java.io.EOFException JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.io.PrintStream JavaDoc;
22 import java.io.PrintWriter JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26 import junit.textui.TestRunner;
27
28 /**
29  * Tests the org.apache.commons.lang.exception.NestableDelegate class.
30  *
31  * @author <a HREF="mailto:steven@caswell.name">Steven Caswell</a>
32  * @author <a HREF="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
33  * @version $Id: NestableDelegateTestCase.java 161244 2005-04-14 06:16:36Z ggregory $
34  */

35 public class NestableDelegateTestCase extends junit.framework.TestCase {
36     private static final String JavaDoc CONSTRUCTOR_FAILED_MSG =
37     "The Nestable implementation passed to the NestableDelegate(Nestable) constructor must extend java.lang.Throwable";
38
39     private static final String JavaDoc PARTIAL_STACK_TRACE =
40         "ThrowableNestedNestable partial stack trace place-holder";
41
42     protected String JavaDoc lineSeparator;
43
44     /**
45      * Construct a new instance of NestableDelegateTestCase with the specified name
46      */

47     public NestableDelegateTestCase(String JavaDoc name)
48     {
49         super(name);
50     }
51
52     /**
53      * Set up instance variables required by this test case.
54      */

55     public void setUp()
56     {
57         lineSeparator = System.getProperty("line.separator");
58     }
59     
60     public static Test suite()
61     {
62         return new TestSuite(NestableDelegateTestCase.class);
63     }
64     
65     /**
66      * Tear down instance variables required by this test case.
67      */

68     public void tearDown()
69     {
70         lineSeparator = null;
71     }
72     
73     /**
74      * Test the implementation
75      */

76     public void testNestableDelegateConstructor()
77     {
78         String JavaDoc msg = null;
79         boolean constructorFailed = false;
80         try
81         {
82             NestableDelegate nonThrowableCause = new NestableDelegate(new NonThrowableNestable());
83         }
84         catch(IllegalArgumentException JavaDoc iae)
85         {
86             constructorFailed = true;
87             msg = iae.getMessage();
88         }
89         assertTrue("nestable delegate constructor with non-throwable cause failed == true", constructorFailed);
90         assertTrue("constructor failed exception msg == " + CONSTRUCTOR_FAILED_MSG,
91             msg.equals(CONSTRUCTOR_FAILED_MSG));
92
93         constructorFailed = false;
94         try
95         {
96             NestableDelegate nd1 = new NestableDelegate(new ThrowableNestable());
97         }
98         catch(IllegalArgumentException JavaDoc iae)
99         {
100             constructorFailed = true;
101         }
102         assertTrue("nestable delegate constructor with throwable cause failed == false", !constructorFailed);
103     }
104
105     public void testNestableDelegateGetMessage()
106     {
107         Nestable ne1 = new ThrowableNestable();
108         assertTrue("ThrowableNestable ne1 getMessage() == ThrowableNestable exception",
109             ne1.getMessage().equals("ThrowableNestable exception"));
110         NestableDelegate nd1 = new NestableDelegate(ne1);
111         assertTrue("nd1 getMessage() == " + ne1.getCause().getMessage(),
112             nd1.getMessage("base").equals("base: " + ne1.getCause().getMessage()));
113         
114         Nestable ne2 = new ThrowableNestedNestable(new Exception JavaDoc("nested exception 2"));
115         NestableDelegate nd2 = new NestableDelegate(ne2);
116         assertTrue("nd2 getMessage() == base: " + ne2.getCause().getMessage(),
117             nd2.getMessage("base").equals("base: " + ne2.getCause().getMessage()));
118     }
119
120     public void testNestableDelegateGetThrowableCount()
121     {
122         Nestable n = null;
123         NestableDelegate d = null;
124         
125         n = new NestableDelegateTester1();
126         d = new NestableDelegate(n);
127         doNestableDelegateGetThrowableCount(d, 1);
128         
129         n = new NestableDelegateTester1("level 1");
130         d = new NestableDelegate(n);
131         doNestableDelegateGetThrowableCount(d, 1);
132         
133         n = new NestableDelegateTester1(new Exception JavaDoc());
134         d = new NestableDelegate(n);
135         doNestableDelegateGetThrowableCount(d, 2);
136         
137         n = new NestableDelegateTester1(new Exception JavaDoc("level 2"));
138         d = new NestableDelegate(n);
139         doNestableDelegateGetThrowableCount(d, 2);
140         
141         n = new NestableDelegateTester1("level 1",
142                 new NestableDelegateTester2("level 2",
143                     new NestableDelegateTester1(
144                         new NestableDelegateTester2("level 4",
145                             new Exception JavaDoc("level 5")
146                         )
147                     )
148                 )
149             );
150         d = new NestableDelegate(n);
151         doNestableDelegateGetThrowableCount(d, 5);
152     }
153
154     private void doNestableDelegateGetThrowableCount(NestableDelegate d, int len)
155     {
156         // Compare the lengths
157
assertEquals("delegate length", len, d.getThrowableCount());
158     }
159     
160     public void testNestableDelegateGetMessages()
161     {
162         Nestable n = null;
163         NestableDelegate d = null;
164         String JavaDoc msgs[] = null;
165         
166         msgs = new String JavaDoc[1];
167         n = new NestableDelegateTester1();
168         d = new NestableDelegate(n);
169         doNestableDelegateGetMessages(d, msgs);
170         
171         msgs = new String JavaDoc[1];
172         msgs[0] = "level 1";
173         n = new NestableDelegateTester1(msgs[0]);
174         d = new NestableDelegate(n);
175         doNestableDelegateGetMessages(d, msgs);
176
177         msgs = new String JavaDoc[2];
178         n = new NestableDelegateTester1(new Exception JavaDoc());
179         d = new NestableDelegate(n);
180         doNestableDelegateGetMessages(d, msgs);
181
182         msgs = new String JavaDoc[2];
183         msgs[0] = null;
184         msgs[1] = "level 2";
185         n = new NestableDelegateTester1(new Exception JavaDoc(msgs[1]));
186         d = new NestableDelegate(n);
187         doNestableDelegateGetMessages(d, msgs);
188  
189         msgs = new String JavaDoc[5];
190         msgs[0] = "level 1";
191         msgs[1] = "level 2";
192         msgs[2] = null;
193         msgs[3] = "level 4";
194         msgs[4] = "level 5";
195         n = new NestableDelegateTester1(msgs[0],
196                 new NestableDelegateTester2(msgs[1],
197                     new NestableDelegateTester1(
198                         new NestableDelegateTester2(msgs[3],
199                             new Exception JavaDoc(msgs[4])
200                         )
201                     )
202                 )
203             );
204         d = new NestableDelegate(n);
205         doNestableDelegateGetMessages(d, msgs);
206     }
207
208     private void doNestableDelegateGetMessages(NestableDelegate d, String JavaDoc[] nMsgs)
209     {
210         // Compare the messages
211
String JavaDoc[] dMsgs = d.getMessages();
212         assertEquals("messages length", nMsgs.length, dMsgs.length);
213         for(int i = 0; i < nMsgs.length; i++)
214         {
215             assertEquals("message " + i, nMsgs[i], dMsgs[i]);
216         }
217     }
218
219     public void testNestableDelegateGetMessageN()
220     {
221         Nestable n = null;
222         NestableDelegate d = null;
223         String JavaDoc[] msgs = new String JavaDoc[5];
224         msgs[0] = "level 1";
225         msgs[1] = "level 2";
226         msgs[2] = null;
227         msgs[3] = "level 4";
228         msgs[4] = "level 5";
229         n = new NestableDelegateTester1(msgs[0],
230                 new NestableDelegateTester2(msgs[1],
231                     new NestableDelegateTester1(
232                         new NestableDelegateTester2(msgs[3],
233                             new Exception JavaDoc(msgs[4])
234                         )
235                     )
236                 )
237             );
238         d = new NestableDelegate(n);
239         for(int i = 0; i < msgs.length; i++)
240         {
241             assertEquals("message " + i, msgs[i], d.getMessage(i));
242         }
243         
244         // Test for index out of bounds
245
try
246         {
247             String JavaDoc msg = d.getMessage(-1);
248             fail("getMessage(-1) should have thrown IndexOutOfBoundsException");
249         }
250         catch(IndexOutOfBoundsException JavaDoc ioode)
251         {
252         }
253         try
254         {
255             String JavaDoc msg = d.getMessage(msgs.length + 100);
256             fail("getMessage(999) should have thrown IndexOutOfBoundsException");
257         }
258         catch(IndexOutOfBoundsException JavaDoc ioode)
259         {
260         }
261     }
262
263     public void testNestableDelegateGetThrowableN()
264     {
265         Nestable n = null;
266         NestableDelegate d = null;
267         String JavaDoc msgs[] = null;
268         Class JavaDoc[] throwables = null;
269         
270         msgs = new String JavaDoc[2];
271         msgs[0] = null;
272         msgs[1] = "level 2";
273         throwables = new Class JavaDoc[2];
274         throwables[0] = NestableDelegateTester1.class;
275         throwables[1] = Exception JavaDoc.class;
276         n = new NestableDelegateTester1(new Exception JavaDoc(msgs[1]));
277         d = new NestableDelegate(n);
278         doNestableDelegateGetThrowableN(d, throwables, msgs);
279  
280         msgs = new String JavaDoc[5];
281         msgs[0] = "level 1";
282         msgs[1] = "level 2";
283         msgs[2] = null;
284         msgs[3] = "level 4";
285         msgs[4] = "level 5";
286         throwables = new Class JavaDoc[5];
287         throwables[0] = NestableDelegateTester1.class;
288         throwables[1] = NestableDelegateTester2.class;
289         throwables[2] = NestableDelegateTester1.class;
290         throwables[3] = NestableDelegateTester2.class;
291         throwables[4] = Exception JavaDoc.class;
292         n = new NestableDelegateTester1(msgs[0],
293                 new NestableDelegateTester2(msgs[1],
294                     new NestableDelegateTester1(
295                         new NestableDelegateTester2(msgs[3],
296                             new Exception JavaDoc(msgs[4])
297                             )
298                         )
299                     )
300                 );
301         d = new NestableDelegate(n);
302         doNestableDelegateGetThrowableN(d, throwables, msgs);
303     }
304
305     private void doNestableDelegateGetThrowableN(NestableDelegate d, Class JavaDoc[] classes, String JavaDoc[] msgs)
306     {
307         Throwable JavaDoc t = null;
308         String JavaDoc msg = null;
309         
310         for(int i = 0; i < classes.length; i++)
311         {
312             t = d.getThrowable(i);
313             assertEquals("throwable class", classes[i], t.getClass());
314             if(Nestable.class.isInstance(t))
315             {
316                 msg = ((Nestable) t).getMessage(0);
317             }
318             else
319             {
320                 msg = t.getMessage();
321             }
322             assertEquals("throwable message", msgs[i], msg);
323         }
324         
325         // Test for index out of bounds
326
try
327         {
328             t = d.getThrowable(-1);
329             fail("getThrowable(-1) should have thrown IndexOutOfBoundsException");
330         }
331         catch(IndexOutOfBoundsException JavaDoc ioobe)
332         {
333         }
334         try
335         {
336             t = d.getThrowable(999);
337             fail("getThrowable(999) should have thrown IndexOutOfBoundsException");
338         }
339         catch(IndexOutOfBoundsException JavaDoc ioobe)
340         {
341         }
342     }
343
344     public void testNestableDelegateGetThrowables()
345     {
346         Nestable n = null;
347         NestableDelegate d = null;
348         String JavaDoc msgs[] = null;
349         Class JavaDoc[] throwables = null;
350         
351         msgs = new String JavaDoc[2];
352         msgs[0] = null;
353         msgs[1] = "level 2";
354         throwables = new Class JavaDoc[2];
355         throwables[0] = NestableDelegateTester1.class;
356         throwables[1] = Exception JavaDoc.class;
357         n = new NestableDelegateTester1(new Exception JavaDoc(msgs[1]));
358         d = new NestableDelegate(n);
359         doNestableDelegateGetThrowables(d, throwables, msgs);
360  
361         msgs = new String JavaDoc[5];
362         msgs[0] = "level 1";
363         msgs[1] = "level 2";
364         msgs[2] = null;
365         msgs[3] = "level 4";
366         msgs[4] = "level 5";
367         throwables = new Class JavaDoc[5];
368         throwables[0] = NestableDelegateTester1.class;
369         throwables[1] = NestableDelegateTester2.class;
370         throwables[2] = NestableDelegateTester1.class;
371         throwables[3] = NestableDelegateTester2.class;
372         throwables[4] = Exception JavaDoc.class;
373         n = new NestableDelegateTester1(msgs[0],
374                 new NestableDelegateTester2(msgs[1],
375                     new NestableDelegateTester1(
376                         new NestableDelegateTester2(msgs[3],
377                             new Exception JavaDoc(msgs[4])
378                         )
379                     )
380                 )
381             );
382         d = new NestableDelegate(n);
383         doNestableDelegateGetThrowables(d, throwables, msgs);
384     }
385     
386     private void doNestableDelegateGetThrowables(NestableDelegate d, Class JavaDoc[] classes, String JavaDoc[] msgs)
387     {
388         Throwable JavaDoc[] throwables = null;
389         String JavaDoc msg = null;
390
391         throwables = d.getThrowables();
392         assertEquals("throwables length", classes.length, throwables.length);
393         for(int i = 0; i < classes.length; i++)
394         {
395             assertEquals("throwable class", classes[i], throwables[i].getClass());
396             Throwable JavaDoc t = throwables[i];
397             if(Nestable.class.isInstance(t))
398             {
399                 msg = ((Nestable) t).getMessage(0);
400             }
401             else
402             {
403                 msg = t.getMessage();
404             }
405             assertEquals("throwable message", msgs[i], msg);
406         }
407     }
408
409     public void testIndexOfThrowable()
410     {
411         Nestable n = null;
412         NestableDelegate d = null;
413         String JavaDoc msgs[] = null;
414         Class JavaDoc[] throwables = null;
415         
416         msgs = new String JavaDoc[5];
417         msgs[0] = "level 1";
418         msgs[1] = "level 2";
419         msgs[2] = null;
420         msgs[3] = "level 4";
421         msgs[4] = "level 5";
422         throwables = new Class JavaDoc[5];
423         throwables[0] = NestableDelegateTester1.class;
424         throwables[1] = NestableDelegateTester2.class;
425         throwables[2] = NestableDelegateTester1.class;
426         throwables[3] = NestableDelegateTester2.class;
427         throwables[4] = EOFException JavaDoc.class;
428         int[] indexes = {0, 1, 0, 1, 4};
429         n = new NestableDelegateTester1(msgs[0],
430                 new NestableDelegateTester2(msgs[1],
431                     new NestableDelegateTester1(
432                         new NestableDelegateTester2(msgs[3],
433                             new EOFException JavaDoc(msgs[4])
434                         )
435                     )
436                 )
437             );
438         d = new NestableDelegate(n);
439         for(int i = 0; i < throwables.length; i++)
440         {
441             doNestableDelegateIndexOfThrowable(d, throwables[i], 0, indexes[i], msgs[indexes[i]]);
442         }
443         doNestableDelegateIndexOfThrowable(d, NestableDelegateTester2.class, 2, 3, msgs[3]);
444         doNestableDelegateIndexOfThrowable(d, NestableDelegateTester1.class, 1, 2, msgs[2]);
445         doNestableDelegateIndexOfThrowable(d, NestableDelegateTester1.class, 3, -1, null);
446         doNestableDelegateIndexOfThrowable(d, NestableDelegateTester1.class, 4, -1, null);
447         doNestableDelegateIndexOfThrowable(d, EOFException JavaDoc.class, 2, 4, msgs[4]);
448         doNestableDelegateIndexOfThrowable(d, IOException JavaDoc.class, 2, 4, msgs[4]);
449         doNestableDelegateIndexOfThrowable(d, Exception JavaDoc.class, 2, 2, msgs[2]);
450         doNestableDelegateIndexOfThrowable(d, Exception JavaDoc.class, 0, 0, msgs[0]);
451         doNestableDelegateIndexOfThrowable(d, java.util.Date JavaDoc.class, 0, -1, null);
452         doNestableDelegateIndexOfThrowable(d, null, 0, -1, null);
453         
454         // Test for index out of bounds
455
try
456         {
457             int index = d.indexOfThrowable(NestableDelegateTester1.class, -1);
458             fail("method should have thrown IndexOutOfBoundsException");
459         }
460         catch(IndexOutOfBoundsException JavaDoc iooob)
461         {
462         }
463         try
464         {
465             int index = d.indexOfThrowable(NestableDelegateTester1.class, 5);
466             fail("method should have thrown IndexOutOfBoundsException");
467         }
468         catch(IndexOutOfBoundsException JavaDoc iooob)
469         {
470         }
471     }
472
473     private void doNestableDelegateIndexOfThrowable(NestableDelegate d, Class JavaDoc type, int fromIndex, int expectedIndex, String JavaDoc expectedMsg)
474     {
475         Throwable JavaDoc t = null;
476         
477         int index = d.indexOfThrowable(type, fromIndex);
478         assertEquals("index of throwable " + (type == null ? "null" : type.getName()), expectedIndex, index);
479         if(expectedIndex > -1)
480         {
481             t = d.getThrowable(index);
482             if(expectedMsg != null)
483             {
484                 String JavaDoc msg = null;
485                 if(Nestable.class.isInstance(t))
486                 {
487                     msg = ((Nestable) t).getMessage(0);
488                 }
489                 else
490                 {
491                     msg = t.getMessage();
492                 }
493                 assertEquals("message of indexed throwable", expectedMsg, msg);
494             }
495         }
496     }
497     
498     public void testNestableDelegetePrintStackTrace()
499     {
500         int lineSepLen = lineSeparator.length();
501         int partialStackTraceLen = PARTIAL_STACK_TRACE.length();
502         Nestable ne3 = new ThrowableNestedNestable(new Exception JavaDoc("nested exception 3"));
503         NestableDelegate nd3 = new NestableDelegate(ne3);
504
505         ByteArrayOutputStream JavaDoc baos1 = new ByteArrayOutputStream JavaDoc();
506         PrintStream JavaDoc ps1 = new PrintStream JavaDoc(baos1);
507         nd3.printStackTrace(ps1);
508         String JavaDoc stack1 = baos1.toString();
509         assertTrue("stack trace startsWith", stack1.startsWith(PARTIAL_STACK_TRACE));
510
511         Nestable n = new NestableDelegateTester1("level 1",
512                 new NestableDelegateTester2("level 2",
513                     new NestableDelegateTester1(
514                         new NestableDelegateTester2("level 4",
515                             new Exception JavaDoc("level 5")
516                         )
517                     )
518                 )
519             );
520         NestableDelegate d = new NestableDelegate(n);
521         
522         // Only testing the flags for jdk1.3 and below
523
if (!ExceptionUtils.isThrowableNested()) {
524             NestableDelegate.topDown = true; NestableDelegate.trimStackFrames = true;
525             checkStackTrace(d, true, true, NestableDelegateTester1.class.getName()+": level 1", 24);
526             NestableDelegate.topDown = true; NestableDelegate.trimStackFrames = false;
527             checkStackTrace(d, true, false, NestableDelegateTester1.class.getName()+": level 1", 80);
528             NestableDelegate.topDown = false; NestableDelegate.trimStackFrames = true;
529             checkStackTrace(d, false, true, "java.lang.Exception: level 5", 24);
530             NestableDelegate.topDown = false; NestableDelegate.trimStackFrames = false;
531             checkStackTrace(d, false, false, "java.lang.Exception: level 5", 80);
532             NestableDelegate.topDown = true; NestableDelegate.trimStackFrames = true;
533         }
534     }
535     private void checkStackTrace(NestableDelegate d, boolean topDown, boolean trimStackFrames,
536             String JavaDoc startsWith, int expCount) {
537         ByteArrayOutputStream JavaDoc baos1 = new ByteArrayOutputStream JavaDoc();
538         PrintStream JavaDoc ps1 = new PrintStream JavaDoc(baos1);
539         d.printStackTrace(ps1);
540         String JavaDoc stack1 = baos1.toString();
541         int actCount = countLines(stack1);
542         assertTrue("topDown: "+topDown+", trimStackFrames: "+trimStackFrames+" startsWith",
543             stack1.startsWith(startsWith));
544         // test is unreliable, as count varies depending on JUnit version/where main method is
545
// assertEquals("topDown: "+topDown+", trimStackFrames: "+trimStackFrames+" lineCount",
546
// expCount, actCount);
547
}
548     private int countLines(String JavaDoc s) {
549         if (s == null) return 0;
550         
551         int i = 0, ndx = -1;
552         while ((ndx = s.indexOf("\n", ndx+1)) != -1) {
553             i++;
554         }
555         return i;
556     }
557     
558     public static void main(String JavaDoc args[])
559     {
560         TestRunner.run(suite());
561     }
562 }
563
564 /**
565  * Nestable and Throwable class which can be passed to the NestableDelegate
566  * constructor. Used for testing various methods which iterate through the
567  * nested causes.
568  */

569 class NestableDelegateTester1 extends Exception JavaDoc implements Nestable
570 {
571     private Throwable JavaDoc cause = null;
572
573     public NestableDelegateTester1()
574     {
575         super();
576     }
577
578     public NestableDelegateTester1(String JavaDoc reason, Throwable JavaDoc cause)
579     {
580         super(reason);
581         this.cause = cause;
582     }
583     
584     public NestableDelegateTester1(String JavaDoc reason)
585     {
586         super(reason);
587     }
588     
589     public NestableDelegateTester1(Throwable JavaDoc cause)
590     {
591         super();
592         this.cause = cause;
593     }
594     
595     /**
596      * @see Nestable#getThrowables()
597      * Returns zero-length <code>Throwable</code> array for this test.
598      */

599     public Throwable JavaDoc[] getThrowables()
600     {
601         return new Throwable JavaDoc[0];
602     }
603     
604     /**
605      * @see Nestable#getMessages()
606      * Returns zero-length String array for this test.
607      */

608     public String JavaDoc[] getMessages()
609     {
610         return new String JavaDoc[0];
611     }
612     
613     /**
614      * @see Nestable#indexOfThrowable(Class)
615      * Returns -1 for this test.
616      */

617     public int indexOfThrowable(Class JavaDoc type)
618     {
619         return -1;
620     }
621     
622     /**
623      * @see Nestable#getThrowable(int)
624      * Returns <code>null</code> for this test.
625      */

626     public Throwable JavaDoc getThrowable(int index)
627     {
628         return null;
629     }
630     
631     /**
632      * @see Nestable#getThrowableCount()
633      * Returns 1 for this test.
634      */

635     public int getThrowableCount()
636     {
637         return 1;
638     }
639     
640     /**
641      * @see Nestable#getCause()
642      */

643     public Throwable JavaDoc getCause()
644     {
645         return cause;
646     }
647     
648     /**
649      * Empty method to satisfy the implemented interface. Does nothing
650      * in this test.
651      *
652      * @param out The writer to use.
653      */

654     public void printPartialStackTrace(PrintWriter JavaDoc out)
655     {
656         super.printStackTrace(out);
657     }
658     
659     /**
660      * @see Nestable#getMessage(int)
661      */

662     public String JavaDoc getMessage(int index)
663     {
664         if(index == 0)
665         {
666             return super.getMessage();
667         }
668         else
669         {
670             return "";
671         }
672     }
673     
674     /**
675      * @see Nestable#indexOfThrowable(Class, int)
676      * Returns -1 for this test.
677      */

678     public int indexOfThrowable(Class JavaDoc type, int fromIndex)
679     {
680         return -1;
681     }
682     
683 }
684
685 /**
686  * Nestable and Throwable class which can be passed to the NestableDelegate
687  * constructor. Used for testing various methods which iterate through the
688  * nested causes.
689  */

690 class NestableDelegateTester2 extends Throwable JavaDoc implements Nestable
691 {
692     private Throwable JavaDoc cause = null;
693
694     public NestableDelegateTester2()
695     {
696         super();
697     }
698     
699     public NestableDelegateTester2(String JavaDoc reason, Throwable JavaDoc cause)
700     {
701         super(reason);
702         this.cause = cause;
703     }
704     
705     public NestableDelegateTester2(String JavaDoc reason)
706     {
707         super(reason);
708     }
709     
710     public NestableDelegateTester2(Throwable JavaDoc cause)
711     {
712         super();
713         this.cause = cause;
714     }
715     
716     /**
717      * @see Nestable#getThrowables()
718      * Returns zero-length <code>Throwable</code> array for this test.
719      */

720     public Throwable JavaDoc[] getThrowables()
721     {
722         return new Throwable JavaDoc[0];
723     }
724     
725     /**
726      * @see Nestable#getMessages()
727      * Returns zero-length String array for this test.
728      */

729     public String