1 9 package org.picocontainer.alternatives; 10 11 import java.util.ArrayList ; 12 import java.util.List ; 13 14 import org.picocontainer.MutablePicoContainer; 15 import org.picocontainer.PicoContainer; 16 import org.picocontainer.defaults.ConstructorInjectionComponentAdapterFactory; 17 import org.picocontainer.defaults.DefaultPicoContainer; 18 import org.picocontainer.defaults.VerifyingVisitor; 19 import org.picocontainer.tck.AbstractImplementationHidingPicoContainerTestCase; 20 import org.picocontainer.testmodel.SimpleTouchable; 21 22 public class ImplementationHidingPicoContainerTestCase extends AbstractImplementationHidingPicoContainerTestCase { 23 24 protected MutablePicoContainer createImplementationHidingPicoContainer() { 25 return new ImplementationHidingPicoContainer(); 26 } 27 28 protected MutablePicoContainer createPicoContainer(PicoContainer parent) { 29 return new ImplementationHidingPicoContainer(parent); 30 } 31 32 public void testStartStopAndDisposeNotCascadedtoRemovedChildren() { 33 super.testStartStopAndDisposeNotCascadedtoRemovedChildren(); 34 } 35 36 public static class MyThread extends Thread { 37 public MyThread(String s) { 38 super(s); 39 } 40 } 41 42 public void testHidingWithoutParameter() { 43 ImplementationHidingPicoContainer pico = new ImplementationHidingPicoContainer(); 45 pico.registerComponentImplementation(String .class); 46 pico.registerComponentImplementation(Runnable .class, MyThread.class); 47 new VerifyingVisitor().traverse(pico); 48 } 49 50 public void testUsageOfADifferentComponentAdapterFactory() { 51 MutablePicoContainer parent = new DefaultPicoContainer(); 53 ImplementationHidingPicoContainer pico = new ImplementationHidingPicoContainer(new ConstructorInjectionComponentAdapterFactory(), parent); 54 pico.registerComponentImplementation(List .class, ArrayList .class); 55 List list1 = (List ) pico.getComponentInstanceOfType(List .class); 56 List list2 = (List ) pico.getComponentInstanceOfType(List .class); 57 assertNotNull(list1); 58 assertNotNull(list2); 59 assertFalse(list1 instanceof ArrayList ); 60 assertFalse(list2 instanceof ArrayList ); 61 assertFalse(list1 == list2); 62 } 63 64 public void testMakeChildContainer(){ 65 MutablePicoContainer parent = new ImplementationHidingPicoContainer(); 66 parent.registerComponentImplementation("t1", SimpleTouchable.class); 67 MutablePicoContainer child = parent.makeChildContainer(); 68 Object t1 = child.getParent().getComponentInstance("t1"); 69 assertNotNull(t1); 70 assertTrue(t1 instanceof SimpleTouchable); 71 } 72 73 public void testSameInstanceCanBeUsedAsDifferentTypeWhenCaching() { 74 } 76 77 78 } 79 | Popular Tags |