geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [2/3] incubator-geode git commit: GEODE-1146: Test cleanup, converting many VM invoke statements to lambda expressions
Date Thu, 21 Apr 2016 18:49:56 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e1656b0/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
index 223e4b4..ce08b52 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache/query/dunit/QueryUsingPoolDUnitTest.java
@@ -16,25 +16,13 @@
  */
 package com.gemstone.gemfire.cache.query.dunit;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
 import cacheRunner.Portfolio;
 import cacheRunner.Position;
 import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.DataSerializable;
 import com.gemstone.gemfire.DataSerializer;
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheException;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.*;
 import com.gemstone.gemfire.cache.client.PoolFactory;
 import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.query.*;
@@ -43,12 +31,9 @@ import com.gemstone.gemfire.cache.query.internal.QueryObserverAdapter;
 import com.gemstone.gemfire.cache.query.internal.QueryObserverHolder;
 import com.gemstone.gemfire.cache.query.types.ObjectType;
 import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
 import com.gemstone.gemfire.cache30.CacheTestCase;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheClientNotifier;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
@@ -68,15 +53,17 @@ import com.gemstone.gemfire.test.junit.categories.FlakyTest;
  */
 public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
-  /** The port on which the bridge server was started in this VM */
+  /**
+   * The port on which the bridge server was started in this VM
+   */
   private static int bridgeServerPort;
-  
+
   final String rootRegionName = "root";
-  
+
   private final String regionName = this.getName();
-  
+
   private final String regName = "/" + rootRegionName + "/" + regionName;
-  
+
   // Used with compiled queries.
   private final String[] queryString = new String[] {
       "SELECT itr.value FROM " + regName + ".entries itr where itr.key = $1", // 0
@@ -108,50 +95,42 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     disconnectAllFromDS();
   }
 
