KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > defaults > issues > Issue0196TestCase


1 package org.picocontainer.defaults.issues;
2
3 import junit.framework.Assert;
4 import junit.framework.TestCase;
5 import org.picocontainer.MutablePicoContainer;
6 import org.picocontainer.defaults.DefaultPicoContainer;
7
8 public class Issue0196TestCase extends TestCase {
9     public static class Descriptor {
10         public static class DescriptorData {
11         }
12     }
13     public static class DescriptorDep {
14         public DescriptorDep(Descriptor.DescriptorData[] datas) {
15             Assert.assertEquals(3, datas.length);
16             Assert.assertNull(datas[0]);
17             Assert.assertNull(datas[1]);
18             Assert.assertNull(datas[2]);
19         }
20     }
21
22     public void testShouldAllowRegistrationOfArrayAsInstance() {
23         MutablePicoContainer pico = new DefaultPicoContainer();
24
25         Descriptor.DescriptorData[] datas = new Descriptor.DescriptorData[3];
26
27         pico.registerComponentInstance(datas);
28         pico.registerComponentImplementation(DescriptorDep.class);
29
30         DescriptorDep descriptorDep = (DescriptorDep) pico.getComponentInstanceOfType(DescriptorDep.class);
31
32         assertNotNull(descriptorDep);
33     }
34 }
35
Popular Tags