Package org.nanocontainer.reflection

Examples of org.nanocontainer.reflection.DefaultNanoPicoContainer


    }


    public void testWithDynamicClassPath() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader(
                ""
                        + "        builder = new org.nanocontainer.script.groovy.CustomGroovyNodeBuilder()\n"
                        + "        File testCompJar = new File(System.getProperty(\"testcomp.jar\"))\n"
                        + "        compJarPath = testCompJar.getCanonicalPath()\n"
View Full Code Here


        assertEquals("TestComp", pico.getComponentInstances().get(0).getClass()
                .getName());
    }

    public void testWithDynamicClassPathWithPermissions() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader(
                ""
                + "        builder = new org.nanocontainer.script.groovy.CustomGroovyNodeBuilder()\n"
                        + "        File testCompJar = new File(System.getProperty(\"testcomp.jar\"))\n"
                        + "        compJarPath = testCompJar.getCanonicalPath()\n"
View Full Code Here

        // can't actually test the permission under JUNIT control. We're just
        // testing the syntax here.
    }

    public void testGrantPermissionInWrongPlace() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        try {
            Reader script = new StringReader("" +
                    "        builder = new org.nanocontainer.script.groovy.CustomGroovyNodeBuilder()\n" +
                    "        File testCompJar = new File(System.getProperty(\"testcomp.jar\"))\n" +
                    "        compJarPath = testCompJar.getCanonicalPath()\n" +
View Full Code Here

    }


    public void testValidationTurnedOnThrowsExceptionForUnknownAttributes() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader(
            "import org.nanocontainer.script.groovy.*\n" +
            "import org.nanocontainer.script.NullNodeBuilderDecorationDelegate\n" +
            "builder = new CustomGroovyNodeBuilder(new NullNodeBuilderDecorationDelegate(), CustomGroovyNodeBuilder.PERFORM_ATTRIBUTE_VALIDATION)\n" +
            "nano = builder.container {\n" +
View Full Code Here

            //a-ok
        }
    }

    public void testValidationTurnedOffDoesntThrowExceptionForUnknownAttributes() {
        DefaultNanoPicoContainer parent = new DefaultNanoPicoContainer();
        Reader script = new StringReader(
            "import org.nanocontainer.script.groovy.*\n" +
            "import org.nanocontainer.script.NullNodeBuilderDecorationDelegate\n" +
            "builder = new CustomGroovyNodeBuilder(new NullNodeBuilderDecorationDelegate(), CustomGroovyNodeBuilder.SKIP_ATTRIBUTE_VALIDATION)\n" +
            "nano = builder.container {\n" +
View Full Code Here

        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 GroovyNodeBuilder()\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" +
                "nano = builder.container(parent:parent) {\n" +
                "    component(A)\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" +
                "nano = builder.container(parent:parent, scope:assemblyScope) {\n" +
                "  if ( assemblyScope instanceof SomeAssemblyScope ){\n "+
View Full Code Here

                        "    component(B)\n" +
                        "  } else { \n" +
                        "    System.out.println('Invalid scope')\n " +
                        "  } \n "+
                        "}\n";
        NanoPicoContainer parent = new DefaultNanoPicoContainer(buildContainer(
                new StringReader(script), null, new ParentAssemblyScope()));
//        NanoPicoContainer parent = new DefaultNanoPicoContainer();
//        parent.registerComponentImplementation(A.class);
        assertNotNull(parent.getComponentInstanceOfType(A.class));
        PicoContainer pico = buildContainer(new StringReader(script), parent,  new SomeAssemblyScope());
        assertNotNull(pico.getComponentInstanceOfType(B.class));
    }
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.