-  public void createPool(VM vm, String poolName, String server, int port, boolean subscriptionEnabled) {
-    createPool(vm, poolName, new String[]{server}, new int[]{port}, subscriptionEnabled);  
+  public void createPool(String poolName, String server, int port, boolean subscriptionEnabled) {
+    createPool(poolName, new String[] { server }, new int[] { port }, subscriptionEnabled);
   }
 
-  public void createPool(VM vm, String poolName, String server, int port) {
-    createPool(vm, poolName, new String[]{server}, new int[]{port}, false);  
+  public void createPool(String poolName, String server, int port) {
+    createPool(poolName, new String[] { server }, new int[] { port }, false);
   }
 
-  public void createPool(VM vm, final String poolName, final String[] servers, final int[] ports,
+  public void createPool(final String poolName, final String[] servers, final int[] ports,
       final boolean subscriptionEnabled) {
-    vm.invoke(new CacheSerializableRunnable("createPool :" + poolName) {
-      public void run2() throws CacheException {
-        // Create Cache.
-        getCache();
-
-        PoolFactory cpf = PoolManager.createFactory();
-        cpf.setSubscriptionEnabled(subscriptionEnabled);
-        for (int i=0; i < servers.length; i++){
-          LogWriterUtils.getLogWriter().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
-          cpf.addServer(servers[i], ports[i]);
-        }
+    // Create Cache.
+    getCache();
+
+    PoolFactory cpf = PoolManager.createFactory();
+    cpf.setSubscriptionEnabled(subscriptionEnabled);
+    for (int i = 0; i < servers.length; i++) {
+      LogWriterUtils.getLogWriter().info("### Adding to Pool. ### Server : " + servers[i] + " Port : " + ports[i]);
+      cpf.addServer(servers[i], ports[i]);
+    }
 
-        cpf.create(poolName);
-      }
-    });   
+    cpf.create(poolName);
   }
 
-  public void validateCompiledQuery(VM vm, final long compiledQueryCount) {
-  vm.invoke(new CacheSerializableRunnable("validate compiled query.") {
-    public void run2() throws CacheException {
-      long count = 0;
-      for (int i=0; i < 100; i++) {
-        count = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        if (count == compiledQueryCount){
-          break;
-        } else {
-          Wait.pause(1 * 100);
-        }
+  public void validateCompiledQuery(final long compiledQueryCount) {
+    long count = 0;
+    for (int i = 0; i < 100; i++) {
+      count = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      if (count == compiledQueryCount) {
+        break;
+      } else {
+        Wait.pause(1 * 100);
       }
-      assertEquals(compiledQueryCount, count);
     }
-  });
- }
-  
+    assertEquals(compiledQueryCount, count);
+  }
+
   /**
    * Tests remote import query execution.
    */
@@ -166,127 +145,116 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        InternalDistributedSystem system = getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, rootRegionName, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, rootRegionName, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("GetCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteImportQueries"; 
-    createPool(vm1, poolName, host0, port);
+    final String poolName = "testRemoteImportQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
 
-        QueryService qService = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName;
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName;
 
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }          
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
 
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'IBM'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(0, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'IBM'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(0, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price > 49";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries/2, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price > 49";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries / 2, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName + " where ticker = 'ibm' and price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct * from " + regionName
+          + " where ticker = 'ibm' and price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
     });
 
-
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -303,124 +271,119 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("GetCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteStructQueries"; 
-    createPool(vm1, poolName, host0, port);
+    final String poolName = "testRemoteStructQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
 
-        QueryService qService = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName;
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName;
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'IBM'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(0, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'IBM'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(0, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price > 49";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries/2, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price > 49";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries / 2, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString =
+          "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
 
-        queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName + " where ticker = 'ibm' and price = 50";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+      queryString = "import com.gemstone.gemfire.admin.QueryUsingPoolDUnitTest.TestObject; select distinct ticker, price from " + regionName
+          + " where ticker = 'ibm' and price = 50";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -432,189 +395,176 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
-//    final int numberOfEntries = 100;
+    //    final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        Portfolio portfolio = null;
-        Position position1 = null;
-        Position position2 = null;
-        Properties portfolioProperties= null;
-        Properties position1Properties = null;
-        Properties position2Properties = null;
-
-        // Create portfolio 1
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(1));
-        portfolioProperties.put("type", "type1");
-        portfolioProperties.put("status", "active");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "SUN");
-        position1Properties.put("qty", new Double(34000.0));
-        position1Properties.put("mktValue", new Double(24.42));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "IBM");
-        position2Properties.put("qty", new Double(8765.0));
-        position2Properties.put("mktValue", new Double(34.29));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(1), portfolio);
-
-        // Create portfolio 2
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(2));
-        portfolioProperties.put("type", "type2");
-        portfolioProperties.put("status", "inactive");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "YHOO");
-        position1Properties.put("qty", new Double(9834.0));
-        position1Properties.put("mktValue", new Double(12.925));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "GOOG");
-        position2Properties.put("qty", new Double(12176.0));
-        position2Properties.put("mktValue", new Double(21.972));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(2), portfolio);
-
-        // Create portfolio 3
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(3));
-        portfolioProperties.put("type", "type3");
-        portfolioProperties.put("status", "active");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "MSFT");
-        position1Properties.put("qty", new Double(98327.0));
-        position1Properties.put("mktValue", new Double(23.32));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "AOL");
-        position2Properties.put("qty", new Double(978.0));
-        position2Properties.put("mktValue", new Double(40.373));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(3), portfolio);
-
-        // Create portfolio 4
-        portfolio = new Portfolio();
-        portfolioProperties = new Properties();
-        portfolioProperties.put("id", new Integer(4));
-        portfolioProperties.put("type", "type1");
-        portfolioProperties.put("status", "inactive");
-
-        position1 = new Position();
-        position1Properties = new Properties();
-        position1Properties.put("secId", "APPL");
-        position1Properties.put("qty", new Double(90.0));
-        position1Properties.put("mktValue", new Double(67.356572));
-        position1.init(position1Properties);
-        portfolioProperties.put("position1", position1);
-
-        position2 = new Position();
-        position2Properties = new Properties();
-        position2Properties.put("secId", "ORCL");
-        position2Properties.put("qty", new Double(376.0));
-        position2Properties.put("mktValue", new Double(101.34));
-        position2.init(position2Properties);
-        portfolioProperties.put("position2", position2);
-
-        portfolio.init(portfolioProperties);
-        region.put(new Integer(4), portfolio);
-      }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      Portfolio portfolio = null;
+      Position position1 = null;
+      Position position2 = null;
+      Properties portfolioProperties = null;
+      Properties position1Properties = null;
+      Properties position2Properties = null;
+
+      // Create portfolio 1
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(1));
+      portfolioProperties.put("type", "type1");
+      portfolioProperties.put("status", "active");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "SUN");
+      position1Properties.put("qty", new Double(34000.0));
+      position1Properties.put("mktValue", new Double(24.42));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "IBM");
+      position2Properties.put("qty", new Double(8765.0));
+      position2Properties.put("mktValue", new Double(34.29));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(1), portfolio);
+
+      // Create portfolio 2
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(2));
+      portfolioProperties.put("type", "type2");
+      portfolioProperties.put("status", "inactive");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "YHOO");
+      position1Properties.put("qty", new Double(9834.0));
+      position1Properties.put("mktValue", new Double(12.925));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "GOOG");
+      position2Properties.put("qty", new Double(12176.0));
+      position2Properties.put("mktValue", new Double(21.972));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(2), portfolio);
+
+      // Create portfolio 3
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(3));
+      portfolioProperties.put("type", "type3");
+      portfolioProperties.put("status", "active");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "MSFT");
+      position1Properties.put("qty", new Double(98327.0));
+      position1Properties.put("mktValue", new Double(23.32));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "AOL");
+      position2Properties.put("qty", new Double(978.0));
+      position2Properties.put("mktValue", new Double(40.373));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(3), portfolio);
+
+      // Create portfolio 4
+      portfolio = new Portfolio();
+      portfolioProperties = new Properties();
+      portfolioProperties.put("id", new Integer(4));
+      portfolioProperties.put("type", "type1");
+      portfolioProperties.put("status", "inactive");
+
+      position1 = new Position();
+      position1Properties = new Properties();
+      position1Properties.put("secId", "APPL");
+      position1Properties.put("qty", new Double(90.0));
+      position1Properties.put("mktValue", new Double(67.356572));
+      position1.init(position1Properties);
+      portfolioProperties.put("position1", position1);
+
+      position2 = new Position();
+      position2Properties = new Properties();
+      position2Properties.put("secId", "ORCL");
+      position2Properties.put("qty", new Double(376.0));
+      position2Properties.put("mktValue", new Double(101.34));
+      position2.init(position2Properties);
+      portfolioProperties.put("position2", position2);
+
+      portfolio.init(portfolioProperties);
+      region.put(new Integer(4), portfolio);
     });
 
     // Create client region
     final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
