1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.proxy2;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertTrue;
22
23 import java.lang.reflect.Proxy;
24
25 import org.apache.commons.proxy2.invoker.NullInvoker;
26 import org.junit.Before;
27 import org.junit.Test;
28
29
30
31
32 public class DefaultProxyFactoryTest
33 {
34 private ProxyFactory proxyFactory;
35
36 @Before
37 public void setUp()
38 {
39 proxyFactory = ProxyUtils.proxyFactory();
40 }
41
42 @Test
43 public void testBasic()
44 {
45 Foo foo = proxyFactory.createInvokerProxy(NullInvoker.INSTANCE, Foo.class);
46 assertNotNull(foo);
47 assertTrue(foo instanceof Proxy);
48 }
49
50 @Test
51 public void testSubclassing()
52 {
53 Bar bar = proxyFactory.createInvokerProxy(NullInvoker.INSTANCE, Bar.class);
54 assertNotNull(bar);
55 }
56
57 @Test
58 public void testCombined()
59 {
60 Bar bar = proxyFactory.createInvokerProxy(NullInvoker.INSTANCE, Bar.class, Foo.class);
61 assertNotNull(bar);
62 assertTrue(bar instanceof Foo);
63 }
64
65 public interface Foo
66 {
67 }
68
69 public static class Bar
70 {
71 }
72 }