// 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));
  }
コード例 #2
0
 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());
 }
コード例 #3
0
 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());
 }
コード例 #4
0
 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());
 }
コード例 #5
0
 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());
 }
コード例 #6
0
 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());
 }