-    vm1.invoke(new CacheSerializableRunnable("Create region") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("mcast-port", "0");
-        getSystem(config);
-        getCache();
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        ClientServerTestCase.configureConnectionPool(factory, host0, port,-1, true, -1, -1, null);
-        createRegion(name, factory.create());
-      }
+    vm1.invoke("Create region", () -> {
+      Properties config = new Properties();
+      config.setProperty("mcast-port", "0");
+      getSystem(config);
+      getCache();
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      ClientServerTestCase.configureConnectionPool(factory, host0, port, -1, true, -1, -1, null);
+      createRegion(name, factory.create());
     });
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        String queryString = null;
-        SelectResults results = null;
+    vm1.invoke("Execute queries", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      String queryString = null;
+      SelectResults results = null;
 
-        queryString =
+      queryString =
           "IMPORT cacheRunner.Position; " +
-          "SELECT DISTINCT id, status FROM " + region.getFullPath() +
-          "WHERE NOT (SELECT DISTINCT * FROM positions.values posnVal TYPE Position " +
-          "WHERE posnVal.secId='AOL' OR posnVal.secId='SAP').isEmpty";
-        try {
-          results = region.query(queryString);
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        LogWriterUtils.getLogWriter().fine("size: " + results.size());
-        //assertEquals(numberOfEntries, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
+              "SELECT DISTINCT id, status FROM " + region.getFullPath() +
+              "WHERE NOT (SELECT DISTINCT * FROM positions.values posnVal TYPE Position " +
+              "WHERE posnVal.secId='AOL' OR posnVal.secId='SAP').isEmpty";
+      try {
+        results = region.query(queryString);
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      LogWriterUtils.getLogWriter().fine("size: " + results.size());
+      //assertEquals(numberOfEntries, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates() && results.getCollectionType().getElementType().isStructType());
     });
 
-
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -631,30 +581,26 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Properties config = new Properties();
-        config.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
-        getSystem(config);
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.LOCAL);
-        createRegion(name, factory.create());
-        Wait.pause(1000);
-        try {
-          startBridgeServer(0, false);
-        } catch (Exception ex) {
-          Assert.fail("While starting CacheServer", ex);
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Properties config = new Properties();
+      config.setProperty("locators", "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
+      getSystem(config);
+      AttributesFactory factory = new AttributesFactory();
+      factory.setScope(Scope.LOCAL);
+      createRegion(name, factory.create());
+      Wait.pause(1000);
+      try {
+        startBridgeServer(0, false);
+      } catch (Exception ex) {
+        Assert.fail("While starting CacheServer", ex);
       }
     });
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
@@ -665,151 +611,143 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final String regionName = "/" + rootRegionName + "/" + name;
 
     // Create client pool.
