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 Stacy Curl * 9 *****************************************************************************/ 10 11 package org.picocontainer.defaults; 12 13 import org.picocontainer.PicoIntrospectionException; 14 import org.picocontainer.internals.ComponentFactory; 15 import org.picocontainer.internals.ComponentRegistry; 16 import org.picocontainer.internals.ComponentSpecification; 17 import org.picocontainer.testmodel.SimpleTouchable; 18 import org.picocontainer.testmodel.Touchable; 19 20 import junit.framework.TestCase; 21 22 public class DefaultComponentRegistryTestCase extends TestCase { 23 private ComponentRegistry componentRegistry; 24 private ComponentFactory componentFactory; 25 26 protected void setUp() throws Exception { 27 componentRegistry = new DefaultComponentRegistry(); 28 componentFactory = new DefaultComponentFactory(); 29 } 30 31 public void testRegisterComponent() throws PicoIntrospectionException { 32 ComponentSpecification componentSpecification = 33 createComponentSpecification(); 34 35 componentRegistry.registerComponent(componentSpecification); 36 37 assertTrue(componentRegistry.getComponentSpecifications().contains( 38 componentSpecification)); 39 } 40 41 public void testUnregisterComponent() throws PicoIntrospectionException { 42 ComponentSpecification componentSpecification = 43 createComponentSpecification(); 44 45 componentRegistry.registerComponent(componentSpecification); 46 47 componentRegistry.unregisterComponent(Touchable.class); 48 49 assertFalse(componentRegistry.getComponentSpecifications().contains( 50 componentSpecification)); 51 } 52 53 private ComponentSpecification createComponentSpecification() throws PicoIntrospectionException { 54 return new ComponentSpecification(componentFactory, Touchable.class, 55 SimpleTouchable.class); 56 } 57 }

This page was automatically generated by Maven