KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > CachingComponentAdapterFactoryTestCase


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  * Original code by *
9  *****************************************************************************/

10 package org.picocontainer.defaults;
11
12 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase;
13 import org.picocontainer.testmodel.SimpleTouchable;
14 import org.picocontainer.testmodel.Touchable;
15
16 /**
17  * @author <a HREF="Rafal.Krzewski">rafal@caltha.pl</a>
18  * @version $Revision: 2347 $
19  */

20 public class CachingComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase {
21     protected void setUp() throws Exception JavaDoc {
22         picoContainer = new DefaultPicoContainer(createComponentAdapterFactory());
23     }
24
25     protected ComponentAdapterFactory createComponentAdapterFactory() {
26         return new CachingComponentAdapterFactory(new ConstructorInjectionComponentAdapterFactory());
27     }
28
29     public void testContainerReturnsSameInstanceEachCall() {
30         picoContainer.registerComponentImplementation(Touchable.class, SimpleTouchable.class);
31         Touchable t1 = (Touchable) picoContainer.getComponentInstance(Touchable.class);
32         Touchable t2 = (Touchable) picoContainer.getComponentInstance(Touchable.class);
33         assertSame(t1, t2);
34     }
35 }
Popular Tags