1 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 33 public class ComponentHandlerEntryTestCase extends TestCase 34 { 35 public ComponentHandlerEntryTestCase( String 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 npe ) 72 { 73 } 75 catch ( Exception 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 npe ) 86 { 87 } 89 catch ( Exception e ) 90 { 91 fail( "Incorrect exception thrown: " + e.getClass().getName() ); 92 } 93 } 94 } 95 | Popular Tags |