Permalink
Browse files

Add bridge method tests

  • Loading branch information...
1 parent 0b3de78 commit 8aad172b6aec9830b43565da53395e5bcf91a4bc @stuartwdouglas stuartwdouglas committed Apr 11, 2011
@@ -26,9 +26,11 @@
public class BridgeMethodInvocationHandler implements InvocationHandler {
- @Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- return method;
+ if(method.getName().equals("getResult")) {
+ return method;
+ }
+ return 20;
}
}
@@ -27,4 +27,8 @@ public Object getResult() {
return null;
}
+ public int proxyMethod() {
+ return 10;
+ }
+
}
@@ -21,13 +21,12 @@
*/
package org.jboss.invocation.proxy.test.proxyfactory;
-import java.lang.reflect.Method;
-
import junit.framework.Assert;
-
import org.jboss.invocation.proxy.ProxyFactory;
import org.junit.Test;
+import java.lang.reflect.Method;
+
public class BridgeMethodTest {
@Test
@@ -46,4 +45,10 @@ public void testParent(BridgeMethodParent parent) {
Assert.assertTrue(result.isBridge());
}
+ public void testParentMethodProxied() throws IllegalAccessException, InstantiationException {
+ ProxyFactory<BridgeMethodChild> proxyFactory = new ProxyFactory<BridgeMethodChild>(BridgeMethodChild.class);
+ BridgeMethodChild instance = proxyFactory.newInstance(new BridgeMethodInvocationHandler());
+ Assert.assertEquals(20,instance.proxyMethod());
+ }
+
}

0 comments on commit 8aad172

Please sign in to comment.