commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r263814 - /jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
Date Sun, 28 Aug 2005 04:05:00 GMT
Author: jcarman
Date: Sat Aug 27 21:04:57 2005
New Revision: 263814

URL: http://svn.apache.org/viewcvs?rev=263814&view=rev
Log:
Added test case to verify that if a MethodInterceptor changes a parameter, the change is propogated.

Modified:
    jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java

Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java?rev=263814&r1=263813&r2=263814&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
(original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/factory/AbstractProxyFactoryTestCase.java
Sat Aug 27 21:04:57 2005
@@ -18,17 +18,15 @@
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.commons.proxy.ProxyFactory;
-import org.apache.commons.proxy.provider.ConstantProvider;
-import static org.apache.commons.proxy.provider.ProviderUtils.beanProvider;
-import static org.apache.commons.proxy.provider.ProviderUtils.singletonProvider;
+import static org.apache.commons.proxy.provider.ProviderUtils.*;
 import org.apache.commons.proxy.util.AbstractTestCase;
 import org.apache.commons.proxy.util.Echo;
 import org.apache.commons.proxy.util.EchoImpl;
 import org.apache.commons.proxy.util.SuffixMethodInterceptor;
 
+import java.io.IOException;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Method;
-import java.io.IOException;
 
 /**
  * @author James Carman
@@ -84,7 +82,7 @@
 
     public void testProxyWithCheckedException() throws Exception
     {
-        final Echo proxy = ( Echo ) factory.createProxy( new ConstantProvider( new EchoImpl()
), Echo.class );
+        final Echo proxy = ( Echo ) factory.createProxy( constantProvider( new EchoImpl()
), Echo.class );
         try
         {
             proxy.ioException();
@@ -97,7 +95,7 @@
 
     public void testProxyWithUncheckedException() throws Exception
     {
-        final Echo proxy = ( Echo ) factory.createProxy( new ConstantProvider( new EchoImpl()
), Echo.class );
+        final Echo proxy = ( Echo ) factory.createProxy( constantProvider( new EchoImpl()
), Echo.class );
         try
         {
             proxy.illegalArgument();
@@ -141,8 +139,23 @@
 
     }
 
+    public void testChangingArguments()
+    {
+        final Echo proxy = ( Echo ) factory.createInterceptorProxy( new EchoImpl(), new ChangeArgumentInterceptor(),
Echo.class );
+        assertEquals( "something different", proxy.echoBack( "whatever" ) );
+    }
+
     private static class PrivateEcho extends EchoImpl
     {
+    }
+
+    private static class ChangeArgumentInterceptor implements MethodInterceptor
+    {
+        public Object invoke( MethodInvocation methodInvocation ) throws Throwable
+        {
+            methodInvocation.getArguments()[0] = "something different";
+            return methodInvocation.proceed();
+        }
     }
 
     private static class NoOpMethodInterceptor implements MethodInterceptor



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message