01: package dynaop;
02:
03: import java.util.List;
04: import java.util.RandomAccess;
05:
06: import junit.framework.TestCase;
07:
08: /**
09: *
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.class);
18: builder.addInterface(List.class);
19: ProxyType type = builder.createProxyType();
20: ClassProxyCreator creator = new ClassProxyCreator(type,
21: Foo.class);
22:
23: Object proxy = creator.createProxy(null);
24: assertTrue(proxy instanceof RandomAccess);
25: assertTrue(proxy instanceof List);
26:
27: proxy = creator.createProxy(null);
28: assertTrue(proxy instanceof RandomAccess);
29: assertTrue(proxy instanceof List);
30:
31: assertEquals(type, creator.getProxyType());
32: }
33:
34: public static class Foo {
35: public void foo() {
36: }
37: }
38: }
|