1 /****************************************************************************** 2 * Copyright (C) PicoContainer 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 * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant * 9 *****************************************************************************/ 10 11 package org.picocontainer; 12 13 import junit.framework.TestCase; 14 import org.picocontainer.testmodel.DependsOnTouchable; 15 import org.picocontainer.testmodel.SimpleTouchable; 16 import org.picocontainer.defaults.DefaultPicoContainer; 17 18 /*** 19 * Can Pico host itself ? 20 */ 21 public class PicoPicoTestCase extends TestCase { 22 23 public void testDefaultPicoContainer() throws PicoRegistrationException, PicoInitializationException { 24 25 DefaultPicoContainer pc = new DefaultPicoContainer.Default(); 26 pc.registerComponentByClass(DefaultPicoContainer.Default.class); 27 pc.instantiateComponents(); 28 29 tryDefaultPicoContainer((DefaultPicoContainer) pc.getComponent(DefaultPicoContainer.Default.class)); 30 31 } 32 33 private void tryDefaultPicoContainer(DefaultPicoContainer pc2) throws PicoRegistrationException, PicoInitializationException { 34 35 pc2.registerComponentByClass(DependsOnTouchable.class); 36 pc2.registerComponentByClass(SimpleTouchable.class); 37 38 pc2.instantiateComponents(); 39 40 assertTrue("There should have been a Fred in the internals", pc2.hasComponent(DependsOnTouchable.class)); 41 assertTrue("There should have been a Touchable in the internals", pc2.hasComponent(SimpleTouchable.class)); 42 } 43 }

This page was automatically generated by Maven