KickJava   Java API By Example, From Geeks To Geeks.

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


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.CascadingException;
21 import org.apache.avalon.framework.CascadingThrowable;
22
23 import junit.framework.TestCase;
24
25 /**
26  * TestCase for {@link CascadingException}.
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 CascadingExceptionTestCase extends TestCase
32 {
33     public void testConstructor()
34     {
35         assertNotNull( new CascadingException( null, null ) );
36         assertNotNull( new CascadingException( "msg", null ) );
37         assertNotNull(
38                 new CascadingException( "msg", new RuntimeException JavaDoc() ) );
39         assertNotNull( new CascadingException( null, new RuntimeException JavaDoc() ) );
40
41         assertNotNull( new CascadingException( "msg" ) );
42         // ambiguous assertNotNull( new CascadingException( null ) );
43
//assertNotNull( new CascadingException() );
44
}
45
46     public void testGetCause()
47     {
48         RuntimeException JavaDoc re = new RuntimeException JavaDoc();
49         CascadingException e = new CascadingException( "msg", re );
50
51         assertEquals( re, e.getCause() );
52
53         e = new CascadingException( "msg", null );
54         assertNull( e.getCause() );
55
56         // default to jdk 1.3 cause (not that it seems to help,
57
// but it still makes sense)
58
/*Exception exc = new Exception("blah");
59         try
60         {
61             try
62             {
63                 throw exc;
64             }
65             catch( Exception ex )
66             {
67                 throw new CascadingException();
68             }
69         }
70         catch( CascadingException ex )
71         {
72             ex.getCause();
73         }*/

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