KickJava   Java API By Example, From Geeks To Geeks.

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


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.ComponentAdapter;
14 import org.picocontainer.PicoInitializationException;
15 import org.picocontainer.PicoIntrospectionException;
16 import org.picocontainer.tck.AbstractComponentAdapterFactoryTestCase;
17 import org.picocontainer.testmodel.SimpleTouchable;
18 import org.picocontainer.testmodel.Touchable;
19
20 public class DefaultComponentAdapterFactoryTestCase extends AbstractComponentAdapterFactoryTestCase {
21     protected ComponentAdapterFactory createComponentAdapterFactory() {
22         return new DefaultComponentAdapterFactory();
23     }
24
25     public void testInstantiateComponentWithNoDependencies() throws PicoInitializationException, PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException {
26         ComponentAdapter componentAdapter =
27                 createComponentAdapterFactory().createComponentAdapter(Touchable.class, SimpleTouchable.class, null);
28
29         Object JavaDoc comp = componentAdapter.getComponentInstance(new DefaultPicoContainer());
30         assertNotNull(comp);
31         assertTrue(comp instanceof SimpleTouchable);
32     }
33
34     public void testSingleUsecanBeInstantiatedByDefaultComponentAdapter() {
35         ComponentAdapter componentAdapter = createComponentAdapterFactory().createComponentAdapter("o", Object JavaDoc.class, null);
36         Object JavaDoc component = componentAdapter.getComponentInstance(new DefaultPicoContainer());
37         assertNotNull(component);
38     }
39 }
40
Popular Tags