X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fgeneral%2FLookupProxyFactoryTest.java;h=dd8930c0df88250e0e6d95ef73415e69ec05765c;hb=4a575582a5c2999bd816b197d9cf274b4b3ddcd7;hp=5dbf81ad3a78a3105b569e2355599d3cbe9e37b2;hpb=7d3754ca3d757ef89241cdbd679f82941e64cfc6;p=utils diff --git a/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java b/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java index 5dbf81ad..dd8930c0 100644 --- a/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java +++ b/support/general/src/test/java/org/wamblee/general/LookupProxyFactoryTest.java @@ -45,9 +45,9 @@ public class LookupProxyFactoryTest { public void setUp() throws Exception { intf = mock(MyInterface.class); lookup = mock(Lookup.class); - + LookupProxyFactory factory = new LookupProxyFactory( - MyInterface.class, lookup); + MyInterface.class, lookup); proxy = factory.getProxy(); } @@ -67,7 +67,8 @@ public class LookupProxyFactoryTest { @Test(expected = LookupException.class) public void testNotFoundAtJndi() throws Exception { - when(lookup.lookup()).thenThrow(new RuntimeException("Object not found")); + when(lookup.lookup()).thenThrow( + new RuntimeException("Object not found")); proxy.execute(); } @@ -95,13 +96,13 @@ public class LookupProxyFactoryTest { assertEquals(NAA_NA_NA_NAA_NA, e.getMessage()); } } - - private static final class MyLookup implements Lookup { - + + private static final class MyLookup implements Lookup { + @Override public Object lookup() throws Exception { return new MyInterface() { - + @Override public int execute() { return 10; @@ -109,24 +110,23 @@ public class LookupProxyFactoryTest { }; } } - - @Test + + @Test public void testProxyMustBerializable() throws Exception { lookup = new MyLookup(); LookupProxyFactory factory = new LookupProxyFactory( - MyInterface.class, lookup); + 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()); - - assertTrue(proxy instanceof Serializable); - - proxy = ObjectSerializationUtils.deserialize(ObjectSerializationUtils.serialize(proxy), - MyInterface.class); - - // and it should still work - assertEquals(10, proxy.execute()); } - }