1 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 31 public class ComponentHandlerMetaDataTestCase extends TestCase 32 { 33 public ComponentHandlerMetaDataTestCase( String 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 npe ) 63 { 64 } 66 catch ( Exception 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 npe ) 79 { 80 } 82 catch ( Exception 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 npe ) 95 { 96 } 98 catch ( Exception e ) 99 { 100 fail( "Did not throw the correct exception: " + e.getClass().getName() ); 101 } 102 } 103 } 104 | Popular Tags |