Package org.picocontainer.testmodel

Examples of org.picocontainer.testmodel.Touchable


        container.registerComponentImplementation(AlternativeTouchable.class);
        container.registerComponentImplementation(DecoratedTouchable.class,
                                                  DecoratedTouchable.class,
                                                  new Parameter[] { new ComponentParameter(SimpleTouchable.class) });

        Touchable t = (Touchable) container.getComponentInstance(DecoratedTouchable.class);
        assertNotNull(t);
    }
View Full Code Here


    public void testTouchableDependencyInjectedViaConstraint() {
        container.registerComponentImplementation(AlternativeTouchable.class);
        container.registerComponentImplementation(DecoratedTouchable.class,
                                                  DecoratedTouchable.class,
                                                  new Parameter[] { new Not(new IsType(SimpleTouchable.class)) });
        Touchable t = (Touchable) container.getComponentInstance(DecoratedTouchable.class);
        assertNotNull(t);
    }
View Full Code Here

    public void testWillOmitSelfFromCollection() {
        MutablePicoContainer pico = getDefaultPicoContainer();
        pico.registerComponentImplementation(SimpleTouchable.class);
        pico.registerComponentImplementation(TouchableObserver.class);
        Touchable observer = (Touchable) pico.getComponentInstanceOfType(TouchableObserver.class);
        assertNotNull(observer);
        observer.touch();
        SimpleTouchable touchable = (SimpleTouchable) pico.getComponentInstanceOfType(SimpleTouchable.class);
        assertTrue(touchable.wasTouched);
    }
View Full Code Here

     */
    public void testUnambiguouSelfDependency() {
        MutablePicoContainer pico = createPicoContainer(null);
        pico.registerComponentImplementation(SimpleTouchable.class);
        pico.registerComponentImplementation(DecoratedTouchable.class);
        Touchable t = (Touchable) pico.getComponentInstance(DecoratedTouchable.class);
        assertNotNull(t);
    }
View Full Code Here

         */
        pico.registerComponentImplementation(Touchable.class, DecoratedTouchable.class, new Parameter[]{
            new ComponentParameter("default")
        });

        Touchable touchable = (Touchable) pico.getComponentInstanceOfType(Touchable.class);
        assertEquals(DecoratedTouchable.class, touchable.getClass());
    }
View Full Code Here

        // Use the List variant instead, so we get better test coverage.
        pico.registerComponentImplementation(Touchable.class, DecoratedTouchable.class, Collections.singletonList(new ComponentParameter("default")));

        DefaultPicoContainer grandChild = new DefaultPicoContainer(new DefaultPicoContainer(new DefaultPicoContainer(pico)));

        Touchable touchable = (Touchable) grandChild.getComponentInstanceOfType(Touchable.class);
        assertEquals(DecoratedTouchable.class, touchable.getClass());

    }
View Full Code Here

TOP

Related Classes of org.picocontainer.testmodel.Touchable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.