1 10 package org.picocontainer.tck; 11 12 import junit.framework.TestCase; 13 import org.picocontainer.ComponentAdapter; 14 import org.picocontainer.PicoIntrospectionException; 15 import org.picocontainer.PicoRegistrationException; 16 import org.picocontainer.defaults.AssignabilityRegistrationException; 17 import org.picocontainer.defaults.ComponentAdapterFactory; 18 import org.picocontainer.defaults.DefaultPicoContainer; 19 import org.picocontainer.defaults.NotConcreteRegistrationException; 20 import org.picocontainer.testmodel.SimpleTouchable; 21 import org.picocontainer.testmodel.Touchable; 22 23 27 public abstract class AbstractComponentAdapterFactoryTestCase extends TestCase { 28 protected DefaultPicoContainer picoContainer; 29 30 protected abstract ComponentAdapterFactory createComponentAdapterFactory(); 31 32 protected void setUp() throws Exception { 33 picoContainer = new DefaultPicoContainer(); 34 } 35 36 public void testEquals() throws PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException { 37 ComponentAdapter componentAdapter = createComponentAdapterFactory().createComponentAdapter(Touchable.class, SimpleTouchable.class, null); 38 39 assertEquals(componentAdapter, componentAdapter); 40 assertTrue(!componentAdapter.equals("blah")); 41 } 42 43 public void testRegisterComponent() throws PicoRegistrationException, AssignabilityRegistrationException { 44 ComponentAdapter componentAdapter = 45 createComponentAdapterFactory().createComponentAdapter(Touchable.class, SimpleTouchable.class, null); 46 47 picoContainer.registerComponent(componentAdapter); 48 49 assertTrue(picoContainer.getComponentAdapters().contains(componentAdapter)); 50 } 51 52 public void testUnregisterComponent() throws PicoRegistrationException, AssignabilityRegistrationException { 53 ComponentAdapter componentAdapter = 54 createComponentAdapterFactory().createComponentAdapter(Touchable.class, SimpleTouchable.class, null); 55 56 picoContainer.registerComponent(componentAdapter); 57 picoContainer.unregisterComponent(Touchable.class); 58 59 assertFalse(picoContainer.getComponentAdapters().contains(componentAdapter)); 60 } 61 } 62 | Popular Tags |