    001    package org.nanocontainer.script.xml.issues;
    002
    003    import com.thoughtworks.proxy.toys.hotswap.Swappable;
    004
    005    import java.io.Reader;
    006    import java.io.StringReader;
    007    import java.util.List;
    008
    009    import org.nanocontainer.script.AbstractScriptedContainerBuilderTestCase;
    010    import org.nanocontainer.script.xml.XMLContainerBuilder;
    011    import org.picocontainer.PicoContainer;
    012
    013    //http://jira.codehaus.org/browse/NANO-170
    014    public class Issue0170TestCase extends AbstractScriptedContainerBuilderTestCase {
    015
    016        public void testHotSwappingCAF() {
    017            Reader script = new StringReader("" +
    018                    "<container>" +
    019                    "  <component-adapter-factory key='factory' class='org.picocontainer.gems.adapters.HotSwappingComponentAdapterFactory'>"+
    020                    "    <component-adapter-factory class='org.picocontainer.defaults.CachingComponentAdapterFactory'>"+
    021                    "      <component-adapter-factory class='org.picocontainer.defaults.ConstructorInjectionComponentAdapterFactory'/>"+
    022                    "    </component-adapter-factory>"+
    023                    "  </component-adapter-factory>"+
    024                    "  <component-adapter class-name-key='java.util.List' class='java.util.ArrayList' factory='factory'/>"+
    025                    "</container>");
    026
    027            PicoContainer pico = buildContainer(script);
    028            assertNotNull(pico);
    029            List list = (List)pico.getComponentInstanceOfType(List.class);
    030            assertNotNull(list);
    031            assertTrue(list instanceof Swappable);
    032        }
    033
    034        private PicoContainer buildContainer(Reader script) {
    035            return buildContainer(new XMLContainerBuilder(script, getClass().getClassLoader()), null, "SOME_SCOPE");
    036        }
    037
    038    }
    039
    040