KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > issues > Issue0229TestCase


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 Michael Rettig *
9  *****************************************************************************/

10 package org.picocontainer.defaults.issues;
11
12 import org.picocontainer.defaults.DefaultPicoContainer;
13 import org.picocontainer.defaults.VerifyingVisitor;
14
15 import junit.framework.TestCase;
16
17
18 public class Issue0229TestCase extends TestCase {
19     public static class MockRunnable implements Runnable JavaDoc {
20         public void run() {
21         }
22     }
23
24     public static class OtherRunnable implements Runnable JavaDoc {
25         public void run() {
26         }
27     }
28
29     public static class MockRunner {
30         private final Runnable JavaDoc[] _runners;
31
32         public MockRunner(Runnable JavaDoc[] runnables) {
33             _runners = runnables;
34         }
35         
36         public Runnable JavaDoc[] getRunners(){
37             return _runners;
38         }
39     }
40
41     public void testArrayDependenciesAndVerification() {
42         DefaultPicoContainer container = new DefaultPicoContainer();
43         container.registerComponentImplementation(MockRunnable.class);
44         container.registerComponentImplementation(OtherRunnable.class);
45         container.registerComponentImplementation(MockRunner.class);
46
47         // this will fail to resolve the Runnable array on the MockRunner
48
VerifyingVisitor visitor = new VerifyingVisitor();
49         visitor.traverse(container);
50
51         container.start();
52         assertNotNull(container.getComponentInstanceOfType(MockRunner.class));
53     }
54
55 }
56
Popular Tags