-    final String poolName = "testRemoteFullRegionQueries"; 
-    createPool(vm1, poolName, host0, port);
-
+    final String poolName = "testRemoteFullRegionQueries";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        String queryString = null;
-        SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
-        QueryService qService = null;
-
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
+    vm1.invoke("Execute queries", () -> {
+      String queryString = null;
+      SelectResults results = null;
+      Comparator comparator = null;
+      Object[] resultsArray = null;
+      QueryService qService = null;
 
-        // value query
-        queryString = "SELECT DISTINCT itr.value FROM " + regionName + ".entries itr where itr.key = 'key-1'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.asList().get(0) instanceof TestObject);
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
 
-        // key query
-        queryString = "SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1'";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertEquals("key-1", results.asList().get(0));
+      // value query
+      queryString = "SELECT DISTINCT itr.value FROM " + regionName + ".entries itr where itr.key = 'key-1'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.asList().get(0) instanceof TestObject);
 
-        // order by value query
-        queryString = "SELECT DISTINCT * FROM " + regionName + " WHERE id < 101 ORDER BY id";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        // All order-by query results are stored in a ResultsCollectionWrapper
-        // wrapping a list, so the assertion below is not correct even though
-        // it should be.
-        //assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.getCollectionType().isOrdered());
-        comparator = new IdComparator();
-        resultsArray = results.toArray();
-        for (int i=0; i<resultsArray.length; i++) {
-          if (i+1 != resultsArray.length) {
-            // The id of the current element in the result set must be less
-            // than the id of the next one to pass.
-            assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i+1], comparator.compare(resultsArray[i], resultsArray[i+1]) == -1);
-          }
-        }
+      // key query
+      queryString = "SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1'";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertEquals("key-1", results.asList().get(0));
 
-        // order by struct query
-        queryString = "SELECT DISTINCT id, ticker, price FROM " + regionName + " WHERE id < 101 ORDER BY id";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(numberOfEntries, results.size());
-        // All order-by query results are stored in a ResultsCollectionWrapper
-        // wrapping a list, so the assertion below is not correct even though
-        // it should be.
-        //assertTrue(!results.getCollectionType().allowsDuplicates());
-        assertTrue(results.getCollectionType().isOrdered());
-        comparator = new StructIdComparator();
-        resultsArray = results.toArray();
-        for (int i=0; i<resultsArray.length; i++) {
-          if (i+1 != resultsArray.length) {
-            // The id of the current element in the result set must be less
-            // than the id of the next one to pass.
-            assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i+1], comparator.compare(resultsArray[i], resultsArray[i+1]) == -1);
-          }
-        }
+      // order by value query
+      queryString = "SELECT DISTINCT * FROM " + regionName + " WHERE id < 101 ORDER BY id";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      // All order-by query results are stored in a ResultsCollectionWrapper
+      // wrapping a list, so the assertion below is not correct even though
+      // it should be.
+      //assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.getCollectionType().isOrdered());
+      comparator = new IdComparator();
+      resultsArray = results.toArray();
+      for (int i = 0; i < resultsArray.length; i++) {
+        if (i + 1 != resultsArray.length) {
+          // The id of the current element in the result set must be less
+          // than the id of the next one to pass.
+          assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i + 1],
+              comparator.compare(resultsArray[i], resultsArray[i + 1]) == -1);
+        }
+      }
+
+      // order by struct query
+      queryString = "SELECT DISTINCT id, ticker, price FROM " + regionName + " WHERE id < 101 ORDER BY id";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(numberOfEntries, results.size());
+      // All order-by query results are stored in a ResultsCollectionWrapper
+      // wrapping a list, so the assertion below is not correct even though
+      // it should be.
+      //assertTrue(!results.getCollectionType().allowsDuplicates());
+      assertTrue(results.getCollectionType().isOrdered());
+      comparator = new StructIdComparator();
+      resultsArray = results.toArray();
+      for (int i = 0; i < resultsArray.length; i++) {
+        if (i + 1 != resultsArray.length) {
+          // The id of the current element in the result set must be less
+          // than the id of the next one to pass.
+          assertTrue("The id for " + resultsArray[i] + " should be less than the id for " + resultsArray[i + 1],
+              comparator.compare(resultsArray[i], resultsArray[i + 1]) == -1);
+        }
+      }
+
+      // size query
+      queryString = "(SELECT DISTINCT * FROM " + regionName + " WHERE id < 101).size";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
+      }
+      assertEquals(1, results.size());
+      Object result = results.iterator().next();
+      assertTrue(result instanceof Integer);
+      int resultInt = ((Integer) result).intValue();
+      assertEquals(resultInt, 100);
 
