(no commit message)
[utils] / support / general / src / test / java / org / wamblee / general / LookupProxyFactoryTest.java
index c7650906ffa2488103a72c606fcd8a6d93aca105..5dbf81ad3a78a3105b569e2355599d3cbe9e37b2 100644 (file)
@@ -18,6 +18,8 @@ package org.wamblee.general;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
+import java.io.Serializable;
+
 import javax.naming.InitialContext;
 
 import org.junit.After;
@@ -93,5 +95,38 @@ public class LookupProxyFactoryTest {
             assertEquals(NAA_NA_NA_NAA_NA, e.getMessage());
         }
     }
+    
+    private static final class MyLookup implements Lookup { 
+        
+        @Override
+        public Object lookup() throws Exception {
+            return new MyInterface() {
+                
+                @Override
+                public int execute() {
+                    return 10;
+                }
+            };
+        }
+    }
+    
+    @Test 
+    public void testProxyMustBerializable() throws Exception {
+        lookup = new MyLookup();
+        LookupProxyFactory<MyInterface> factory = new LookupProxyFactory<MyInterface>(
+            MyInterface.class, lookup); 
+        proxy = factory.getProxy();
+        
+        assertEquals(10, proxy.execute());
+        
+        assertTrue(proxy instanceof Serializable); 
+        
+        proxy = ObjectSerializationUtils.deserialize(ObjectSerializationUtils.serialize(proxy), 
+            MyInterface.class);
+        
+        // and it should still work 
+        assertEquals(10, proxy.execute());     
+    }
+    
 
 }