KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dynaop > ClassProxyCreatorTest


1 package dynaop;
2
3 import java.util.List JavaDoc;
4 import java.util.RandomAccess JavaDoc;
5
6 import junit.framework.TestCase;
7
8 /**
9  *
10  *
11  * @author Bob Lee (crazybob@crazybob.org)
12  */

13 public class ClassProxyCreatorTest extends TestCase {
14
15     public void testProxyCreation() {
16         ProxyTypeBuilder builder = new ProxyTypeBuilder(Foo.class);
17         builder.addInterface(RandomAccess JavaDoc.class);
18         builder.addInterface(List JavaDoc.class);
19         ProxyType type = builder.createProxyType();
20         ClassProxyCreator creator = new ClassProxyCreator(type, Foo.class);
21
22         Object JavaDoc proxy = creator.createProxy(null);
23         assertTrue(proxy instanceof RandomAccess JavaDoc);
24         assertTrue(proxy instanceof List JavaDoc);
25
26         proxy = creator.createProxy(null);
27         assertTrue(proxy instanceof RandomAccess JavaDoc);
28         assertTrue(proxy instanceof List JavaDoc);
29         
30         assertEquals(type, creator.getProxyType());
31     }
32     
33     public static class Foo {
34         public void foo() {}
35     }
36 }
37
Popular Tags