001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by Michael Rettig *
009 *****************************************************************************/
010 package org.picocontainer.defaults.issues;
011
012 import org.picocontainer.DefaultPicoContainer;
013 import org.picocontainer.visitors.VerifyingVisitor;
014
015 import junit.framework.TestCase;
016
017
018 public class Issue0229TestCase extends TestCase {
019
020 public static class MockRunnable implements Runnable {
021 public void run() {
022 }
023 }
024
025 public static class OtherRunnable implements Runnable {
026 public void run() {
027 }
028 }
029
030 public static class MockRunner {
031 private final Runnable[] _runners;
032
033 public MockRunner(Runnable[] runnables) {
034 _runners = runnables;
035 }
036
037 public Runnable[] getRunners(){
038 return _runners;
039 }
040 }
041
042 public void testArrayDependenciesAndVerification() {
043 DefaultPicoContainer container = new DefaultPicoContainer();
044 container.addComponent(new MockRunnable());
045 container.addComponent(new OtherRunnable());
046 container.addComponent(MockRunner.class);
047
048 // this will fail to resolve the Runnable array on the MockRunner
049 VerifyingVisitor visitor = new VerifyingVisitor();
050 visitor.traverse(container);
051
052 container.start();
053 assertNotNull(container.getComponent(MockRunner.class));
054 }
055
056 }