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.defaults.DefaultPicoContainer;
013 import org.picocontainer.defaults.VerifyingVisitor;
014
015 import junit.framework.TestCase;
016
017
018 public class Issue0229TestCase extends TestCase {
019 public static class MockRunnable implements Runnable {
020 public void run() {
021 }
022 }
023
024 public static class OtherRunnable implements Runnable {
025 public void run() {
026 }
027 }
028
029 public static class MockRunner {
030 private final Runnable[] _runners;
031
032 public MockRunner(Runnable[] runnables) {
033 _runners = runnables;
034 }
035
036 public Runnable[] getRunners(){
037 return _runners;
038 }
039 }
040
041 public void testArrayDependenciesAndVerification() {
042 DefaultPicoContainer container = new DefaultPicoContainer();
043 container.registerComponentImplementation(MockRunnable.class);
044 container.registerComponentImplementation(OtherRunnable.class);
045 container.registerComponentImplementation(MockRunner.class);
046
047 // this will fail to resolve the Runnable array on the MockRunner
048 VerifyingVisitor visitor = new VerifyingVisitor();
049 visitor.traverse(container);
050
051 container.start();
052 assertNotNull(container.getComponentInstanceOfType(MockRunner.class));
053 }
054
055 }