-        // size query
-        queryString = "(SELECT DISTINCT * FROM " + regionName + " WHERE id < 101).size";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        Object result = results.iterator().next();
-        assertTrue(result instanceof Integer);
-        int resultInt = ((Integer) result).intValue();
-        assertEquals(resultInt, 100);
-
-        // query with leading/trailing spaces
-        queryString = " SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1' ";
-        try {
-          Query query = qService.newQuery(queryString);
-          results = (SelectResults)query.execute();
-        } catch (Exception e) {
-          Assert.fail("Failed executing " + queryString, e);
-        }
-        assertEquals(1, results.size());
-        assertEquals("key-1", results.asList().get(0));
+      // query with leading/trailing spaces
+      queryString = " SELECT DISTINCT itr.key FROM " + regionName + ".entries itr where itr.key = 'key-1' ";
+      try {
+        Query query = qService.newQuery(queryString);
+        results = (SelectResults) query.execute();
+      } catch (Exception e) {
+        Assert.fail("Failed executing " + queryString, e);
       }
+      assertEquals(1, results.size());
+      assertEquals("key-1", results.asList().get(0));
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server query using parameters (compiled queries).
    */
   public void testClientServerQueriesWithParams() throws CacheException {
-
-    final String name = this.getName();
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final int[] expectedResults = new int[] {
@@ -821,132 +759,106 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         50, // 5
     };
 
-
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create and populate region", () -> {
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
     // Create client region
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
     vm1.invoke(new CacheSerializableRunnable("Execute queries") {
       public void run2() throws CacheException {
         SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
         QueryService qService = null;
 
         try {
           qService = (PoolManager.find(poolName)).getQueryService();
         } catch (Exception e) {
           Assert.fail("Failed to get QueryService.", e);
-        }          
+        }
 
-        for (int i=0; i < queryString.length; i++){
+        for (int i = 0; i < queryString.length; i++) {
           try {
             LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
             Query query = qService.newQuery(queryString[i]);
-            results = (SelectResults)query.execute(params[i]);
+            results = (SelectResults) query.execute(params[i]);
           } catch (Exception e) {
             Assert.fail("Failed executing " + queryString[i], e);
           }
           try {
             assertEquals(expectedResults[i], results.size());
-          }catch(Throwable th) {
-            fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
+          } catch (Throwable th) {
+            fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
           }
-        }        
+        }
       }
     });
 
     final int useMaintainedCompiledQueries = queryString.length;
 
     // Execute the same compiled queries multiple time
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
-        QueryService qService = null;
+    vm1.invoke("Execute queries", () -> {
+      SelectResults results = null;
+      QueryService qService = null;
 
-        try {
-          qService = (PoolManager.find(poolName)).getQueryService();
-        } catch (Exception e) {
-          Assert.fail("Failed to get QueryService.", e);
-        }          
-        for (int x=0; x < useMaintainedCompiledQueries; x++){
-          for (int i=0; i < queryString.length; i++){
-            try {
-              LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
-              Query query = qService.newQuery(queryString[i]);
-              results = (SelectResults)query.execute(params[i]);
-            } catch (Exception e) {
-              Assert.fail("Failed executing " + queryString[i], e);
-            }
-            try {
-              assertEquals(expectedResults[i], results.size());
-            }catch(Throwable th) {
-              fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
-            }
-          }        
+      try {
+        qService = (PoolManager.find(poolName)).getQueryService();
+      } catch (Exception e) {
+        Assert.fail("Failed to get QueryService.", e);
+      }
+      for (int x = 0; x < useMaintainedCompiledQueries; x++) {
+        for (int i = 0; i < queryString.length; i++) {
+          try {
+            LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
+            Query query = qService.newQuery(queryString[i]);
+            results = (SelectResults) query.execute(params[i]);
+          } catch (Exception e) {
+            Assert.fail("Failed executing " + queryString[i], e);
+          }
+          try {
+            assertEquals(expectedResults[i], results.size());
+          } catch (Throwable th) {
+            fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
+          }
         }
       }
     });
 
     // Validate maintained compiled queries.
     // There should be only queryString.length compiled queries registered.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Check to see if maintained compiled queries are used.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
-        int numTimesUsed = (useMaintainedCompiledQueries + 1) * queryString.length;
-        assertEquals(numTimesUsed, compiledQueryUsedCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryUsedCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryUsedCount();
+      int numTimesUsed = (useMaintainedCompiledQueries + 1) * queryString.length;
+      assertEquals(numTimesUsed, compiledQueryUsedCount);
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server query using parameters (compiled queries).
    */
   public void testMulitipleClientServerQueriesWithParams() throws CacheException {
-    final String name = this.getName();
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -955,12 +867,12 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final int[] expectedResults = new int[] {
@@ -972,69 +884,59 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         50, // 5
     };
 
-
     // Start server1
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server", () -> {
+      configAndStartBridgeServer();
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-
     // Start server2
-    vm1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm1.invoke("Create Bridge Server", () -> {
+      configAndStartBridgeServer();
+      Region region = getRootRegion().getSubregion(regionName);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
     // Create client region
-    final int port0 = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
-    final int port1 = vm1.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port0 = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port1 = vm1.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
 
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm2, poolName, new String[]{host0}, new int[]{port0}, true);
-    createPool(vm3, poolName, new String[]{host0}, new int[]{port1}, true);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0 }, new int[] { port0 }, true));
+    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0 }, new int[] { port1 }, true));
 
     // Execute client queries
     SerializableRunnable executeQueries = new CacheSerializableRunnable("Execute queries") {
       public void run2() throws CacheException {
         SelectResults results = null;
-        Comparator comparator = null;
-        Object[] resultsArray = null;
         QueryService qService = null;
 
         try {
           qService = (PoolManager.find(poolName)).getQueryService();
         } catch (Exception e) {
           Assert.fail("Failed to get QueryService.", e);
-        }          
-        for (int j=0; j < queryString.length; j++){
-          for (int i=0; i < queryString.length; i++){
+        }
+        for (int j = 0; j < queryString.length; j++) {
+          for (int i = 0; i < queryString.length; i++) {
             try {
               LogWriterUtils.getLogWriter().info("### Executing Query :" + queryString[i]);
               Query query = qService.newQuery(queryString[i]);
-              results = (SelectResults)query.execute(params[i]);
+              results = (SelectResults) query.execute(params[i]);
             } catch (Exception e) {
               Assert.fail("Failed executing " + queryString[i], e);
             }
             try {
               assertEquals(expectedResults[i], results.size());
-            }catch(Throwable th) {
-              fail("Result mismatch for query= " + queryString[i] + " expected = "+expectedResults[i] + " actual="+results.size());
+            } catch (Throwable th) {
+              fail("Result mismatch for query= " + queryString[i] + " expected = " + expectedResults[i] + " actual=" + results.size());
             }
           }
         }
@@ -1046,68 +948,49 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
 
     // Validate maintained compiled queries.
     // There should be only queryString.length compiled queries registered.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    
-    this.closeClient(vm2);
-    this.closeClient(vm3);
-    
+
+    vm2.invoke("closeClient", () -> closeClient());
+    vm3.invoke("closeClient", () -> closeClient());
+
     // Validate maintained compiled queries.
     // All the queries will be still present in the server.
-    // They will be cleaned up periodically.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    // They will be cleaned up periodically1
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    
-    vm1.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+
+    vm1.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
- 
+
     // recreate clients and execute queries.
-    createPool(vm2, poolName, new String[]{host0, host0}, new int[]{port1, port0}, true);
-    createPool(vm3, poolName, new String[]{host0, host0}, new int[]{port0, port1}, true);
+    vm2.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port1, port0 }, true));
+    vm3.invoke("createPool", () -> createPool(poolName, new String[] { host0,host0 }, new int[] { port0, port1 }, true));
 
     vm2.invoke(executeQueries);
     vm3.invoke(executeQueries);
