KickJava   Java API By Example, From Geeks To Geeks.

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


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.ComponentHandlerMetaData;
22 import org.apache.avalon.fortress.test.data.Component1;
23 import org.apache.avalon.framework.configuration.DefaultConfiguration;
24
25 /**
26  * ComponentHandlerMetaDataTestCase does XYZ
27  *
28  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
29  * @version CVS $ Revision: 1.1 $
30  */

31 public class ComponentHandlerMetaDataTestCase extends TestCase
32 {
33     public ComponentHandlerMetaDataTestCase( String JavaDoc name )
34     {
35         super( name );
36     }
37
38     public void testMetaData()
39     {
40         ComponentHandlerMetaData meta = new ComponentHandlerMetaData( "component1",
41             Component1.class.getName(), new DefaultConfiguration( "test" ), true );
42
43         assertNotNull( meta );
44         assertNotNull( meta.getClassname() );
45         assertNotNull( meta.getConfiguration() );
46         assertNotNull( meta.getName() );
47         assertEquals( true, meta.isLazyActivation() );
48         assertEquals( "component1", meta.getName() );
49         assertEquals( Component1.class.getName(), meta.getClassname() );
50         assertEquals( "test", meta.getConfiguration().getName() );
51     }
52
53     public void testNullPointerException()
54     {
55         try
56         {
57             new ComponentHandlerMetaData( null, Component1.class.getName(),
58                 new DefaultConfiguration( "test" ), false );
59
60             fail( "No NullPointerException was thrown" );
61         }
62         catch ( NullPointerException JavaDoc npe )
63         {
64             // SUCCESS!!
65
}
66         catch ( Exception JavaDoc e )
67         {
68             fail( "Did not throw the correct exception: " + e.getClass().getName() );
69         }
70
71         try
72         {
73             new ComponentHandlerMetaData( "component1", null,
74                 new DefaultConfiguration( "test" ), false );
75
76             fail( "No NullPointerException was thrown" );
77         }
78         catch ( NullPointerException JavaDoc npe )
79         {
80             // SUCCESS!!
81
}
82         catch ( Exception JavaDoc e )
83         {
84             fail( "Did not throw the correct exception: " + e.getClass().getName() );
85         }
86
87         try
88         {
89             new ComponentHandlerMetaData( "component1", Component1.class.getName(),
90                 null, false );
91
92             fail( "No NullPointerException was thrown" );
93         }
94         catch ( NullPointerException JavaDoc npe )
95         {
96             // SUCCESS!!
97
}
98         catch ( Exception JavaDoc e )
99         {
100             fail( "Did not throw the correct exception: " + e.getClass().getName() );
101         }
102     }
103 }
104
Popular Tags