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
11 package org.picocontainer.defaults;
12
13 import junit.framework.TestCase;
14 import org.picocontainer.PicoContainer;
15 import org.picocontainer.PicoInitializationException;
16 import org.picocontainer.PicoInstantiationException;
17 import org.picocontainer.PicoIntrospectionException;
18 import org.picocontainer.internals.ComponentSpecification;
19 import org.picocontainer.extras.CompositePicoContainer;
20 import org.picocontainer.extras.NullContainer;
21
22 import java.lang.reflect.InvocationTargetException;
23
24 public class DummiesTestCase extends TestCase {
25
26 public void testDummyContainer() throws PicoInstantiationException {
27 NullContainer dc = new NullContainer();
28 dc.instantiateComponents();
29 assertFalse(dc.hasComponent(String.class));
30 assertNull(dc.getComponent(String.class));
31 assertEquals(0, dc.getComponents().size());
32 assertEquals(0, dc.getComponentKeys().size());
33 assertNull(dc.getComponentMulticaster());
34 assertNull(dc.getComponentMulticaster(true, false));
35 assertNull(dc.getComponentMulticaster(false, true));
36 }
37
38 public void testDefaultComponentFactory() throws PicoInstantiationException,
39 NoSuchMethodException,
40 InvocationTargetException,
41 IllegalAccessException, PicoIntrospectionException {
42 DefaultComponentFactory dcd = new DefaultComponentFactory();
43 Object decorated = dcd.createComponent(new ComponentSpecification(dcd, Object.class, Object.class), null);
44 assertNotNull(decorated);
45 }
46
47 public void donot_testInstantiation() throws PicoInitializationException {
48 CompositePicoContainer acc = new CompositePicoContainer.WithContainerArray(new PicoContainer[0]);
49 // Should not barf. Should do nothing, but that hard to test.
50 // Hmmm, should it be silent, ot barf ?
51 acc.instantiateComponents();
52 }
53 }
This page was automatically generated by Maven