01: package org.mockejb.interceptor.test;
02:
03: import junit.framework.TestCase;
04: import org.mockejb.interceptor.*;
05:
06: /**
07: *
08: * @author Alexander Ananiev
09: */
10: public class InterceptableProxyTest extends TestCase {
11:
12: public void testInterfaceProxy() throws Exception {
13:
14: TestIface proxy = (TestIface) InterceptableProxy.create(
15: TestIface.class, new TestImpl());
16:
17: assertEquals("test", proxy.echo("test"));
18: }
19:
20: public void testClassProxy() throws Exception {
21:
22: InterceptableTestClass proxy = (InterceptableTestClass) InterceptableProxy
23: .create(InterceptableTestClass.class, new TestImpl());
24:
25: assertEquals("test", proxy.echo("test"));
26:
27: // Intercept the calls to the class itself
28: proxy = (InterceptableTestClass) InterceptableProxy.create(
29: InterceptableTestClass.class,
30: new InterceptableTestClass());
31:
32: assertEquals("test", proxy.echo("test"));
33:
34: }
35:
36: }
|