http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java index 141bb0b..683ec03 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java @@ -113,12 +113,10 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { public void testSimpleDurableClient() { // Step 1: Starting the servers - PORT1 = ((Integer)this.server1VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true) - })).intValue(); - PORT2 = ((Integer)this.server2VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true), - })).intValue(); + PORT1 = ((Integer)this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true) + ))).intValue(); + PORT2 = ((Integer)this.server2VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true), + ))).intValue(); // Step 2: Bring Up the Client // Start a durable client that is not kept alive on the server when it @@ -127,12 +125,11 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { final int durableClientTimeout = 600; // keep the client alive for 600 // seconds - this.durableClientVM.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { + this.durableClientVM.invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), regionName, getClientDistributedSystemProperties(durableClientId, - durableClientTimeout), Boolean.TRUE }); + durableClientTimeout), Boolean.TRUE )); // Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -146,66 +143,46 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // KEY_STONE1, KEY_STONE2 are registered as durableKeys & KEY_STONE3, // KEY_STONE4 as non-durableKeys - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K2, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K3, new Boolean(true) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K4, new Boolean(true) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K2, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K3, new Boolean(true) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K4, new Boolean(true) )); // Step 4: Update Values on the Server for KEY_STONE1, KEY_STONE2, // KEY_STONE3, KEY_STONE4 - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "Value1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "Value2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "Value3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "Value4" }); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "Value1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "Value2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "Value3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "Value4" )); Wait.pause(1000); // Step 5: Verify Updates on the Client - assertEquals("Value1", this.server2VM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); - assertEquals("Value1", this.server1VM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); + assertEquals("Value1", this.server2VM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertEquals("Value1", this.server1VM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); - assertEquals("Value1", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); - assertEquals("Value2", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K2 })); - assertEquals("Value3", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K3 })); - assertEquals("Value4", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K4 })); + assertEquals("Value1", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertEquals("Value2", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); + assertEquals("Value3", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K3 ))); + assertEquals("Value4", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K4 ))); // Step 6: Close Cache of the DurableClient - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "closeCache"); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.closeCache()); // pause(5000); // Step 7: Update KEY_STONE1,KEY_STONE2,KEY_STONE3,KEY_STONE4 on the // Server say with values PingPong1, PingPong2, PingPong3, PingPong4 - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "PingPong1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "PingPong2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "PingPong3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "PingPong4" }); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "PingPong1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "PingPong2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "PingPong3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "PingPong4" )); // Step 8: Re-start the Client this.durableClientVM - .invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), + .invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), regionName, getClientDistributedSystemProperties(durableClientId), - Boolean.TRUE }); + Boolean.TRUE )); // Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -217,61 +194,46 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { Wait.pause(5000); - assertNull(this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K1 })); - assertNull(this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K2 })); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); Wait.pause(5000); - assertNull(this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K1 })); - assertNull(this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K2 })); - - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "PingPong_updated_1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "PingPong_updated_2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "PingPong_updated_3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "PingPong_updated_4" }); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); + + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "PingPong_updated_1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "PingPong_updated_2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "PingPong_updated_3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "PingPong_updated_4" )); Wait.pause(5000); // Step 9: Verify Updates on the Client - assertEquals("PingPong_updated_1", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); - assertNull(this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K2 })); - assertEquals("PingPong_updated_3", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K3 })); - assertEquals("PingPong_updated_4", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K4 })); + assertEquals("PingPong_updated_1", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); + assertEquals("PingPong_updated_3", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K3 ))); + assertEquals("PingPong_updated_4", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K4 ))); // Step 10 : Stop all VMs // Stop the durable client - this.durableClientVM.invoke(CacheServerTestUtil.class, "closeCache"); + this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 2 - this.server2VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server2VM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 1 - this.server1VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server1VM.invoke(() -> CacheServerTestUtil.closeCache()); } public void testSimpleDurableClientWithRegistration() { // Step 1: Starting the servers - PORT1 = ((Integer)this.server1VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true) - })).intValue(); - PORT2 = ((Integer)this.server2VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true) - })).intValue(); + PORT1 = ((Integer)this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true) + ))).intValue(); + PORT2 = ((Integer)this.server2VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true) + ))).intValue(); // Step 2: Bring Up the Client // Start a durable client that is not kept alive on the server when it @@ -279,12 +241,11 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { final String durableClientId = getName() + "_client"; // keep the client alive for 600 seconds final int durableClientTimeout = 600; - this.durableClientVM.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { + this.durableClientVM.invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), regionName, getClientDistributedSystemProperties(durableClientId, - durableClientTimeout) }); + durableClientTimeout) )); // Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -298,66 +259,46 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // KEY_STONE1, KEY_STONE2 are registered as durableKeys & KEY_STONE3, // KEY_STONE4 as non-durableKeys - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K2, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K3, new Boolean(true) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K4, new Boolean(true) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K2, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K3, new Boolean(true) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K4, new Boolean(true) )); // Step 4: Update Values on the Server for KEY_STONE1, KEY_STONE2, // KEY_STONE3, KEY_STONE4 - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "Value1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "Value2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "Value3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "Value4" }); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "Value1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "Value2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "Value3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "Value4" )); Wait.pause(1000); // Step 5: Verify Updates on the Client - assertEquals("Value1", this.server2VM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); - assertEquals("Value1", this.server1VM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); + assertEquals("Value1", this.server2VM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertEquals("Value1", this.server1VM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); - assertEquals("Value1", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); - assertEquals("Value2", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K2 })); - assertEquals("Value3", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K3 })); - assertEquals("Value4", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K4 })); + assertEquals("Value1", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); + assertEquals("Value2", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); + assertEquals("Value3", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K3 ))); + assertEquals("Value4", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K4 ))); // Step 6: Close Cache of the DurableClient - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "closeCache"); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.closeCache()); // pause(5000); // Step 7: Update KEY_STONE1,KEY_STONE2,KEY_STONE3,KEY_STONE4 on the // Server say with values PingPong1, PingPong2, PingPong3, PingPong4 - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "PingPong1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "PingPong2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "PingPong3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "PingPong4" }); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "PingPong1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "PingPong2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "PingPong3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "PingPong4" )); // Step 8: Re-start the Client this.durableClientVM - .invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), + .invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 0), regionName, getClientDistributedSystemProperties(durableClientId), - Boolean.TRUE }); + Boolean.TRUE )); // Step 9: Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -370,89 +311,71 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // pause(1000); // Step 10: Register all Keys - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K3, new Boolean(true) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K4, new Boolean(true) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K3, new Boolean(true) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K4, new Boolean(true) )); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K2, new Boolean(false) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K2, new Boolean(false) )); // Step 11: Unregister Some Keys (Here K1, K3) - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "unregisterKey", new Object[] { K1 }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "unregisterKey", new Object[] { K3 }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.unregisterKey( K1 )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.unregisterKey( K3 )); Wait.pause(5000); // Step 12: Modify values on the server for all the Keys - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K1, "PingPong_updated_1" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K2, "PingPong_updated_2" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K3, "PingPong_updated_3" }); - this.server2VM.invoke(DurableRegistrationDUnitTest.class, "putValue", - new Object[] { K4, "PingPong_updated_4" }); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K1, "PingPong_updated_1" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K2, "PingPong_updated_2" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K3, "PingPong_updated_3" )); + this.server2VM.invoke(() -> DurableRegistrationDUnitTest.putValue( K4, "PingPong_updated_4" )); Wait.pause(5000); // Step 13: Check the values for the ones not unregistered and the // Unregistered Keys' Values should be null try { - assertEquals("PingPong_updated_2", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K2 })); + assertEquals("PingPong_updated_2", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); } catch (Exception e) { fail("Prob in KEY_STONE2: " - + this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K2 })); + + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K2 ))); } try { - assertEquals("PingPong_updated_4", this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K4 })); + assertEquals("PingPong_updated_4", this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K4 ))); } catch (Exception e) { fail("Prob in KEY_STONE4: " - + this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K4 })); + + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K4 ))); } try { - assertNull(this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K1 })); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); } catch (Exception e) { fail("Prob in KEY_STONE1: " - + this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K1 })); + + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K1 ))); } try { - assertNull(this.durableClientVM.invoke( - DurableRegistrationDUnitTest.class, "getValue", new Object[] { K3 })); + assertNull(this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K3 ))); } catch (Exception e) { fail("Prob in KEY_STONE3: " - + this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "getValue", new Object[] { K3 })); + + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.getValue( K3 ))); } // Stop the durable client - this.durableClientVM.invoke(CacheServerTestUtil.class, "closeCache"); + this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 2 - this.server2VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server2VM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 1 - this.server1VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server1VM.invoke(() -> CacheServerTestUtil.closeCache()); } @@ -461,21 +384,19 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // Step 1: Start server1 PORT2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); - PORT1 = ((Integer)this.server1VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true) - })).intValue(); + PORT1 = ((Integer)this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true) + ))).intValue(); // Step 2: Bring Up the Client final String durableClientId = getName() + "_client"; // keep the client alive for 600 seconds final int durableClientTimeout = 600; - this.durableClientVM.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { + this.durableClientVM.invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 1), regionName, getClientDistributedSystemProperties(durableClientId, - durableClientTimeout) }); + durableClientTimeout) )); // Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -486,20 +407,15 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { }); // Step 3: Client registers Interests - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K2, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K3, new Boolean(true) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K4, new Boolean(true) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K2, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K3, new Boolean(true) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K4, new Boolean(true) )); // Step 4: Bring up the server2 - this.server2VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true), - PORT2 }); + this.server2VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true), + PORT2 )); Wait.pause(3000); @@ -546,13 +462,13 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // Stop the durable client - this.durableClientVM.invoke(CacheServerTestUtil.class, "closeCache"); + this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 2 - this.server2VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server2VM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 1 - this.server1VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server1VM.invoke(() -> CacheServerTestUtil.closeCache()); } @@ -561,21 +477,19 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // Step 1: Start server1 PORT2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET)); - PORT1 = ((Integer)this.server1VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true) - })).intValue(); + PORT1 = ((Integer)this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true) + ))).intValue(); // Step 2: Bring Up the Client final String durableClientId = getName() + "_client"; // keep the client alive for 600 seconds final int durableClientTimeout = 600; - this.durableClientVM.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { + this.durableClientVM.invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 1), regionName, getClientDistributedSystemProperties(durableClientId, - durableClientTimeout) }); + durableClientTimeout) )); // Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -586,28 +500,22 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { }); // Step 3: Client registers Interests - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K1, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K2, new Boolean(false) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K3, new Boolean(true) }); - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "registerKey", new Object[] { K4, new Boolean(true) }); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K1, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K2, new Boolean(false) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K3, new Boolean(true) )); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.registerKey( K4, new Boolean(true) )); // Close Cache of the DurableClient - this.durableClientVM.invoke(DurableRegistrationDUnitTest.class, - "closeCache"); + this.durableClientVM.invoke(() -> DurableRegistrationDUnitTest.closeCache()); Wait.pause(2000); //Re-start the Client this.durableClientVM - .invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] { getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 1), + .invoke(() -> CacheServerTestUtil.createCacheClient( getClientPool(NetworkUtils.getServerHostName(durableClientVM.getHost()), PORT1, PORT2, true, 1), regionName, getClientDistributedSystemProperties(durableClientId), - Boolean.TRUE }); + Boolean.TRUE )); //Send clientReady message this.durableClientVM.invoke(new CacheSerializableRunnable( @@ -618,9 +526,8 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { }); // Step 4: Bring up the server2 - this.server2VM.invoke(CacheServerTestUtil.class, - "createCacheServer", new Object[] { regionName, new Boolean(true), - PORT2 }); + this.server2VM.invoke(() -> CacheServerTestUtil.createCacheServer( regionName, new Boolean(true), + PORT2 )); Wait.pause(3000); @@ -666,13 +573,13 @@ public class DurableRegistrationDUnitTest extends DistributedTestCase { // Stop the durable client - this.durableClientVM.invoke(CacheServerTestUtil.class, "closeCache"); + this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 2 - this.server2VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server2VM.invoke(() -> CacheServerTestUtil.closeCache()); // Stop server 1 - this.server1VM.invoke(CacheServerTestUtil.class, "closeCache"); + this.server1VM.invoke(() -> CacheServerTestUtil.closeCache()); }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java index 4f1028c..bc49f93 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/DurableResponseMatrixDUnitTest.java @@ -69,8 +69,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase final Host host = Host.getHost(0); server1 = host.getVM(0); // start servers first - PORT1 = ((Integer)server1.invoke(DurableResponseMatrixDUnitTest.class, - "createServerCache")); + PORT1 = ((Integer)server1.invoke(() -> DurableResponseMatrixDUnitTest.createServerCache())); createCacheClient(NetworkUtils.getServerHostName(server1.getHost())); //Disconnecting the client can cause this IgnoredException.addIgnoredException("Connection reset||Unexpected IOException"); @@ -79,8 +78,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase public void testRegisterInterestResponse_NonExistent_Invalid() throws Exception { - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntry( KEY )); Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertFalse(r.containsValueForKey(KEY)); // invalidate @@ -89,8 +87,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase public void testRegisterInterestResponse_NonExistent_Valid() throws Exception { - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals("ValueMatrix1", r.getEntry(KEY).getValue()); @@ -100,8 +97,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "ValueMatrix1"); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntry( KEY )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals("ValueMatrix1", r.getEntry(KEY).getValue()); } @@ -118,8 +114,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntry( KEY )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals(null, r.getEntry(KEY).getValue()); } @@ -129,8 +124,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals("ValueMatrix1", r.getEntry(KEY).getValue()); } @@ -140,8 +134,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.destroy(KEY); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntry( KEY )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertFalse(r.containsValueForKey(KEY)); // invalidate assertEquals(null, r.getEntry(KEY).getValue()); // invalidate @@ -152,8 +145,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.destroy(KEY); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals("ValueMatrix1", r.getEntry(KEY).getValue()); } @@ -172,8 +164,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); r.registerInterest(KEY, InterestResultPolicy.KEYS_VALUES); assertEquals(null, r.getEntry(KEY)); @@ -208,8 +199,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -217,32 +207,26 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix2" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix2" )); waitForValue(r, KEY, "ValueMatrix2"); } public void testNotification_NonExistent_Invalid() throws Exception { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntryOnly", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntryOnly( KEY )); waitForValue(r, KEY, null); // invalidate } public void testNotification_NonExistent_Destroy() throws Exception { Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "destroyEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.destroyEntry( KEY )); waitForValue(r, KEY, null); // destroyed } @@ -251,8 +235,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -261,8 +244,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix2" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix2" )); waitForValue(r, KEY, "ValueMatrix2"); } @@ -271,8 +253,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntryOnly", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntryOnly( KEY )); waitForValue(r, KEY, null); // invalidate } @@ -281,8 +262,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); r.put(KEY, "DummyValue"); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "destroyEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.destroyEntry( KEY )); waitForValue(r, KEY, null); // destroyed } @@ -291,8 +271,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -301,8 +280,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -311,8 +289,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntryOnly", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntryOnly( KEY )); waitForValue(r, KEY, null); // invalidate } @@ -321,8 +298,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "destroyEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.destroyEntry( KEY )); waitForValue(r, KEY, null); // destroyed } @@ -331,8 +307,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); localInvalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -341,8 +316,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); localInvalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "updateEntry", - new Object[] { KEY, "ValueMatrix1" }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.updateEntry( KEY, "ValueMatrix1" )); waitForValue(r, KEY, "ValueMatrix1"); } @@ -351,8 +325,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); localInvalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "invalidateEntryOnly", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.invalidateEntryOnly( KEY )); waitForValue(r, KEY, null); // invalidate } @@ -361,8 +334,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase Region r = cache.getRegion(Region.SEPARATOR + REGION_NAME); invalidateEntry(KEY); r.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); - server1.invoke(DurableResponseMatrixDUnitTest.class, "destroyEntry", - new Object[] { KEY }); + server1.invoke(() -> DurableResponseMatrixDUnitTest.destroyEntry( KEY )); waitForValue(r, KEY, null); // destroyed } @@ -513,7 +485,7 @@ public class DurableResponseMatrixDUnitTest extends DistributedTestCase // close the clients first closeCache(); // then close the servers - server1.invoke(DurableResponseMatrixDUnitTest.class, "closeCache"); + server1.invoke(() -> DurableResponseMatrixDUnitTest.closeCache()); } public static void closeCache() http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java index 78e0f41..a0926f2 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationDUnitTest.java @@ -92,10 +92,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase vm1 = host.getVM(1); //start servers first - PORT1 = ((Integer)vm0.invoke(EventIDVerificationDUnitTest.class, - "createServerCache")).intValue(); - PORT2 = ((Integer)vm1.invoke(EventIDVerificationDUnitTest.class, - "createServerCache")).intValue(); + PORT1 = ((Integer)vm0.invoke(() -> EventIDVerificationDUnitTest.createServerCache())).intValue(); + PORT2 = ((Integer)vm1.invoke(() -> EventIDVerificationDUnitTest.createServerCache())).intValue(); //vm2.invoke(EventIDVerificationDUnitTest.class, "createClientCache", new // Object[] { new Integer(PORT1),new Integer(PORT2)}); @@ -107,24 +105,20 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void testEventIDOnServer() { createEntry(); - Boolean pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + Boolean pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); put(); - pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); destroy(); - pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); put(); cache.getLogger().info("going to remove"); remove(); cache.getLogger().info("after remove"); - pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); } @@ -136,11 +130,9 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void testEventIDPrapogationOnServerDuringRegionDestroy() { destroyRegion(); - Boolean pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + Boolean pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); - pass = (Boolean)vm1.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + pass = (Boolean)vm1.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); } @@ -152,11 +144,9 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void testEventIDPrapogationOnServerDuringRegionClear() { clearRegion(); - Boolean pass = (Boolean)vm0.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + Boolean pass = (Boolean)vm0.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); - pass = (Boolean)vm1.invoke(EventIDVerificationDUnitTest.class, - "verifyResult"); + pass = (Boolean)vm1.invoke(() -> EventIDVerificationDUnitTest.verifyResult()); assertTrue(pass.booleanValue()); } @@ -190,10 +180,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase CacheWriter writer = new CacheWriterAdapter() { public void beforeCreate(EntryEvent event) { - vm0.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); - vm1.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); + vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); + vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); try { super.beforeCreate(event); } @@ -207,10 +195,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void beforeUpdate(EntryEvent event) { - vm0.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); - vm1.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); + vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); + vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); try { super.beforeUpdate(event); } @@ -224,10 +210,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void beforeDestroy(EntryEvent event) { - vm0.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); - vm1.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((EntryEventImpl)event).getEventId() }); + vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); + vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((EntryEventImpl)event).getEventId() )); try { super.beforeDestroy(event); } @@ -241,10 +225,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void beforeRegionDestroy(RegionEvent event) { - vm0.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((RegionEventImpl)event).getEventId() }); - vm1.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((RegionEventImpl)event).getEventId() }); + vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((RegionEventImpl)event).getEventId() )); + vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((RegionEventImpl)event).getEventId() )); try { super.beforeRegionDestroy(event); } @@ -257,10 +239,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase public void beforeRegionClear(RegionEvent event) { - vm0.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((RegionEventImpl)event).getEventId() }); - vm1.invoke(EventIDVerificationDUnitTest.class, "setEventIDData", - new Object[] { ((RegionEventImpl)event).getEventId() }); + vm0.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((RegionEventImpl)event).getEventId() )); + vm1.invoke(() -> EventIDVerificationDUnitTest.setEventIDData( ((RegionEventImpl)event).getEventId() )); try { super.beforeRegionClear(event); } @@ -493,8 +473,8 @@ public class EventIDVerificationDUnitTest extends DistributedTestCase // close the clients first closeCache(); // then close the servers - vm0.invoke(EventIDVerificationDUnitTest.class, "closeCache"); - vm1.invoke(EventIDVerificationDUnitTest.class, "closeCache"); + vm0.invoke(() -> EventIDVerificationDUnitTest.closeCache()); + vm1.invoke(() -> EventIDVerificationDUnitTest.closeCache()); } public static void closeCache() http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationInP2PDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationInP2PDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationInP2PDUnitTest.java index 15a709b..2df2cf6 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationInP2PDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/EventIDVerificationInP2PDUnitTest.java @@ -82,40 +82,33 @@ public class EventIDVerificationInP2PDUnitTest extends DistributedTestCase public void testEventIDsDACK() throws Exception { createServerCache(new Integer(DISTRIBUTED_ACK)); - vm0.invoke(EventIDVerificationInP2PDUnitTest.class, "createServerCache", - new Object[] { new Integer(DISTRIBUTED_ACK) }); + vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.createServerCache( new Integer(DISTRIBUTED_ACK) )); verifyOperations(); } public void testEventIDsGLOBAL() throws Exception { createServerCache(new Integer(GLOBAL)); - vm0.invoke(EventIDVerificationInP2PDUnitTest.class, "createServerCache", - new Object[] { new Integer(GLOBAL) }); + vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.createServerCache( new Integer(GLOBAL) )); verifyOperations(); } public void _testEventIDsNOACK() throws Exception { createServerCache(new Integer(0)); - vm0.invoke(EventIDVerificationInP2PDUnitTest.class, "createServerCache", - new Object[] { new Integer(0) }); + vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.createServerCache( new Integer(0) )); createEntry(); - Boolean pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + Boolean pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertFalse(pass.booleanValue()); put(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertFalse(pass.booleanValue()); destroy(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertFalse(pass.booleanValue()); destroyRegion(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertFalse(pass.booleanValue()); } @@ -297,31 +290,26 @@ public class EventIDVerificationInP2PDUnitTest extends DistributedTestCase public static void verifyOperations() { createEntry(); - Boolean pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + Boolean pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertTrue(pass.booleanValue()); put(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertTrue(pass.booleanValue()); invalidateRegion(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertTrue(pass.booleanValue()); destroy(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertTrue(pass.booleanValue()); destroyRegion(); - pass = (Boolean)vm0.invoke(EventIDVerificationInP2PDUnitTest.class, - "verifyResult", new Object[]{eventId} ); + pass = (Boolean)vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.verifyResult(eventId)); assertTrue(pass.booleanValue()); } @Override protected final void preTearDown() throws Exception { closeCache(); - vm0.invoke(EventIDVerificationInP2PDUnitTest.class, "closeCache"); + vm0.invoke(() -> EventIDVerificationInP2PDUnitTest.closeCache()); } public static void closeCache() http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java index 08175dd..df81db8 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java @@ -89,19 +89,19 @@ public class HABug36738DUnitTest extends DistributedTestCase @Override protected final void preTearDown() throws Exception { - server1.invoke(HABug36738DUnitTest.class, "closeCache"); - server2.invoke(HABug36738DUnitTest.class, "closeCache"); + server1.invoke(() -> HABug36738DUnitTest.closeCache()); + server2.invoke(() -> HABug36738DUnitTest.closeCache()); } public void testBug36768() throws Exception { createServer1(); Wait.pause(10000); - server1.invoke(HABug36738DUnitTest.class, "checkRegionQueueSize"); + server1.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); createServer2(); - server1.invoke(HABug36738DUnitTest.class, "checkRegionQueueSize"); - server2.invoke(HABug36738DUnitTest.class, "checkRegionQueueSize"); - server2.invoke(HABug36738DUnitTest.class, "printRecs"); + server1.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); + server2.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); + server2.invoke(() -> HABug36738DUnitTest.printRecs()); } public static void printRecs() @@ -122,15 +122,13 @@ public class HABug36738DUnitTest extends DistributedTestCase // function to create server and region in it. private void createServer1() throws Exception { - server1.invoke(HABug36738DUnitTest.class, "createServerCache", - new Object[] { new Boolean(true) }); + server1.invoke(() -> HABug36738DUnitTest.createServerCache( new Boolean(true) )); } // function to create server without region. private void createServer2() throws Exception { - server2.invoke(HABug36738DUnitTest.class, "createServerCache", - new Object[] { new Boolean(false) }); + server2.invoke(() -> HABug36738DUnitTest.createServerCache( new Boolean(false) )); } public static void createServerCache(Boolean isRegion) throws Exception http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java index fc9211d..d236bc5 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart1DUnitTest.java @@ -33,14 +33,14 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testInterestRegistrationOnBothPrimaryAndSecondary() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); // register K1 and K2 registerK1AndK2(); - server1.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server2.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server3.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server1.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server2.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server3.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -50,9 +50,9 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testInterestRegistrationResponseOnBothPrimaryAndSecondary() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); // register interest and verify response registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse(); } @@ -64,15 +64,15 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testRERegistrationWillNotCreateDuplicateKeysOnServerInterstMaps() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); // register multiple times reRegisterK1AndK2(); - server1.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server2.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server3.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server1.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server2.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server3.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -83,9 +83,9 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testPrimaryFailureInRegisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); // stop primary VM oldPrimary = getPrimaryVM(); stopPrimaryAndRegisterK1AndK2AndVerifyResponse(); @@ -93,8 +93,8 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { verifyDeadAndLiveServers(1, 2); // new primary VM newPrimary = getPrimaryVM(oldPrimary); - newPrimary.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); - newPrimary.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + newPrimary.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); + newPrimary.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -104,17 +104,17 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testSecondaryFailureInRegisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); VM primary = getPrimaryVM(); stopSecondaryAndRegisterK1AndK2AndVerifyResponse(); verifyDeadAndLiveServers(1, 2); // still primary - primary.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); - primary.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + primary.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); + primary.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -126,17 +126,17 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testBothPrimaryAndSecondaryFailureInRegisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); // stop server1 and server2 VM oldPrimary = getPrimaryVM(); stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse(); verifyDeadAndLiveServers(2, 1); VM newPrimary = getPrimaryVM(oldPrimary); - newPrimary.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); - newPrimary.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + newPrimary.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); + newPrimary.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -150,17 +150,17 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { public void testProbablePrimaryFailureInRegisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); VM oldPrimary = getPrimaryVM(); stopPrimaryAndRegisterK1AndK2AndVerifyResponse(); verifyDeadAndLiveServers(1, 2); VM newPrimary = getPrimaryVM(oldPrimary); - newPrimary.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); - newPrimary.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + newPrimary.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); + newPrimary.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -174,40 +174,40 @@ public class HAInterestPart1DUnitTest extends HAInterestTestCase { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); registerK1AndK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); - server1.invoke(HAInterestTestCase.class, "stopServer"); - server2.invoke(HAInterestTestCase.class, "stopServer"); - server3.invoke(HAInterestTestCase.class, "stopServer"); + server1.invoke(() -> HAInterestTestCase.stopServer()); + server2.invoke(() -> HAInterestTestCase.stopServer()); + server3.invoke(() -> HAInterestTestCase.stopServer()); // All servers are dead at this point , no primary in the system. verifyDeadAndLiveServers(3, 0); // now start one of the servers - server2.invoke(HAInterestTestCase.class, "startServer"); + server2.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(2, 1); // verify that is it primary , and dispatcher is running - server2.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); + server2.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); // verify that interest is registered on this recovered EP - server2.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server2.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); // now start one more server ; this should be now secondary - server1.invoke(HAInterestTestCase.class, "startServer"); + server1.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(1, 2); // verify that is it secondary , dispatcher should not be runnig - server1.invoke(HAInterestTestCase.class, "verifyDispatcherIsNotAlive"); + server1.invoke(() -> HAInterestTestCase.verifyDispatcherIsNotAlive()); // verify that interest is registered on this recovered EP as well - server1.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server1.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); // now start one more server ; this should be now secondary - server3.invoke(HAInterestTestCase.class, "startServer"); + server3.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(0, 3); // verify that is it secondary , dispatcher should not be runnig - server3.invoke(HAInterestTestCase.class, "verifyDispatcherIsNotAlive"); + server3.invoke(() -> HAInterestTestCase.verifyDispatcherIsNotAlive()); // verify that interest is registered on this recovered EP as well - server3.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server3.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/69024aa9/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart2DUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart2DUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart2DUnitTest.java index 647069f..02c3e71 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart2DUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HAInterestPart2DUnitTest.java @@ -39,9 +39,9 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { public void testPrimaryFailureInUNregisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); registerK1AndK2(); @@ -51,11 +51,11 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { verifyDeadAndLiveServers(1, 2); VM newPrimary = getPrimaryVM(oldPrimary); - newPrimary.invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); + newPrimary.invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); // primary - newPrimary.invoke(HAInterestTestCase.class, "verifyInterestUNRegistration"); + newPrimary.invoke(() -> HAInterestTestCase.verifyInterestUNRegistration()); // secondary - getBackupVM().invoke(HAInterestTestCase.class, "verifyInterestUNRegistration"); + getBackupVM().invoke(() -> HAInterestTestCase.verifyInterestUNRegistration()); } /** @@ -65,18 +65,18 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { public void testSecondaryFailureInUNRegisterInterest() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); registerK1AndK2(); VM stoppedBackup = stopSecondaryAndUNregisterK1(); verifyDeadAndLiveServers(1, 2); // still primary - getPrimaryVM().invoke(HAInterestTestCase.class, "verifyDispatcherIsAlive"); + getPrimaryVM().invoke(() -> HAInterestTestCase.verifyDispatcherIsAlive()); // primary - getPrimaryVM().invoke(HAInterestTestCase.class, "verifyInterestUNRegistration"); + getPrimaryVM().invoke(() -> HAInterestTestCase.verifyInterestUNRegistration()); // secondary - getBackupVM(stoppedBackup).invoke(HAInterestTestCase.class, "verifyInterestUNRegistration"); + getBackupVM(stoppedBackup).invoke(() -> HAInterestTestCase.verifyInterestUNRegistration()); } /** @@ -87,11 +87,11 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { public void testDSMDetectsServerLiveJustBeforeInterestRegistration() throws Exception { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); VM backup = getBackupVM(); - backup.invoke(HAInterestTestCase.class, "stopServer"); + backup.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(1, 2); setClientServerObserverForBeforeRegistration(backup); try { @@ -100,9 +100,9 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { } finally { unSetClientServerObserverForRegistrationCallback(); } - server1.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server2.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server3.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server1.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server2.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server3.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -114,12 +114,12 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); createEntriesK1andK2(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); VM backup = getBackupVM(); - backup.invoke(HAInterestTestCase.class, "stopServer"); + backup.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(1, 2); setClientServerObserverForAfterRegistration(backup); @@ -130,9 +130,9 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { unSetClientServerObserverForRegistrationCallback(); } - server1.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server2.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); - server3.invoke(HAInterestTestCase.class, "verifyInterestRegistration"); + server1.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server2.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); + server3.invoke(() -> HAInterestTestCase.verifyInterestRegistration()); } /** @@ -145,16 +145,16 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { public void testRefreshEntriesFromPrimaryWhenDSMDetectsServerLive() throws Exception { IgnoredException.addIgnoredException(ServerConnectivityException.class.getName()); - PORT1 = ((Integer) server1.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + PORT1 = ((Integer) server1.invoke(() -> HAInterestTestCase.createServerCache())).intValue(); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); createClientPoolCacheConnectionToSingleServer(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); registerK1AndK2(); verifyRefreshedEntriesFromServer(); - server1.invoke(HAInterestTestCase.class, "stopServer"); + server1.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(1, 0); - server1.invoke(HAInterestTestCase.class, "putK1andK2"); - server1.invoke(HAInterestTestCase.class, "startServer"); + server1.invoke(() -> HAInterestTestCase.putK1andK2()); + server1.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(0, 1); final Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(r1); @@ -213,29 +213,29 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { * refreshes registered entries from the server, because it is secondary */ public void testGIIFromSecondaryWhenDSMDetectsServerLive() throws Exception { - server1.invoke(HAInterestTestCase.class, "closeCache"); - server2.invoke(HAInterestTestCase.class, "closeCache"); - server3.invoke(HAInterestTestCase.class, "closeCache"); + server1.invoke(() -> HAInterestTestCase.closeCache()); + server2.invoke(() -> HAInterestTestCase.closeCache()); + server3.invoke(() -> HAInterestTestCase.closeCache()); - PORT1 = ((Integer) server1.invoke(HAInterestTestCase.class, "createServerCacheWithLocalRegion")).intValue(); - PORT2 = ((Integer) server2.invoke(HAInterestTestCase.class, "createServerCacheWithLocalRegion")).intValue(); - PORT3 = ((Integer) server3.invoke(HAInterestTestCase.class, "createServerCacheWithLocalRegion")).intValue(); + PORT1 = ((Integer) server1.invoke(() -> HAInterestTestCase.createServerCacheWithLocalRegion())).intValue(); + PORT2 = ((Integer) server2.invoke(() -> HAInterestTestCase.createServerCacheWithLocalRegion())).intValue(); + PORT3 = ((Integer) server3.invoke(() -> HAInterestTestCase.createServerCacheWithLocalRegion())).intValue(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - server3.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + server3.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); createClientPoolCache(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); VM backup1 = getBackupVM(); VM backup2 = getBackupVM(backup1); - backup1.invoke(HAInterestTestCase.class, "stopServer"); - backup2.invoke(HAInterestTestCase.class, "stopServer"); + backup1.invoke(() -> HAInterestTestCase.stopServer()); + backup2.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(2, 1); registerK1AndK2(); verifyRefreshedEntriesFromServer(); - backup1.invoke(HAInterestTestCase.class, "putK1andK2"); - backup1.invoke(HAInterestTestCase.class, "startServer"); + backup1.invoke(() -> HAInterestTestCase.putK1andK2()); + backup1.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(1, 2); verifyRefreshedEntriesFromServer(); } @@ -248,19 +248,19 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { * @throws Exception */ public void testBug35945() throws Exception { - PORT1 = ((Integer) server1.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + PORT1 = ((Integer) server1.invoke(() -> HAInterestTestCase.createServerCache())).intValue(); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); createClientPoolCacheConnectionToSingleServer(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); registerK1AndK2(); verifyRefreshedEntriesFromServer(); - server1.invoke(HAInterestTestCase.class, "stopServer"); + server1.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(1, 0); // put on stopped server - server1.invoke(HAInterestTestCase.class, "putK1andK2"); + server1.invoke(() -> HAInterestTestCase.putK1andK2()); // spawn a thread to put on server , which will acquire a lock on entry setClientServerObserverForBeforeInterestRecovery(); - server1.invoke(HAInterestTestCase.class, "startServer"); + server1.invoke(() -> HAInterestTestCase.startServer()); verifyDeadAndLiveServers(0, 1); waitForBeforeInterestRecoveryCallBack(); // verify updated value of k1 as a refreshEntriesFromServer @@ -316,23 +316,23 @@ public class HAInterestPart2DUnitTest extends HAInterestTestCase { public void testInterestRecoveryFailure() throws Exception { IgnoredException.addIgnoredException("Server unreachable"); - PORT1 = ((Integer) server1.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); - server1.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); - PORT2 = ((Integer) server2.invoke(HAInterestTestCase.class, "createServerCache")).intValue(); - server2.invoke(HAInterestTestCase.class, "createEntriesK1andK2"); + PORT1 = ((Integer) server1.invoke(() -> HAInterestTestCase.createServerCache())).intValue(); + server1.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); + PORT2 = ((Integer) server2.invoke(() -> HAInterestTestCase.createServerCache())).intValue(); + server2.invoke(() -> HAInterestTestCase.createEntriesK1andK2()); createClientPoolCacheWithSmallRetryInterval(this.getName(), NetworkUtils.getServerHostName(server1.getHost())); registerK1AndK2(); verifyRefreshedEntriesFromServer(); VM backup = getBackupVM(); VM primary = getPrimaryVM(); - backup.invoke(HAInterestTestCase.class, "stopServer"); - primary.invoke(HAInterestTestCase.class, "stopServer"); + backup.invoke(() -> HAInterestTestCase.stopServer()); + primary.invoke(() -> HAInterestTestCase.stopServer()); verifyDeadAndLiveServers(2, 0); - primary.invoke(HAInterestTestCase.class, "putK1andK2"); + primary.invoke(() -> HAInterestTestCase.putK1andK2()); setClientServerObserverForBeforeInterestRecoveryFailure(); - primary.invoke(HAInterestTestCase.class, "startServer"); + primary.invoke(() -> HAInterestTestCase.startServer()); waitForBeforeInterestRecoveryCallBack(); if (exceptionOccured) { fail("The DSM could not ensure that server 1 is started & serevr 2 is stopped");