KickJava   Java API By Example, From Geeks To Geeks.

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


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

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