1 10 package org.picocontainer.defaults; 11 12 import org.picocontainer.Parameter; 13 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase; 14 import org.picocontainer.tck.AbstractComponentAdapterTestCase.RecordingLifecycleStrategy; 15 import org.picocontainer.testmodel.NullLifecycle; 16 import org.picocontainer.testmodel.RecordingLifecycle; 17 import org.picocontainer.testmodel.RecordingLifecycle.One; 18 19 23 public class ConstructorInjectionComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase { 24 protected void setUp() throws Exception { 25 picoContainer = new DefaultPicoContainer(createComponentAdapterFactory()); 26 } 27 28 protected ComponentAdapterFactory createComponentAdapterFactory() { 29 return new ConstructorInjectionComponentAdapterFactory(); 30 } 31 32 public void testCustomLifecycleCanBeInjected() throws NoSuchMethodException { 33 RecordingLifecycleStrategy strategy = new RecordingLifecycleStrategy(new StringBuffer ()); 34 ConstructorInjectionComponentAdapterFactory caf = 35 new ConstructorInjectionComponentAdapterFactory(false, strategy); 36 ConstructorInjectionComponentAdapter cica = (ConstructorInjectionComponentAdapter) 37 caf.createComponentAdapter(NullLifecycle.class, NullLifecycle.class, new Parameter[0]); 38 One one = new RecordingLifecycle.One(new StringBuffer ()); 39 cica.start(one); 40 cica.stop(one); 41 cica.dispose(one); 42 assertEquals("<start<stop<dispose", strategy.recording()); 43 } 44 45 } | Popular Tags |