    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                                                          *
    009     *****************************************************************************/
    010    package org.picocontainer.defaults.issues;
    011
    012    import static org.junit.Assert.assertNotNull;
    013    import junit.framework.Assert;
    014
    015    import org.junit.Test;
    016    import org.picocontainer.DefaultPicoContainer;
    017    import org.picocontainer.MutablePicoContainer;
    018
    019    public class Issue0196TestCase {
    020        public static class Descriptor {
    021            public static class DescriptorData {
    022            }
    023        }
    024        public static class DescriptorDep {
    025            public DescriptorDep(Descriptor.DescriptorData[] datas) {
    026                Assert.assertEquals(3, datas.length);
    027                Assert.assertNull(datas[0]);
    028                Assert.assertNull(datas[1]);
    029                Assert.assertNull(datas[2]);
    030            }
    031        }
    032
    033        @Test public void testShouldAllowRegistrationOfArrayAsInstance() {
    034            MutablePicoContainer pico = new DefaultPicoContainer();
    035
    036            Descriptor.DescriptorData[] datas = new Descriptor.DescriptorData[3];
    037
    038            pico.addComponent(datas);
    039            pico.addComponent(DescriptorDep.class);
    040
    041            DescriptorDep descriptorDep = pico.getComponent(DescriptorDep.class);
    042
    043            assertNotNull(descriptorDep);
    044        }
    045    }