1 10 package org.picocontainer.defaults; 11 12 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase; 13 import org.picocontainer.testmodel.SimpleTouchable; 14 import org.picocontainer.testmodel.Touchable; 15 16 20 public class CachingComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase { 21 protected void setUp() throws Exception { 22 picoContainer = new DefaultPicoContainer(createComponentAdapterFactory()); 23 } 24 25 protected ComponentAdapterFactory createComponentAdapterFactory() { 26 return new CachingComponentAdapterFactory(new ConstructorInjectionComponentAdapterFactory()); 27 } 28 29 public void testContainerReturnsSameInstanceEachCall() { 30 picoContainer.registerComponentImplementation(Touchable.class, SimpleTouchable.class); 31 Touchable t1 = (Touchable) picoContainer.getComponentInstance(Touchable.class); 32 Touchable t2 = (Touchable) picoContainer.getComponentInstance(Touchable.class); 33 assertSame(t1, t2); 34 } 35 } | Popular Tags |