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