KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > reflection > ImplementationHidingNanoPicoContainerTestCase


1 /*****************************************************************************
2  * Copyright (C) NanoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by Paul Hammant *
9  *****************************************************************************/

10
11 package org.nanocontainer.reflection;
12
13 import org.picocontainer.MutablePicoContainer;
14 import org.picocontainer.PicoContainer;
15 import org.picocontainer.tck.AbstractImplementationHidingPicoContainerTestCase;
16 import org.nanocontainer.NanoPicoContainer;
17
18 /**
19  * @author Paul Hammant
20  * @version $Revision: 2962 $
21  */

22
23 public class ImplementationHidingNanoPicoContainerTestCase extends AbstractImplementationHidingPicoContainerTestCase {
24
25     protected MutablePicoContainer createImplementationHidingPicoContainer() {
26         return new ImplementationHidingNanoPicoContainer();
27     }
28
29     protected MutablePicoContainer createPicoContainer(PicoContainer parent) {
30         return new ImplementationHidingNanoPicoContainer(this.getClass().getClassLoader(), parent);
31     }
32     // test methods inherited. This container is part compliant.
33

34     public void testMakeRemoveChildContainer() {
35         final NanoPicoContainer parent = (NanoPicoContainer) createPicoContainer(null);
36         parent.registerComponentInstance("java.lang.String", "This is a test");
37         MutablePicoContainer pico = parent.makeChildContainer();
38         // Verify they are indeed wired together.
39
assertNotNull(pico.getComponentInstance("java.lang.String"));
40         boolean result = parent.removeChildContainer(pico);
41         assertTrue(result);
42     }
43
44 }
45
Popular Tags