KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > impl > test > ComponentHandlerEntryTestCase


1 /*
2  * Copyright 2003-2004 The 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.fortress.impl.test;
19
20 import junit.framework.TestCase;
21 import org.apache.avalon.fortress.impl.ComponentHandlerEntry;
22 import org.apache.avalon.fortress.impl.ComponentHandlerMetaData;
23 import org.apache.avalon.fortress.impl.handler.ComponentHandler;
24 import org.apache.avalon.fortress.test.data.Component1;
25 import org.apache.avalon.framework.configuration.DefaultConfiguration;
26
27 /**
28  * ComponentHandlerEntryTestCase does XYZ
29  *
30  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
31  * @version CVS $ Revision: 1.1 $
32  */

33 public class ComponentHandlerEntryTestCase extends TestCase
34 {
35     public ComponentHandlerEntryTestCase( String JavaDoc name )
36     {
37         super( name );
38     }
39
40     public void testComponentHandlerEntry()
41     {
42         ComponentHandler handler = new TestComponentHandler();
43         ComponentHandlerMetaData meta = new ComponentHandlerMetaData(
44             "component1", Component1.class.getName(),
45             new DefaultConfiguration( "test" ), true );
46         ComponentHandlerEntry entry = new ComponentHandlerEntry( handler, meta );
47
48         assertNotNull( entry );
49         assertNotNull( entry.getHandler() );
50         assertNotNull( entry.getMetaData() );
51
52         assertEquals( handler, entry.getHandler() );
53         assertSame( handler, entry.getHandler() );
54
55         assertEquals( meta, entry.getMetaData() );
56         assertSame( meta, entry.getMetaData() );
57     }
58
59     public void testNullPointerException()
60     {
61         ComponentHandler handler = new TestComponentHandler();
62         ComponentHandlerMetaData meta = new ComponentHandlerMetaData(
63             "component1", Component1.class.getName(),
64             new DefaultConfiguration( "test" ), true );
65
66         try
67         {
68             new ComponentHandlerEntry( null, meta );
69             fail( "No NullPointerException was thrown" );
70         }
71         catch ( NullPointerException JavaDoc npe )
72         {
73             // SUCCESS!!
74
}
75         catch ( Exception JavaDoc e )
76         {
77             fail( "Incorrect exception thrown: " + e.getClass().getName() );
78         }
79
80         try
81         {
82             new ComponentHandlerEntry( handler, null );
83             fail( "No NullPointerException was thrown" );
84         }
85         catch ( NullPointerException JavaDoc npe )
86         {
87             // SUCCESS!!
88
}
89         catch ( Exception JavaDoc e )
90         {
91             fail( "Incorrect exception thrown: " + e.getClass().getName() );
92         }
93     }
94 }
95
Popular Tags