// TODO - move to AbstractComponentRegistryTestCase public void testGetComponentSpecification() throws PicoCompositionException { DefaultPicoContainer pico = new DefaultPicoContainer(); assertNull(pico.getComponentAdapter(Touchable.class, null)); pico.addComponent(SimpleTouchable.class); assertNotNull(pico.getComponentAdapter(SimpleTouchable.class, null)); assertNotNull(pico.getComponentAdapter(Touchable.class, null)); }
public void testAddComponentNoesNotUseImplementationHidingBehaviorWhenNoCachePropertyIsSpecified() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHiding().wrap(new ConstructorInjection())); pico.change(Characteristics.NO_HIDE_IMPL).addComponent("foo", String.class); ComponentAdapter foo = pico.getComponentAdapter("foo"); assertEquals(ConstructorInjector.class, foo.getClass()); }
public void testAddComponentUsesImplementationHidingBehaviorWithRedundantHideImplProperty() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHiding().wrap(new ConstructorInjection())); pico.change(Characteristics.HIDE_IMPL).addComponent("foo", String.class); ComponentAdapter foo = pico.getComponentAdapter("foo"); assertEquals(HiddenImplementation.class, foo.getClass()); assertEquals(ConstructorInjector.class, ((AbstractBehavior) foo).getDelegate().getClass()); }
public void testAddComponentUsesImplementationHidingBehavior() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHiding().wrap(new ConstructorInjection())); pico.addComponent("foo", String.class); ComponentAdapter foo = pico.getComponentAdapter("foo"); assertEquals(HiddenImplementation.class, foo.getClass()); assertEquals(ConstructorInjector.class, ((AbstractBehavior) foo).getDelegate().getClass()); }
public void testAddAdapterUsesImplementationHidingBehavior() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHiding().wrap(new ConstructorInjection())); pico.addAdapter( new InstanceAdapter("foo", "bar", new NullLifecycleStrategy(), new NullComponentMonitor())); ComponentAdapter foo = pico.getComponentAdapter("foo"); assertEquals(HiddenImplementation.class, foo.getClass()); assertEquals(InstanceAdapter.class, ((AbstractBehavior) foo).getDelegate().getClass()); }
public void testAddAdapterNoesNotUseImplementationHidingBehaviorWhenNoCachePropertyIsSpecified() { DefaultPicoContainer pico = new DefaultPicoContainer(new ImplementationHiding().wrap(new ConstructorInjection())); pico.change(Characteristics.NO_HIDE_IMPL) .addAdapter( new InstanceAdapter( "foo", "bar", new NullLifecycleStrategy(), new NullComponentMonitor())); ComponentAdapter foo = pico.getComponentAdapter("foo"); assertEquals(InstanceAdapter.class, foo.getClass()); }