Examples of registerComponentInstance()


Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

      if (componentInstance instanceof MutablePicoContainer)
      {
         MutablePicoContainer pc = (MutablePicoContainer)componentInstance;
         Object contrivedKey = new Object();
         String contrivedComp = "";
         pc.registerComponentInstance(contrivedKey, contrivedComp);
         try
         {
            if (this.getComponentInstance(contrivedKey) != null)
            {
               throw new PicoRegistrationException(
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

      if (componentInstance instanceof MutablePicoContainer)
      {
         MutablePicoContainer pc = (MutablePicoContainer)componentInstance;
         Object contrivedKey = new Object();
         String contrivedComp = "";
         pc.registerComponentInstance(contrivedKey, contrivedComp);
         try
         {
            if (this.getComponentInstance(contrivedKey) != null)
            {
               throw new PicoRegistrationException(
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testRegistersSingleInstance() throws PicoException, PicoInitializationException {
        MutablePicoContainer pico = createPicoContainer(null);
        StringBuffer sb = new StringBuffer();
        pico.registerComponentInstance(sb);
        assertSame(sb, pico.getComponentInstance(StringBuffer.class));
    }

    public void testContainerIsSerializable() throws PicoException, PicoInitializationException,
            IOException, ClassNotFoundException {
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testExternallyInstantiatedObjectsCanBeRegistgeredAndLookedUp() throws PicoException, PicoInitializationException {
        MutablePicoContainer pico = createPicoContainer(null);
        final HashMap map = new HashMap();
        pico.registerComponentInstance(Map.class, map);
        assertSame(map, pico.getComponentInstance(Map.class));
    }

    public void testAmbiguousResolution() throws PicoRegistrationException, PicoInitializationException {
        MutablePicoContainer pico = createPicoContainer(null);
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testAmbiguousResolution() throws PicoRegistrationException, PicoInitializationException {
        MutablePicoContainer pico = createPicoContainer(null);
        pico.registerComponentImplementation("ping", String.class);
        pico.registerComponentInstance("pong", "pang");
        try {
            pico.getComponentInstance(String.class);
        } catch (AmbiguousComponentResolutionException e) {
            assertTrue(e.getMessage().indexOf("java.lang.String") != -1);
        }
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    public void testRegisterComponentWithObjectBadType() throws PicoIntrospectionException {
        MutablePicoContainer pico = createPicoContainer(null);

        try {
            pico.registerComponentInstance(Serializable.class, new Object());
            fail("Shouldn't be able to register an Object.class as Serializable because it is not, " +
                    "it does not implement it, Object.class does not implement much.");
        } catch (AssignabilityRegistrationException e) {
        }
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testContainerCascadesStart() {
        final MutablePicoContainer picoContainer = createPicoContainer(null);
        Foo foo = new Foo();
        picoContainer.registerComponentInstance(foo);
        picoContainer.start();
        assertEquals(true, foo.started);
    }

    public void testContainerCascadesStop() {
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testContainerCascadesStop() {
        final MutablePicoContainer picoContainer = createPicoContainer(null);
        Foo foo = new Foo();
        picoContainer.registerComponentInstance(foo);
        picoContainer.start();
        picoContainer.stop();
        assertEquals(true, foo.stopped);
    }
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

    }

    public void testContainerCascadesDispose() {
        final MutablePicoContainer picoContainer = createPicoContainer(null);
        Foo foo = new Foo();
        picoContainer.registerComponentInstance(foo);
        picoContainer.dispose();
        assertEquals(true, foo.disposed);
    }

    public void testComponentInstancesFromParentsAreNotDirectlyAccessible2() {
View Full Code Here

Examples of org.picocontainer.MutablePicoContainer.registerComponentInstance()

        Object bo = new Object();
        Object co = new Object();

        a.registerComponentInstance("a", ao);
        b.registerComponentInstance("b", bo);
        c.registerComponentInstance("c", co);

        assertEquals(1, a.getComponentInstances().size());
        assertEquals(1, b.getComponentInstances().size());
        assertEquals(1, c.getComponentInstances().size());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.