KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.picocontainer.defaults;
11
12 import org.picocontainer.Parameter;
13 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase;
14 import org.picocontainer.tck.AbstractComponentAdapterTestCase.RecordingLifecycleStrategy;
15 import org.picocontainer.testmodel.NullLifecycle;
16 import org.picocontainer.testmodel.RecordingLifecycle;
17 import org.picocontainer.testmodel.RecordingLifecycle.One;
18
19 /**
20  * @author Mauro Talevi
21  * @version $Revision: $
22  */

23 public class ConstructorInjectionComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase {
24     protected void setUp() throws Exception JavaDoc {
25         picoContainer = new DefaultPicoContainer(createComponentAdapterFactory());
26     }
27
28     protected ComponentAdapterFactory createComponentAdapterFactory() {
29         return new ConstructorInjectionComponentAdapterFactory();
30     }
31
32     public void testCustomLifecycleCanBeInjected() throws NoSuchMethodException JavaDoc {
33         RecordingLifecycleStrategy strategy = new RecordingLifecycleStrategy(new StringBuffer JavaDoc());
34         ConstructorInjectionComponentAdapterFactory caf =
35             new ConstructorInjectionComponentAdapterFactory(false, strategy);
36         ConstructorInjectionComponentAdapter cica = (ConstructorInjectionComponentAdapter)
37         caf.createComponentAdapter(NullLifecycle.class, NullLifecycle.class, new Parameter[0]);
38         One one = new RecordingLifecycle.One(new StringBuffer JavaDoc());
39         cica.start(one);
40         cica.stop(one);
41         cica.dispose(one);
42         assertEquals("<start<stop<dispose", strategy.recording());
43     }
44
45 }
Popular Tags