-    
+
     // Validate maintained compiled queries.
     // All the queries will be still present in the server.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
-    });
-    
-    vm1.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
-    });
-    
-    // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
-    vm1.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
+
+    vm1.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
+    // Stop server
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
+    vm1.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1116,8 +999,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   public void testClientServerCompiledQueryRegisterAndCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -1125,77 +1006,55 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-    createPool(vm2, poolName, host0, port);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);      }
-    });
+    vm1.invoke("executeCompiledQueries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);      }
-    });
-    
+    vm2.invoke("executeCompiledQueries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
-    closeClient(vm1);
+    vm1.invoke("closeClient", () -> closeClient());
 
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1204,7 +1063,6 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
   public void testClientServerCompiledQueryTimeBasedCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
 
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
@@ -1213,119 +1071,90 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
-        QueryService qs = getCache().getQueryService();
-        DefaultQuery query = (DefaultQuery)qs.newQuery("Select * from " + regName);
-        query.setTestCompiledQueryClearTime(2 * 1000); 
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
+      QueryService qs = getCache().getQueryService();
+      DefaultQuery query = (DefaultQuery) qs.newQuery("Select * from " + regName);
+      query.setTestCompiledQueryClearTime(2 * 1000);
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
-    createPool(vm1, poolName, host0, port);
-    createPool(vm2, poolName, host0, port);
+    final String poolName = "testClientServerQueriesWithParams";
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-        
+    vm2.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-        
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
     // The client2 will be using the queries.
-    vm2.invokeAsync(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        for (int i=0; i < 10; i++) {
-          Wait.pause(200);
-          executeCompiledQueries(poolName, params);
-        }
+    vm2.invokeAsync("Execute queries", () -> {
+      for (int i = 0; i < 10; i++) {
+        Wait.pause(200);
+        executeCompiledQueries(poolName, params);
       }
     });
-       
+
     // Validate maintained compiled queries.
-    validateCompiledQuery(vm0, queryString.length);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(queryString.length));
 
     // Let the compiled queries to be idle (not used).
-    Wait.pause(2 * 1000);    
-    
+    Wait.pause(2 * 1000);
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
 
     // Close clients
-    closeClient(vm2);
-    closeClient(vm1);
-    
+
+    vm1.invoke("closeClient", () -> closeClient());
+    vm2.invoke("closeClient", () -> closeClient());
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(0, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(0, compiledQueryCount);
     });
