Package org.picocontainer.testmodel

Examples of org.picocontainer.testmodel.SimpleTouchable



    //TODO move
    public void testMultipleImplementationsAccessedThroughKey()
            throws PicoInitializationException, PicoRegistrationException, PicoInvocationTargetInitializationException {
        SimpleTouchable Touchable1 = new SimpleTouchable();
        SimpleTouchable Touchable2 = new SimpleTouchable();
        DefaultPicoContainer pico = new DefaultPicoContainer();
        pico.registerComponentInstance("Touchable1", Touchable1);
        pico.registerComponentInstance("Touchable2", Touchable2);
        pico.registerComponentImplementation("fred1", DependsOnTouchable.class, new Parameter[]{new ComponentParameter("Touchable1")});
        pico.registerComponentImplementation("fred2", DependsOnTouchable.class, new Parameter[]{new ComponentParameter("Touchable2")});
View Full Code Here


    //TODO - move
    public void testRegistrationByName() throws Exception {
        DefaultPicoContainer pico = new DefaultPicoContainer();

        Webster one = new Webster(new ArrayList());
        Touchable two = new SimpleTouchable();

        pico.registerComponentInstance("one", one);
        pico.registerComponentInstance("two", two);

        assertEquals("Wrong number of comps in the internals", 2, pico.getComponentInstances().size());
View Full Code Here

    public void testDuplicateRegistrationWithTypeAndObject() throws PicoInstantiationException, PicoRegistrationException, PicoIntrospectionException {
        DefaultPicoContainer pico = new DefaultPicoContainer();

        pico.registerComponentImplementation(SimpleTouchable.class);
        try {
            pico.registerComponentInstance(SimpleTouchable.class, new SimpleTouchable());
            fail("Should have barfed with dupe registration");
        } catch (DuplicateComponentKeyRegistrationException e) {
            // expected
            assertTrue(e.getDuplicateKey() == SimpleTouchable.class);
            assertTrue(e.getMessage().indexOf(SimpleTouchable.class.getName()) > 0);
View Full Code Here

        assertSame(value, parameter.resolveInstance(picoContainer, null, Object.class));
    }

    public void testDependsOnTouchableWithTouchableSpecifiedAsConstant() throws PicoRegistrationException, PicoInitializationException {
        DefaultPicoContainer pico = new DefaultPicoContainer();
        SimpleTouchable touchable = new SimpleTouchable();
        pico.registerComponentImplementation(DependsOnTouchable.class, DependsOnTouchable.class, new Parameter[]{
            new ConstantParameter(touchable)
        });
        pico.getComponentInstances();
        assertTrue(touchable.wasTouched);
View Full Code Here

    assertEquals(239, ((Integer)parameter.resolveInstance(picoContainer,null,Integer.TYPE)).intValue());
  }

    public void testConstantParameterRespectsExpectedType() {
        MutablePicoContainer picoContainer = new DefaultPicoContainer();
        Parameter parameter = new ConstantParameter(new SimpleTouchable());
        ComponentAdapter adapter = picoContainer.registerComponentImplementation(Touchable.class, SimpleTouchable.class);
        assertFalse(parameter.isResolvable(picoContainer, adapter, TestCase.class));
    }
View Full Code Here

    public void testSerializedContainerCanRetrieveImplementation() throws PicoException, PicoInitializationException,
            IOException, ClassNotFoundException {

        Touchable touchable = getTouchableFromSerializedContainer();

        SimpleTouchable simpleTouchable = (SimpleTouchable) touchable;

        assertTrue(simpleTouchable.wasTouched);
    }
View Full Code Here

*/
public class InstanceComponentAdapterTestCase
        extends AbstractComponentAdapterTestCase {

    public void testComponentAdapterReturnsSame() {
        final Touchable touchable = new SimpleTouchable();
        final ComponentAdapter componentAdapter = new InstanceComponentAdapter(Touchable.class, touchable);
        assertSame(touchable, componentAdapter.getComponentInstance(null));
    }
View Full Code Here

        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 testChildOverridesParent() {
        parent.registerComponentImplementation(SimpleTouchable.class);
        child.registerComponentImplementation(SimpleTouchable.class);

        SimpleTouchable parentTouchable = (SimpleTouchable) parent.getComponentInstance(SimpleTouchable.class);
        SimpleTouchable childTouchable = (SimpleTouchable) child.getComponentInstance(SimpleTouchable.class);
        assertEquals(1, child.getComponentInstances().size());
        assertNotSame(parentTouchable, childTouchable);
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.testmodel.SimpleTouchable

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.