001 /***************************************************************************** 002 * Copyright (C) PicoContainer 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 * 009 *****************************************************************************/ 010 package org.picocontainer.defaults; 011 012 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase; 013 import org.picocontainer.testmodel.SimpleTouchable; 014 import org.picocontainer.testmodel.Touchable; 015 016 /** 017 * @author <a href="Rafal.Krzewski">rafal@caltha.pl</a> 018 * @version $Revision: 2347 $ 019 */ 020 public class CachingComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase { 021 protected void setUp() throws Exception { 022 picoContainer = new DefaultPicoContainer(createComponentAdapterFactory()); 023 } 024 025 protected ComponentAdapterFactory createComponentAdapterFactory() { 026 return new CachingComponentAdapterFactory(new ConstructorInjectionComponentAdapterFactory()); 027 } 028 029 public void testContainerReturnsSameInstanceEachCall() { 030 picoContainer.registerComponentImplementation(Touchable.class, SimpleTouchable.class); 031 Touchable t1 = (Touchable) picoContainer.getComponentInstance(Touchable.class); 032 Touchable t2 = (Touchable) picoContainer.getComponentInstance(Touchable.class); 033 assertSame(t1, t2); 034 } 035 }