-    
+
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
    * Tests client-server compiled query register and cleanup.
-   * It creates the client connections without the subscription 
+   * It creates the client connections without the subscription
    * enabled. This doesn't create any client proxy on the server.
    */
   public void testClientServerCompiledQueryCleanup() throws CacheException {
 
     final String name = this.getName();
-    final String rootRegionName = "root";
-
     final Host host = Host.getHost(0);
     VM vm0 = host.getVM(0);
     VM vm1 = host.getVM(1);
@@ -1333,124 +1162,89 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
-    
+
     // Start server
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-      }
-    });
+    vm0.invoke("Create Bridge Server", () -> configAndStartBridgeServer());
 
     // Initialize server region
-    vm0.invoke(new CacheSerializableRunnable("Create and populate region.") {
-      public void run2() throws CacheException {
-        Region region = getRootRegion().getSubregion(name);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
-        QueryService qs = getCache().getQueryService();
-        DefaultQuery query = (DefaultQuery)qs.newQuery("Select * from " + regName);
-        query.setTestCompiledQueryClearTime(2 * 1000); 
+    vm0.invoke("Create and populate region.", () -> {
+      Region region = getRootRegion().getSubregion(name);
+      for (int i = 0; i < numberOfEntries; i++) {
+        region.put("key-" + i, new TestObject(i, "ibm"));
       }
+      QueryService qs = getCache().getQueryService();
+      DefaultQuery query = (DefaultQuery) qs.newQuery("Select * from " + regName);
+      query.setTestCompiledQueryClearTime(2 * 1000);
     });
 
-    final int port = vm0.invoke(() -> QueryUsingPoolDUnitTest.getCacheServerPort());
+    final int port = vm0.invoke("getCacheServerPort", () -> QueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(vm0.getHost());
 
-    final String regionName = "/" + this.rootRegionName + "/" + this.regionName;
-
     // Create client pool.
-    final String poolName = "testClientServerQueriesWithParams"; 
+    final String poolName = "testClientServerQueriesWithParams";
     final boolean subscriptiuonEnabled = false;
-    createPool(vm1, poolName, host0, port, subscriptiuonEnabled);
-    createPool(vm2, poolName, host0, port, subscriptiuonEnabled);
+    vm1.invoke("createPool", () -> createPool(poolName, host0, port, subscriptiuonEnabled));
+    vm2.invoke("createPool", () -> createPool(poolName, host0, port, subscriptiuonEnabled));
 
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
-    vm2.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-    
+    vm2.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-    
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
 
     // Execute client queries
     // The client2 will be using the queries.
-    vm2.invokeAsync(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        for (int i=0; i < 10; i++) {
-          Wait.pause(10);
-          executeCompiledQueries(poolName, params);
-        }
+    vm2.invokeAsync("Execute queries", () -> {
+      for (int i = 0; i < 10; i++) {
+        Wait.pause(10);
+        executeCompiledQueries(poolName, params);
       }
     });
-       
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, queryString.length);
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(queryString.length));
 
     // Close clients
     // Let the compiled queries to be idle (not used).
     //pause(2 * 1000);    
-    
+
     // Validate maintained compiled queries.
-    this.validateCompiledQuery(vm0, 0);
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Recreate compiled queries.
     // Execute client queries
-    vm1.invoke(new CacheSerializableRunnable("Execute queries") {
-      public void run2() throws CacheException {
-        executeCompiledQueries(poolName, params);
-      }
-    });
-    
-    
+    vm1.invoke("Execute queries", () -> executeCompiledQueries(poolName, params));
+
     // Validate maintained compiled queries.
-    vm0.invoke(new CacheSerializableRunnable("validate compiled query.") {
-      public void run2() throws CacheException {
-        long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
-        assertEquals(queryString.length, compiledQueryCount);
-      }
+    vm0.invoke("validate compiled query.", () -> {
+      long compiledQueryCount = CacheClientNotifier.getInstance().getStats().getCompiledQueryCount();
+      assertEquals(queryString.length, compiledQueryCount);
     });
 
     // Close clients
-    closeClient(vm2);
-    closeClient(vm1);
+    vm2.invoke("closeClient", () -> closeClient());
+    vm1.invoke("closeClient", () -> closeClient());
 
     // Validate maintained compiled queries.
     // since not used it should get cleaned up after sometime.
-    this.validateCompiledQuery(vm0, 0);
-    
-    
+    vm0.invoke("validate Compiled query", () -> validateCompiledQuery(0));
+
     // Stop server
-    vm0.invoke(new SerializableRunnable("Stop CacheServer") {
-      public void run() {
-        stopBridgeServer(getCache());
-      }
-    });    
+    vm0.invoke("Stop CacheServer", () -> stopBridgeServer(getCache()));
   }
 
   /**
@@ -1469,12 +1263,12 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
     final int numberOfEntries = 100;
 
     final Object[][] params = new Object[][] {
-        {"key-1"}, // 0
-        {101}, // 1
-        {101}, // 2
-        {101}, // 3
-        {50, "ibm"}, // 4
-        {50, "ibm"}, // 5
+        { "key-1" }, // 0
+        { 101 }, // 1
+        { 101 }, // 2
+        { 101 }, // 3
+        { 50, "ibm" }, // 4
+        { 50, "ibm" }, // 5
     };
 
     final String[] querys = new String[] {
@@ -1486,67 +1280,54 @@ public class QueryUsingPoolDUnitTest extends CacheTestCase {
         "SELECT * FROM " + regName + " WHERE id < 50 and Ticker = 'ibm'", // 5
     };
 
-    final int[] expectedResults = new int[] {
-        1, // 0
-        100, // 1
-        100, // 2
-        1, // 3
-        1, // 4
-        50, // 5
-    };
-
     // Start server1
-    vm0.invoke(new CacheSerializableRunnable("Create Bridge Server") {
-      public void run2() throws CacheException {
-        configAndStartBridgeServer();
-        Region region = getRootRegion().getSubregion(regionName);
-        for (int i=0; i<numberOfEntries; i++) {
-          region.put("key-"+i, new TestObject(i, "ibm"));
-        }
+    vm0.invoke("Create Bridge Server

<TRUNCATED>


Mime
View raw message