001 /*****************************************************************************
002 * Copyright (C) NanoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by Paul Hammant *
009 *****************************************************************************/
010
011 package org.nanocontainer.reflection;
012
013 import org.picocontainer.MutablePicoContainer;
014 import org.picocontainer.PicoContainer;
015 import org.picocontainer.tck.AbstractImplementationHidingPicoContainerTestCase;
016 import org.nanocontainer.NanoPicoContainer;
017
018 /**
019 * @author Paul Hammant
020 * @version $Revision: 2962 $
021 */
022
023 public class ImplementationHidingNanoPicoContainerTestCase extends AbstractImplementationHidingPicoContainerTestCase {
024
025 protected MutablePicoContainer createImplementationHidingPicoContainer() {
026 return new ImplementationHidingNanoPicoContainer();
027 }
028
029 protected MutablePicoContainer createPicoContainer(PicoContainer parent) {
030 return new ImplementationHidingNanoPicoContainer(this.getClass().getClassLoader(), parent);
031 }
032 // test methods inherited. This container is part compliant.
033
034 public void testMakeRemoveChildContainer() {
035 final NanoPicoContainer parent = (NanoPicoContainer) createPicoContainer(null);
036 parent.registerComponentInstance("java.lang.String", "This is a test");
037 MutablePicoContainer pico = parent.makeChildContainer();
038 // Verify they are indeed wired together.
039 assertNotNull(pico.getComponentInstance("java.lang.String"));
040 boolean result = parent.removeChildContainer(pico);
041 assertTrue(result);
042 }
043
044 }