[nanocontainer-scm] [jira] Created: (NANO-137) Groovy Builder for Nano does not propate parent container types or component adapters.

"Michael Rimov (JIRA)" <jira-yCVjj/[email protected]> Fri, 10 Jun 2005 21:33:42 -0500 (CDT)
Newsgroups gmane.comp.java.nanocontainer.cvs
Message-ID <9903301.1118457222658.JavaMail.haus-jira@codehaus01.managed.contegix.com>
Groovy Builder for Nano does not propate parent container types or component adapters.
--------------------------------------------------------------------------------------

         Key: NANO-137
         URL: http://jira.codehaus.org/browse/NANO-137
     Project: NanoContainer
        Type: Bug
  Components: core  
    Versions: 1.0-beta-5    
    Reporter: Michael Rimov


Using the Groovy Builder, it appears currently impossible to implicitly propagate parent container types and adapterfactories to children containers.  The following test case will fail.  (NOTE: The test case depends on the BasePicoVisitor enhancement submitted in PICO-235, but it is easy enough to backport)

    public void testChildContainerHasParentAdapter() {
        Reader script = new StringReader("" +
            "builder = new org.nanocontainer.script.groovy.NanoContainerBuilder()\n"
            + "pico = builder.container(parent) { \n"
            + "  container() {\n"
            + "     component(ArrayList)"
            + "  }\n"
            + "}"
            );

        //Build the parent
        ObjectReference parent = new SimpleReference();
        parent.set(new DefaultPicoContainer(new BeanPropertyComponentAdapterFactory(new DefaultComponentAdapterFactory())));

        //Build target
        ScriptedContainerBuilder builder = new GroovyContainerBuilder(script, Thread.currentThread().getContextClassLoader());
        builder.buildContainer(new SimpleReference(),parent,null, true);
        
        //Collect a list of all containers.
        final List allContainers = new ArrayList();
        PicoVisitor testingVisitor = new BasePicoVisitor() {
            public void visitContainer(PicoContainer pico) {
                super.visitContainer(pico); //Calls checkTraversal for us.
                allContainers.add(pico);
        }
    };
    testingVisitor.traverse((PicoContainer)parent.get());

    //Verify that default component adapter factory gets propagated 
    //down the hierarchy much in the way that pico.makeChildContainer() works.
    for (Iterator i = allContainers.iterator(); i.hasNext();) {
        PicoContainer oneContainer = (PicoContainer)i.next();                 assertNotNull(oneContainer.getComponentAdapterOfType(BeanPropertyComponentAdapterFactory.class));
    }        
}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira