Package org.picocontainer.defaults.issues

Source Code of org.picocontainer.defaults.issues.Issue0229TestCase

/*****************************************************************************
* Copyright (C) PicoContainer Organization. All rights reserved.            *
* ------------------------------------------------------------------------- *
* The software in this package is published under the terms of the BSD      *
* style license a copy of which has been included with this distribution in *
* the LICENSE.txt file.                                                     *
*                                                                           *
* Original code by Michael Rettig                                           *
*****************************************************************************/
package org.picocontainer.defaults.issues;

import org.picocontainer.defaults.DefaultPicoContainer;
import org.picocontainer.defaults.VerifyingVisitor;

import junit.framework.TestCase;


public class Issue0229TestCase extends TestCase {
    public static class MockRunnable implements Runnable {
        public void run() {
        }
    }

    public static class OtherRunnable implements Runnable {
        public void run() {
        }
    }

    public static class MockRunner {
        private final Runnable[] _runners;

        public MockRunner(Runnable[] runnable) {
            _runners = runnable;
        }
    }

    public void testArrayDependenciesAndVerification() {
        DefaultPicoContainer container = new DefaultPicoContainer();
        container.registerComponentImplementation(MockRunnable.class);
        container.registerComponentImplementation(OtherRunnable.class);
        container.registerComponentImplementation(MockRunner.class);

        // this will fail to resolve the Runnable array on the MockRunner
        VerifyingVisitor visitor = new VerifyingVisitor();
        visitor.traverse(container);

        container.start();
        assertNotNull(container.getComponentInstanceOfType(MockRunner.class));
    }

}
TOP

Related Classes of org.picocontainer.defaults.issues.Issue0229TestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.