Package org.nanocontainer.reflection

Examples of org.nanocontainer.reflection.DefaultNanoPicoContainer


        StringWriter writer = (StringWriter)pico.getComponentInstanceOfType(StringWriter.class);
        assertTrue(writer.toString().length() > 0);
    }

    public void testCustomComponentMonitorCanBeSpecifiedWhenParentIsSpecified() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "import java.io.StringWriter\n" +
                "import org.picocontainer.monitors.WriterComponentMonitor\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
View Full Code Here


        StringWriter writer = (StringWriter)pico.getComponentInstanceOfType(StringWriter.class);
        assertTrue(writer.toString().length() > 0);
    }

    public void testCustomComponentMonitorCanBeSpecifiedWhenParentAndCAFAreSpecified() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "import java.io.StringWriter\n" +
                "import org.picocontainer.defaults.DefaultComponentAdapterFactory\n" +
                "import org.picocontainer.monitors.WriterComponentMonitor\n" +
View Full Code Here

        assertEquals("Should match the expression", "<A<C<BB>C>A>!B!C!A", X.componentRecorder);
    }

    public void testBuildContainerWithParentAttribute() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        parent.registerComponentInstance("hello", "world");

        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
                "nano = builder.container(parent:parent) {\n" +
View Full Code Here

        assertEquals("world", pico.getComponentInstance("hello"));
    }


    public void testBuildContainerWithParentDependencyAndAssemblyScope() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        parent.registerComponentImplementation("a", A.class);

        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
                "nano = builder.container(parent:parent) {\n" +
View Full Code Here

                "      System.out.println('Invalid scope')\n " +
                "  } \n "+
                "}\n");

        Reader script = new StringReader(scriptValue);
        NanoPicoContainer parent = new DefaultNanoPicoContainer(
            buildContainer(script, null, new ParentAssemblyScope()));

        assertNotNull(parent.getComponentAdapterOfType(A.class));

        script = new StringReader(scriptValue);
        PicoContainer pico = buildContainer(script, parent,  new SomeAssemblyScope());
        assertNotNull(pico.getComponentInstance(B.class));
    }
View Full Code Here

    }



    public void testBuildContainerWhenExpectedParentDependencyIsNotFound() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();

        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
                "nano = builder.container(parent:parent) {\n" +
View Full Code Here

            // expected
        }
    }

    public void testBuildContainerWithParentAttributesPropagatesComponentAdapterFactory() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer(new SetterInjectionComponentAdapterFactory() );
        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
                "nano = builder.container(parent:parent) {\n" +
                "}\n");
View Full Code Here

    }



    public void testExceptionThrownWhenParentAttributeDefinedWithinChild() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer(new SetterInjectionComponentAdapterFactory() );
        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "nano = new CustomGroovyNodeBuilder().container() {\n" +
                "    component(A)\n" +
                "    container(parent:parent) {\n" +
View Full Code Here

            // ignore
        }
    }

    public void testSpuriousAttributes() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();

        Reader script = new StringReader("" +
                "package org.nanocontainer.script.groovy\n" +
                "builder = new CustomGroovyNodeBuilder()\n" +
                "nano = builder.container(jim:'Jam', foo:'bar') {\n" +
View Full Code Here




    public void testWithDynamicClassPathThatDoesNotExist() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        try {
            Reader script = new StringReader("" +
                    "        child = null\n" +
                    "        pico = builder.container {\n" +
                    "            classPathElement(path:'this/path/does/not/exist.jar')\n" +
View Full Code Here

TOP

Related Classes of org.nanocontainer.reflection.DefaultNanoPicoContainer

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.