KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > framework > test > CascadingRuntimeExceptionTestCase


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

17
18 package org.apache.avalon.framework.test;
19
20 import org.apache.avalon.framework.CascadingRuntimeException;
21 import org.apache.avalon.framework.CascadingThrowable;
22
23 import junit.framework.TestCase;
24
25 /**
26  * TestCase for {@link CascadingRuntimeException}.
27  *
28  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
29  * @version CVS $Revision: 1.2 $ $Date: 2004/02/21 13:27:02 $
30  */

31 public class CascadingRuntimeExceptionTestCase extends TestCase
32 {
33     public void testConstructor()
34     {
35         assertNotNull( new CascadingRuntimeException( null, null ) );
36         assertNotNull( new CascadingRuntimeException( "msg", null ) );
37         assertNotNull(
38                 new CascadingRuntimeException( "msg", new RuntimeException JavaDoc() ) );
39         assertNotNull(
40                 new CascadingRuntimeException( null, new RuntimeException JavaDoc() ) );
41     }
42
43     public void testGetCause()
44     {
45         RuntimeException JavaDoc re = new RuntimeException JavaDoc();
46         CascadingRuntimeException e = new CascadingRuntimeException( "msg",
47                 re );
48
49         assertEquals( re, e.getCause() );
50
51         e = new CascadingRuntimeException( "msg", null );
52         assertNull( e.getCause() );
53
54         // default to jdk 1.3 cause (not that it seems to help,
55
// but it still makes sense)
56
/*Exception exc = new Exception("blah");
57         try
58         {
59             try
60             {
61                 throw exc;
62             }
63             catch( Exception ex )
64             {
65                 throw new CascadingRuntimeException();
66             }
67         }
68         catch( CascadingRuntimeException ex )
69         {
70             ex.getCause();
71         }*/

72     }
73
74     public void testCasts()
75     {
76         CascadingRuntimeException e = new CascadingRuntimeException( "msg",
77                 null );
78         assertTrue( e instanceof RuntimeException JavaDoc );
79         assertTrue( e instanceof CascadingThrowable );
80     }
81 }
82
Popular Tags