KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tests > jfun > yan > SingletonProxyContainerTestCase


1 /*****************************************************************************
2  * Copyright (C) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Original code by the committers *
9  *****************************************************************************/

10
11 package tests.jfun.yan;
12
13 import jfun.yan.containers.*;
14 import jfun.yan.*;
15 import junit.framework.TestSuite;
16
17 import java.util.List JavaDoc;
18 import java.util.ArrayList JavaDoc;
19
20 /**
21  * @author Paul Hammant
22  * @version $Revision: 1.2 $
23  */

24 public class SingletonProxyContainerTestCase
25 extends BaseProxyContainerTestCase {
26   public static void main(String JavaDoc[] args){
27     Utils.runTest(suite());
28   }
29   private static TestSuite suite(){
30     return new TestSuite(SingletonProxyContainerTestCase.class);
31   }
32     protected Container createImplementationHidingPicoContainer() {
33         return new SingletonProxyContainer();
34     }
35
36     protected Container createPicoContainer(Container parent) {
37         return new SingletonProxyContainer().inherit(parent);
38     }
39
40     public void testUsageOfADifferentComponentAdapterFactory() {
41         // Jira bug 212 - logical opposite
42
Container parent = new DefaultContainer();
43         Container pico =
44           new SingletonProxyContainer().inherit(parent);
45         pico.registerConstructor(List JavaDoc.class, ArrayList JavaDoc.class, null);
46         pico.verify();
47         List JavaDoc list1 = (List JavaDoc) pico.getInstanceOfType(List JavaDoc.class);
48         List JavaDoc list2 = (List JavaDoc) pico.getInstanceOfType(List JavaDoc.class);
49         assertNotNull(list1);
50         assertNotNull(list2);
51         assertTrue(list1 == list2);
52     }
53     protected Container getContainerImpl(){
54       return new SingletonProxyContainer();
55     }
56
57 }
58
Popular Tags