KickJava   Java API By Example, From Geeks To Geeks.

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


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  *****************************************************************************/

9 package tests.jfun.yan;
10
11 import jfun.yan.*;
12 import jfun.yan.containers.DefaultContainer;
13 import jfun.yan.containers.ProxyContainer;
14 import junit.framework.TestSuite;
15
16 import java.util.List JavaDoc;
17 import java.util.ArrayList JavaDoc;
18
19 public class ProxyContainerTestCase
20 extends BaseProxyContainerTestCase {
21   public static void main(String JavaDoc[] args){
22     tests.jfun.yan.Utils.runTest(suite());
23   }
24   private static TestSuite suite(){
25     return new TestSuite(ProxyContainerTestCase.class);
26   }
27     protected Container createImplementationHidingPicoContainer() {
28         return new ProxyContainer();
29     }
30
31     protected Container createPicoContainer(Container parent) {
32         return new ProxyContainer().inherit(parent);
33     }
34 /*
35     public void testStartStopAndDisposeNotCascadedtoRemovedChildren() {
36         super.testStartStopAndDisposeNotCascadedtoRemovedChildren();
37     }
38 */

39     public static class MyThread extends Thread JavaDoc {
40         public MyThread(String JavaDoc s){super(s);}
41     }
42 /*
43     public void testHidingWithoutParameter() {
44         // this was a bug reported by Arnd Kors on 21st Sept on the mail list.
45         ProxyContainer pico = new ProxyContainer();
46         pico.registerConstructor(String.class);
47         pico.registerConstructor(Runnable.class, MyThread.class);
48         new VerifyingVisitor().traverse(pico);
49     }*/

50
51     public void testUsageOfADifferentComponentAdapterFactory() {
52         // Jira bug 212
53
Container parent = new DefaultContainer();
54         Container pico = new ProxyContainer().inherit(parent);
55         pico.registerConstructor(List JavaDoc.class, ArrayList JavaDoc.class, null);
56         List JavaDoc list1 = (List JavaDoc) pico.getInstanceOfType(List JavaDoc.class);
57         List JavaDoc list2 = (List JavaDoc) pico.getInstanceOfType(List JavaDoc.class);
58         pico.verify();
59         assertNotNull(list1);
60         assertNotNull(list2);
61         assertFalse(list1 == list2);
62     }
63 }
64
Popular Tags