You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/09 17:05:23 UTC

[06/51] [partial] incubator-geode git commit: GEODE-837: update tests from JUnit3 to JUnit4

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java
index 22c39d3..d0fb8cb 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 import java.util.HashSet;
 import java.util.concurrent.CountDownLatch;
 
@@ -55,12 +64,13 @@ import com.gemstone.gemfire.test.dunit.Wait;
  * This includes the test with different data activities.
  *
  */
-public class CqDataDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class CqDataDUnitTest extends JUnit4CacheTestCase {
 
-  protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest("CqDataDUnitTest");
+  protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest();
   
-  public CqDataDUnitTest(String name) {
-    super(name);
+  public CqDataDUnitTest() {
+    super();
   }
 
   @Override
@@ -87,6 +97,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * 
    * @throws Exception
    */
+  @Test
   public void testClientWithFeederAndCQ() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -129,6 +140,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ Fail over/HA with redundancy level set.
    * @throws Exception
    */
+  @Test
   public void testCQHAWithState() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -250,6 +262,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * 
    * @throws Exception
    */
+  @Test
   public void testCQWithDestroysAndInvalidates() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -321,6 +334,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * bug 37295.
    * 
    */
+  @Test
   public void testCQWithMultipleClients() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -390,6 +404,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ when region is populated with net load.
    * @throws Exception
    */
+  @Test
   public void testCQWithLoad() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -441,6 +456,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ when entries are evicted from region.
    * @throws Exception
    */
+  @Test
   public void testCQWithEviction() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -511,6 +527,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ with ConnectionPool.
    * @throws Exception
    */
+  @Test
   public void testCQWithConnectionPool() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -569,6 +586,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ with BridgeClient.
    * @throws Exception
    */
+  @Test
   public void testCQWithBridgeClient() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -624,6 +642,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ with ConnectionPool.
    * @throws Exception
    */
+  @Test
   public void testCQWithPool() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -678,6 +697,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Test for CQ with establishCallBackConnection.
    * @throws Exception
    */
+  @Test
   public void testCQWithEstablishCallBackConnection() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -743,6 +763,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * Region invalidate triggers cqEvent with query op region invalidate.
    * @throws Exception
    */
+  @Test
   public void testRegionEvents() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -824,6 +845,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * thus making the query data and region data inconsistent.
    * @throws Exception
    */
+  @Test
   public void testEventsDuringQueryExecution() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -959,6 +981,7 @@ public class CqDataDUnitTest extends CacheTestCase {
    * 
    * @throws Exception
    */
+  @Test
   public void testMultipleExecuteWithInitialResults() throws Exception {
     final int numObjects = 200;
     final int totalObjects = 500;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataOptimizedExecuteDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataOptimizedExecuteDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataOptimizedExecuteDUnitTest.java
index 89e1554..4bf36f4 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataOptimizedExecuteDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataOptimizedExecuteDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 
 import com.gemstone.gemfire.cache.query.internal.cq.CqServiceImpl;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
@@ -26,10 +35,11 @@ import com.gemstone.gemfire.test.dunit.SerializableRunnable;
  * Test class for testing {@link CqServiceImpl#EXECUTE_QUERY_DURING_INIT} flag
  *
  */
+@Category(DistributedTest.class)
 public class CqDataOptimizedExecuteDUnitTest extends CqDataDUnitTest {
 
-  public CqDataOptimizedExecuteDUnitTest(String name) {
-    super(name);
+  public CqDataOptimizedExecuteDUnitTest() {
+    super();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java
index b94c7e4..53d473e 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java
@@ -16,45 +16,71 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
-import com.gemstone.gemfire.cache.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.MirrorType;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Scope;
 import com.gemstone.gemfire.cache.client.Pool;
 import com.gemstone.gemfire.cache.client.PoolFactory;
 import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.query.*;
+import com.gemstone.gemfire.cache.query.CqAttributes;
+import com.gemstone.gemfire.cache.query.CqAttributesFactory;
+import com.gemstone.gemfire.cache.query.CqEvent;
+import com.gemstone.gemfire.cache.query.CqException;
+import com.gemstone.gemfire.cache.query.CqExistsException;
+import com.gemstone.gemfire.cache.query.CqListener;
+import com.gemstone.gemfire.cache.query.CqQuery;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.RegionNotFoundException;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.Struct;
 import com.gemstone.gemfire.cache.query.data.Portfolio;
 import com.gemstone.gemfire.cache.query.internal.cq.CqQueryImpl;
 import com.gemstone.gemfire.cache.query.internal.cq.CqQueryImpl.TestHook;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.cache30.CertifiableTestCacheListener;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.PoolFactoryImpl;
 import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerTestUtil;
-import com.gemstone.gemfire.test.dunit.*;
-import util.TestException;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.AsyncInvocation;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
- * This class tests the ContiunousQuery mechanism in GemFire.
+ * This class tests the ContinuousQuery mechanism in GemFire.
  * This includes the test with different data activities.
- *
  */
-public class CqDataUsingPoolDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class CqDataUsingPoolDUnitTest extends JUnit4CacheTestCase {
 
-  protected CqQueryUsingPoolDUnitTest cqDUnitTest = new CqQueryUsingPoolDUnitTest("CqDataUsingPoolDUnitTest");
-  
-  public CqDataUsingPoolDUnitTest(String name) {
-    super(name);
-  }
+  protected CqQueryUsingPoolDUnitTest cqDUnitTest = new CqQueryUsingPoolDUnitTest(); // TODO: don't do this!
 
   @Override
   public final void postSetUp() throws Exception {
@@ -62,6 +88,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     // system before creating ConnectionPools
     getSystem();
     Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
+      @Override
       public void run() {
         getSystem();
       }
@@ -77,9 +104,8 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
    * Added wrt bug 37161.
    * In case of InterestList the events are not sent back to the client
    * if its the originator, this is not true for cq.
-   * 
-   * @throws Exception
    */
+  @Test
   public void testClientWithFeederAndCQ() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -93,7 +119,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     String poolName = "testClientWithFeederAndCQ";
     cqDUnitTest.createPool(client, poolName, host0, port);
-    
+
     // Create client.
     cqDUnitTest.createClient(client, port, host0);
 
@@ -114,40 +140,38 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         /* queryUpdates: */ 0,
         /* queryDeletes: */ 0,
         /* totalEvents: */ size);
-    
+
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server);
-    
   }
 
   /**
    * Test for CQ Fail over/HA with redundancy level set.
-   * @throws Exception
    */
+  @Test
   public void testCQHAWithState() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
     VM server2 = host.getVM(1);
     VM server3 = host.getVM(2);
-    
+
     VM client = host.getVM(3);
-    
+
     cqDUnitTest.createServer(server1);
-    
+
     final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server1.getHost());
-    
+
     final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    
+
     cqDUnitTest.createServer(server2, ports[0]);
     final int port2 = server2.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
-            
+
     // Create client - With 3 server endpoints and redundancy level set to 2.
-    
+
     // Create client with redundancyLevel 1
-    //cqDUnitTest.createClient(client, new int[] {port1, port2, ports[1]}, host0, "1");
-    
+
     String poolName = "testCQHAWithState";
     cqDUnitTest.createPool(client, poolName, new String[] {host0, host0, host0}, new int[] {port1, port2, ports[1]}, "1");
 
@@ -158,94 +182,91 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
       cqDUnitTest.createCQ(client, poolName, "testCQHAWithState_" + i, cqDUnitTest.cqs[i]);
       cqDUnitTest.executeCQ(client, "testCQHAWithState_" + i, false, null);
     }
-    
+
     Wait.pause(1 * 1000);
-    
+
     int size = 10;
-    
+
     // CREATE.
     cqDUnitTest.createValues(server1, cqDUnitTest.regions[0], size);
     cqDUnitTest.createValues(server1, cqDUnitTest.regions[1], size);
-    
+
     for (int i=1; i <= size; i++) {
       cqDUnitTest.waitForCreated(client, "testCQHAWithState_0", CqQueryUsingPoolDUnitTest.KEY + i);
     }
-    
+
     // Clients expected initial result.
     int[] resultsCnt = new int[] {10, 1, 2};
 
     for (int i=0; i < numCQs; i++) {
       cqDUnitTest.validateCQ(client, "testCQHAWithState_" + i, CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], 0, 0);
-    }    
+    }
 
     // Close server1.
     // To maintain the redundancy; it will make connection to endpoint-3.
     cqDUnitTest.closeServer(server1);
     Wait.pause(3 * 1000);
-    
-    
+
+
     // UPDATE-1.
     cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], 10);
     cqDUnitTest.createValues(server2, cqDUnitTest.regions[1], 10);
-    
+
     for (int i=1; i <= size; i++) {
       cqDUnitTest.waitForUpdated(client, "testCQHAWithState_0", CqQueryUsingPoolDUnitTest.KEY + size);
     }
-    
+
     for (int i=0; i < numCQs; i++) {
       cqDUnitTest.validateCQ(client, "testCQHAWithState_" + i, CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i], CqQueryUsingPoolDUnitTest.noTest);
-    }    
+    }
 
     //Stop cq.
     cqDUnitTest.stopCQ(client, "testCQHAWithState_0");
-    
+
     Wait.pause(2 * 1000);
-    
+
     // UPDATE with stop.
     cqDUnitTest.createServer(server3, ports[1]);
     server3.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     Wait.pause(2 * 1000);
-    
+
     cqDUnitTest.clearCQListenerEvents(client, "testCQHAWithState_0");
-    
-    cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], 10);    
+
+    cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], 10);
     cqDUnitTest.createValues(server2, cqDUnitTest.regions[1], 10);
-    
+
     // Wait for events at client.
     try {
       cqDUnitTest.waitForUpdated(client, "testCQHAWithState_0", CqQueryUsingPoolDUnitTest.KEY + 1);
       fail("Events not expected since CQ is in stop state.");
-    } catch (Exception ex) {
+    } catch (Exception expected) {
       // Success.
     }
-    
+
     cqDUnitTest.executeCQ(client, "testCQHAWithState_0", false, null);
 
-    // Update - 2 
-    cqDUnitTest.createValues(server3, cqDUnitTest.regions[0], 10);    
+    // Update - 2
+    cqDUnitTest.createValues(server3, cqDUnitTest.regions[0], 10);
     cqDUnitTest.createValues(server3, cqDUnitTest.regions[1], 10);
-    
+
     for (int i=1; i <= size; i++) {
       cqDUnitTest.waitForUpdated(client, "testCQHAWithState_0", CqQueryUsingPoolDUnitTest.KEY + size);
     }
 
     for (int i=0; i < numCQs; i++) {
       cqDUnitTest.validateCQ(client, "testCQHAWithState_" + i, CqQueryUsingPoolDUnitTest.noTest, resultsCnt[i], resultsCnt[i] * 2, CqQueryUsingPoolDUnitTest.noTest);
-    }    
-    
+    }
+
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server2);
     cqDUnitTest.closeServer(server3);
   }
 
-  
-  
   /**
    * Tests propogation of invalidates and destorys to the clients. Bug 37242.
-   * 
-   * @throws Exception
    */
+  @Test
   public void testCQWithDestroysAndInvalidates() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -261,7 +282,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     // Create client.
     //cqDUnitTest.createClient(client, port, host0);
-    
+
     // producer is not doing any thing.
     cqDUnitTest.createClient(producer, port, host0);
 
@@ -271,9 +292,10 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     cqDUnitTest.createCQ(client, poolName, name, cqDUnitTest.cqs[4]);
     cqDUnitTest.executeCQ(client, name, true, null);
-    
+
     // do destroys and invalidates.
     server.invoke(new CacheSerializableRunnable("Create values") {
+      @Override
       public void run2() throws CacheException
       {
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
@@ -291,11 +313,12 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     for (int i = 1; i <= 5; i++) {
       cqDUnitTest.waitForCreated(client, name , CqQueryUsingPoolDUnitTest.KEY+i);
     }
-    
+
     // do more puts to push first five key-value to disk.
     cqDUnitTest.createValues(server, cqDUnitTest.regions[0], 10);
     // do invalidates on fisrt five keys.
     server.invoke(new CacheSerializableRunnable("Create values") {
+      @Override
       public void run2() throws CacheException
       {
         Region region1 = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
@@ -308,27 +331,25 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     for (int i = 1; i <= 5; i++) {
       cqDUnitTest.waitForInvalidated(client, name , CqQueryUsingPoolDUnitTest.KEY+i);
     }
-        
+
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server);
-  
   }
-  
+
   /**
    * Tests make sure that the second client doesnt get more
-   * events then there should be. This will test the fix for 
+   * events then there should be. This will test the fix for
    * bug 37295.
-   * 
    */
+  @Test
   public void testCQWithMultipleClients() throws Exception {
-    
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
     VM client1 = host.getVM(1);
     VM client2 = host.getVM(2);
     VM client3 = host.getVM(3);
-    
+
     /* Create Server and Client */
     cqDUnitTest.createServer(server);
     final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
@@ -339,28 +360,23 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     cqDUnitTest.createPool(client1, poolName1, host0, port);
     cqDUnitTest.createPool(client2, poolName2, host0, port);
-    
-    //cqDUnitTest.createClient(client1, port, host0);
-    //cqDUnitTest.createClient(client2, port, host0);
-    
+
     /* Create CQs. and initialize the region */
-    // this should statisfy every thing since id is always greater than 
+    // this should stasify every thing since id is always greater than
     // zero.
     cqDUnitTest.createCQ(client1, poolName1, "testCQWithMultipleClients_0", cqDUnitTest.cqs[0]);
     cqDUnitTest.executeCQ(client1, "testCQWithMultipleClients_0", false, null);
     // should only satisfy one key-value pair in the region.
     cqDUnitTest.createCQ(client2, poolName2, "testCQWithMultipleClients_0", cqDUnitTest.cqs[1]);
     cqDUnitTest.executeCQ(client2, "testCQWithMultipleClients_0", false, null);
-    
+
     int size = 10;
-    
+
     // Create Values on Server.
     cqDUnitTest.createValues(server, cqDUnitTest.regions[0], size);
-    
-    
+
     cqDUnitTest.waitForCreated(client1, "testCQWithMultipleClients_0", CqQueryUsingPoolDUnitTest.KEY + 10);
-    
-    
+
     /* Validate the CQs */
     cqDUnitTest.validateCQ(client1, "testCQWithMultipleClients_0",
         /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest,
@@ -371,11 +387,9 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         /* queryUpdates: */ 0,
         /* queryDeletes: */ 0,
         /* totalEvents: */ size);
-    
-    
+
     cqDUnitTest.waitForCreated(client2, "testCQWithMultipleClients_0", CqQueryUsingPoolDUnitTest.KEY + 2 );
-    
-    
+
     cqDUnitTest.validateCQ(client2, "testCQWithMultipleClients_0",
         /* resultSize: */ CqQueryUsingPoolDUnitTest.noTest,
         /* creates: */ 1,
@@ -385,8 +399,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         /* queryUpdates: */ 0,
         /* queryDeletes: */ 0,
         /* totalEvents: */ 1);
-         
-        
+
     /* Close Server and Client */
     cqDUnitTest.closeClient(client2);
     cqDUnitTest.closeClient(client3);
@@ -395,38 +408,39 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
   /**
    * Test for CQ when region is populated with net load.
-   * @throws Exception
    */
+  @Test
   public void testCQWithLoad() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
     VM server2 = host.getVM(1);
-    
+
     VM client = host.getVM(2);
-    
+
     cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES);
     cqDUnitTest.createServer(server2, 0, false, MirrorType.KEYS);
-        
+
     final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server1.getHost());
-    
+
     String poolName = "testCQWithLoad";
     cqDUnitTest.createPool(client, poolName, host0, port1);
 
     //cqDUnitTest.createClient(client, port1, host0);
-    
+
     // Create CQs.
-    cqDUnitTest.createCQ(client, poolName, "testCQWithLoad_0", cqDUnitTest.cqs[0]);  
-    cqDUnitTest.executeCQ(client, "testCQWithLoad_0", false, null); 
-    
+    cqDUnitTest.createCQ(client, poolName, "testCQWithLoad_0", cqDUnitTest.cqs[0]);
+    cqDUnitTest.executeCQ(client, "testCQWithLoad_0", false, null);
+
     Wait.pause(1 * 1000);
-    
+
     final int size = 10;
-    
+
     // CREATE VALUES.
     cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], size);
-    
+
     server1.invoke(new CacheSerializableRunnable("Load from second server") {
+      @Override
       public void run2() throws CacheException {
         Region region1 = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
         for (int i=1; i <= size; i++){
@@ -434,13 +448,13 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
+
     for (int i=1; i <= size; i++) {
       cqDUnitTest.waitForCreated(client, "testCQWithLoad_0", CqQueryUsingPoolDUnitTest.KEY + i);
     }
-        
+
     cqDUnitTest.validateCQ(client, "testCQWithLoad_0", CqQueryUsingPoolDUnitTest.noTest, size, 0, 0);
-        
+
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server1);
@@ -449,19 +463,18 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
   /**
    * Test for CQ when entries are evicted from region.
-   * @throws Exception
    */
+  @Test
   public void testCQWithEviction() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
     VM server2 = host.getVM(1);
-    
+
     VM client = host.getVM(2);
-    
-    //cqDUnitTest.createServer(server1, 0, false, MirrorType.NONE);
 
     final int evictionThreshold = 5;
     server1.invoke(new CacheSerializableRunnable("Create Cache Server") {
+      @Override
       public void run2() throws CacheException {
         LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
         AttributesFactory factory = new AttributesFactory();
@@ -470,53 +483,53 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
         // setting the eviction attributes.
         factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(evictionThreshold));
-        for (int i = 0; i < cqDUnitTest.regions.length; i++) { 
+        for (int i = 0; i < cqDUnitTest.regions.length; i++) {
           Region region = createRegion(cqDUnitTest.regions[i], factory.createRegionAttributes());
           // Set CacheListener.
-          region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter()));  
-        } 
+          region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter()));
+        }
         Wait.pause(2000);
-        
+
         try {
           cqDUnitTest.startBridgeServer(0, true);
         } catch (Exception ex) {
           Assert.fail("While starting CacheServer", ex);
         }
         Wait.pause(2000);
-
       }
     });
 
     cqDUnitTest.createServer(server2, 0, false, MirrorType.NONE);
-        
+
     final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server1.getHost());
-      
+
     String poolName = "testCQWithEviction";
     cqDUnitTest.createPool(client, poolName, host0, port1);
 
     //cqDUnitTest.createClient(client, port1, host0);
-    
+
     // Create CQs.
-    cqDUnitTest.createCQ(client, poolName, "testCQWithEviction_0", cqDUnitTest.cqs[0]);  
+    cqDUnitTest.createCQ(client, poolName, "testCQWithEviction_0", cqDUnitTest.cqs[0]);
 
     // This should fail as Region is not replicated.
     // There is a bug37966 filed on this.
     try {
-      cqDUnitTest.executeCQ(client, "testCQWithEviction_0", false, "CqException"); 
+      cqDUnitTest.executeCQ(client, "testCQWithEviction_0", false, "CqException");
       fail("Should have thrown exception, cq not supported on Non-replicated region.");
-    } catch (Exception ex) {
+    } catch (Exception expected) {
       // Ignore  expected.
     }
-    
+
     Wait.pause(1 * 1000);
-    
+
     final int size = 10;
-    
+
     // CREATE VALUES.
     cqDUnitTest.createValues(server2, cqDUnitTest.regions[0], size);
-    
+
     server1.invoke(new CacheSerializableRunnable("Load from second server") {
+      @Override
       public void run2() throws CacheException {
         Region region1 = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
         for (int i=1; i <= size; i++){
@@ -524,23 +537,20 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
-    //for (int i=1; i <= size; i++) {
-    //  cqDUnitTest.waitForCreated(client, "testCQWithEviction_0", cqDUnitTest.KEY + i);
-    //}
-        
+
     Wait.pause(2 * 1000);
-    
+
     server1.invoke(new CacheSerializableRunnable("validate destroy") {
+      @Override
       public void run2() throws CacheException {
         Region region = getRootRegion().getSubregion(cqDUnitTest.regions[0]);
         assertNotNull(region);
-        
+
         Set keys = region.entrySet();
         int keyCnt= size - evictionThreshold;
-        assertEquals("Mismatch, number of keys in local region is not equal to the expected size", 
+        assertEquals("Mismatch, number of keys in local region is not equal to the expected size",
           keyCnt, keys.size());
-        
+
         CertifiableTestCacheListener ctl = (CertifiableTestCacheListener) region.getAttributes().getCacheListener();
         for (int i = 1; i <= keyCnt; i++) {
           ctl.waitForDestroyed(CqQueryUsingPoolDUnitTest.KEY+i);
@@ -549,20 +559,16 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
       }
     });
 
-    // There should not be any destroy events.
-    //cqDUnitTest.validateCQ(client, "testCQWithEviction_0", cqDUnitTest.noTest, size, 0, 0);
-        
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server1);
     cqDUnitTest.closeServer(server2);
   }
-  
-  
+
   /**
    * Test for CQ with establishCallBackConnection.
-   * @throws Exception
    */
+  @Test
   public void testCQWithEstablishCallBackConnection() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -573,31 +579,29 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
 
-//    final String[] regions = cqDUnitTest.regions;
-//    final int[] serverPorts = new int[] {port1};
-
     final String poolName = "testCQWithEstablishCallBackConnection";
 
     client.invoke(new CacheSerializableRunnable("createPool :" + poolName) {
+      @Override
       public void run2() throws CacheException {
         // Create Cache.
         getCache();
-        
+
         PoolFactory cpf = PoolManager.createFactory();
-        cpf.setSubscriptionEnabled(false);        
+        cpf.setSubscriptionEnabled(false);
         cpf.addServer(serverHost, port1);
         cpf.create(poolName);
       }
-    });   
+    });
 
     // Create CQs.
-    cqDUnitTest.createCQ(client, poolName, "testCQWithEstablishCallBackConnection_0", cqDUnitTest.cqs[0]);  
+    cqDUnitTest.createCQ(client, poolName, "testCQWithEstablishCallBackConnection_0", cqDUnitTest.cqs[0]);
 
     // This should fail.
     try {
       cqDUnitTest.executeCQ(client, "testCQWithEstablishCallBackConnection_0", false, "CqException");
       fail("Test should have failed with connection with establishCallBackConnection not found.");
-    } catch (Exception ex) {
+    } catch (Exception expected) {
       // Expected.
     }
 
@@ -605,39 +609,39 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server1);
   }
-  
+
   /**
    * Test for:
    * Region destroy, calls close on the server.
    * Region clear triggers cqEvent with query op region clear.
    * Region invalidate triggers cqEvent with query op region invalidate.
-   * @throws Exception
    */
+  @Test
   public void testRegionEvents() throws Exception {
-    
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
     VM client = host.getVM(1);
-    
+
     cqDUnitTest.createServer(server);
     final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server.getHost());
-    
+
     String poolName = "testRegionEvents";
     cqDUnitTest.createPool(client, poolName, host0, port);
 
     //cqDUnitTest.createClient(client, port, host0);
-    
+
     // Create CQ on regionA
     cqDUnitTest.createCQ(client, poolName, "testRegionEvents_0", cqDUnitTest.cqs[0]);
     cqDUnitTest.executeCQ(client, "testRegionEvents_0", false, null);
-    
+
     // Create CQ on regionB
     cqDUnitTest.createCQ(client, poolName, "testRegionEvents_1", cqDUnitTest.cqs[2]);
     cqDUnitTest.executeCQ(client, "testRegionEvents_1", false, null);
 
     // Test for Event on Region Clear.
     server.invoke(new CacheSerializableRunnable("testRegionEvents"){
+      @Override
       public void run2()throws CacheException {
         LogWriterUtils.getLogWriter().info("### Clearing the region on the server ###");
         Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
@@ -647,11 +651,12 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         region.clear();
       }
     });
-    
+
     cqDUnitTest.waitForRegionClear(client,"testRegionEvents_0");
 
     // Test for Event on Region invalidate.
     server.invoke(new CacheSerializableRunnable("testRegionEvents"){
+      @Override
       public void run2()throws CacheException {
         LogWriterUtils.getLogWriter().info("### Invalidate the region on the server ###");
         Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
@@ -666,6 +671,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     // Test for Event on Region destroy.
     server.invoke(new CacheSerializableRunnable("testRegionEvents"){
+      @Override
       public void run2()throws CacheException {
         LogWriterUtils.getLogWriter().info("### Destroying the region on the server ###");
         Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[1]);
@@ -681,43 +687,41 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     //cqDUnitTest.waitForClose(client,"testRegionEvents_1");
     cqDUnitTest.validateCQCount(client,1);
 
-        
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server);
-
   }
 
   /**
    * Test for events created during the CQ query execution.
-   * When CQs are executed using executeWithInitialResults 
+   * When CQs are executed using executeWithInitialResults
    * there may be possibility that the region changes during
    * that time may not be reflected in the query result set
    * thus making the query data and region data inconsistent.
-   * @throws Exception
    */
+  @Test
   public void testEventsDuringQueryExecution() throws Exception {
-    
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
     final VM client = host.getVM(1);
     final String cqName = "testEventsDuringQueryExecution_0";
     cqDUnitTest.createServer(server);
-    
+
     final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server.getHost());
- 
+
     String poolName = "testEventsDuringQueryExecution";
     cqDUnitTest.createPool(client, poolName, host0, port);
-    
+
     // create CQ.
     cqDUnitTest.createCQ(client, poolName, cqName, cqDUnitTest.cqs[0]);
 
     final int numObjects = 200;
     final int totalObjects = 500;
-    
+
     // initialize Region.
     server.invoke(new CacheSerializableRunnable("Update Region"){
+      @Override
       public void run2()throws CacheException {
         Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
         for (int i = 1; i <= numObjects; i++) {
@@ -726,13 +730,14 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
+
     // First set testhook in executeWithInitialResults so that queued events
-    // are not drained before we verify there number.    
-    client.invoke(setTestHook());    
-    
+    // are not drained before we verify there number.
+    client.invoke(setTestHook());
+
     // Execute CQ while update is in progress.
     AsyncInvocation executeCq = client.invokeAsync(new CacheSerializableRunnable("Execute CQ AsyncInvoke") {
+      @Override
       public void run2()throws CacheException {
         QueryService cqService = getCache().getQueryService();
         // Get CqQuery object.
@@ -755,26 +760,26 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           public boolean done() {
             return testHook.numQueuedEvents() > 0;
           }
-          
+
           @Override
           public String description() {
             return "No queued events found.";
           }
         }, 3000, 5, true);
-        
+
         getCache().getLogger().fine("Queued Events Size" + testHook.numQueuedEvents());
         // Make sure CQEvents are queued during execute with initial results.
-        
+
         CqQueryTestListener cqListener = (CqQueryTestListener)cq1.getCqAttributes().getCqListener();
         // Wait for the last key to arrive.
         cqListener.waitForCreated("" + totalObjects);
-        
+
         // Check if the events from CqListener are in order.
         int oldId = 0;
-        for (Object cqEvent : cqListener.events.toArray()) { 
+        for (Object cqEvent : cqListener.events.toArray()) {
           int newId = new Integer(cqEvent.toString()).intValue();
           if (oldId > newId){
-            fail("Queued events for CQ Listener during execution with " + 
+            fail("Queued events for CQ Listener during execution with " +
                 "Initial results is not in the order in which they are created.");
           }
           oldId = newId;
@@ -782,7 +787,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
         // Check if all the IDs are present as part of Select Results and CQ Events.
         HashSet ids = new HashSet(cqListener.events);
-    
+
         for (Object o : cqResults.asList()) {
           Struct s = (Struct)o;
           ids.add(s.get("key"));
@@ -796,7 +801,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
             missingIds.add(key);
           }
         }
-        
+
         if (!missingIds.isEmpty()) {
           fail("Missing Keys in either ResultSet or the Cq Event list. " +
               " Missing keys : [size : " + missingIds.size() + "]" + missingIds +
@@ -807,9 +812,11 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
 
     // Keep updating region (async invocation).
     server.invoke(new CacheSerializableRunnable("Update Region"){
+      @Override
       public void run2()throws CacheException {
         Wait.pause(200);
         client.invoke(new CacheSerializableRunnable("Releasing the latch") {
+          @Override
           public void run2()throws CacheException {
             // Now release the testhook so that CQListener can proceed.
             final TestHook testHook = CqQueryImpl.testHook;
@@ -827,9 +834,9 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     // Close.
     cqDUnitTest.closeClient(client);
     cqDUnitTest.closeServer(server);
-
   }
 
+  @Test
   public void testCqStatInitializationTimingIssue() {
     disconnectAllFromDS();
 
@@ -841,35 +848,37 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     VM server = host.getVM(0);
     VM client = host.getVM(1);
     VM client2 = host.getVM(2);
- 
+
     // Start server 1
     final int server1Port = ((Integer) server.invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true))))
         .intValue();
-    
+
     // Start a  client
     client.invoke(() -> CacheServerTestUtil.createCacheClient(getClientPool(NetworkUtils.getServerHostName(client.getHost()), server1Port), regionName));
-    
+
     // Start a pub client
     client2.invoke(() -> CacheServerTestUtil.createCacheClient(getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName));
-    
+
     //client has thread that invokes new and remove cq over and over
     client.invokeAsync(new CacheSerializableRunnable("Register cq") {
+      @Override
       public void run2() throws CacheException {
         for (int i = 0; i < 10000; i++) {
           CqQuery query = createCq(regionName, cq1Name);
           if (query != null) {
-            try {              
+            try {
               query.close();
             }
             catch (Exception e) {
-              System.out.println("exception while closing cq:" + e);
+              fail("exception while closing cq:", e);
             }
           }
         }
       }
     });
-    
+
     client2.invokeAsync(new CacheSerializableRunnable("pub updates") {
+      @Override
       public void run2() throws CacheException {
         Region region = CacheServerTestUtil.getCache().getRegion(regionName);
         while (true) {
@@ -879,8 +888,9 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
+
     server.invokeAsync(new CacheSerializableRunnable("pub updates") {
+      @Override
       public void run2() throws CacheException {
         Region region = CacheServerTestUtil.getCache().getRegion(regionName);
         while (true) {
@@ -890,42 +900,45 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
+
     //client has another thread that retrieves cq map and checks stat over and over
     client.invoke(new CacheSerializableRunnable("Check Stats") {
+      @Override
       public void run2() throws CacheException {
         for (int i = 0; i < 10000; i++) {
           checkCqStats(cq1Name);
         }
       }
     });
-    
+
     client.invoke(() -> CacheServerTestUtil.closeCache());
     client2.invoke(() -> CacheServerTestUtil.closeCache());
     server.invoke(() -> CacheServerTestUtil.closeCache());
   }
-  
+
+  @Test
   public void testGetDurableCQsFromPoolOnly() throws Exception {
     final String regionName = "regionA";
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
     VM client1 = host.getVM(1);
     VM client2 = host.getVM(2);
-    
+
     /* Create Server and Client */
     cqDUnitTest.createServer(server);
     final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server.getHost());
-  
+
     final String poolName1 = "pool1";
     final String poolName2 = "pool2";
-  
+
     cqDUnitTest.createPool(client1, poolName1, host0, port);
     cqDUnitTest.createPool(client2, poolName2, host0, port);
-    
+
     client1.invoke(new CacheSerializableRunnable("Register cq for client 1") {
+      @Override
       public void run2() throws CacheException {
-    
+
         QueryService queryService = null;
         try {
           queryService = (PoolManager.find(poolName1)).getQueryService();
@@ -941,26 +954,21 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client1NoDC2", "Select * From /root/" + regionName + " where id = 3", attributes, false).execute();
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
       }
     });
-    
+
     client2.invoke(new CacheSerializableRunnable("Register cq for client 2") {
+      @Override
       public void run2() throws CacheException {
-    
+
         QueryService queryService = null;
         try {
           queryService = (PoolManager.find(poolName2)).getQueryService();
@@ -976,24 +984,19 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client2DCQ4", "Select * From /root/" + regionName + " where id = 3", attributes, true).execute();
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
       }
     });
-    
+
     client2.invoke(new CacheSerializableRunnable("test getDurableCQsFromServer for client2") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = null;
         try {
@@ -1001,14 +1004,12 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         } catch (Exception cqe) {
           Assert.fail("Failed to getCQService.", cqe);
         }
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         assertEquals(4, list.size());
         assertTrue(list.contains("client2DCQ1"));
@@ -1017,8 +1018,9 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         assertTrue(list.contains("client2DCQ4"));
       }
     });
-    
+
     client1.invoke(new CacheSerializableRunnable("test getDurableCQsFromServer for client1") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = null;
         try {
@@ -1026,41 +1028,41 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         } catch (Exception cqe) {
           Assert.fail("Failed to getCQService.", cqe);
         }
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         assertEquals(2, list.size());
         assertTrue(list.contains("client1DCQ1"));
         assertTrue(list.contains("client1DCQ2"));
       }
     });
-    
+
     cqDUnitTest.closeClient(client2);
     cqDUnitTest.closeClient(client1);
     cqDUnitTest.closeServer(server);
   }
-  
+
+  @Test
   public void testGetDurableCQsFromServerWithEmptyList() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
     VM client1 = host.getVM(1);
-    
+
     /* Create Server and Client */
     cqDUnitTest.createServer(server);
     final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
     final String host0 = NetworkUtils.getServerHostName(server.getHost());
-  
+
     final String poolName1 = "pool1";
-  
+
     cqDUnitTest.createPool(client1, poolName1, host0, port);
-    
+
     client1.invoke(new CacheSerializableRunnable("test getDurableCQsFromServer for client1") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = null;
         try {
@@ -1068,25 +1070,24 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
         } catch (Exception cqe) {
           Assert.fail("Failed to getCQService.", cqe);
         }
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         assertEquals(0, list.size());
         assertFalse(list.contains("client1DCQ1"));
         assertFalse(list.contains("client1DCQ2"));
       }
     });
-    
+
     cqDUnitTest.closeClient(client1);
     cqDUnitTest.closeServer(server);
   }
   
+  @Test
   public void testGetDurableCqsFromServer() {
     disconnectAllFromDS();
 
@@ -1111,14 +1112,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     createClient2CqsAndDurableCqs(client2, regionName);
     
     client2.invoke(new CacheSerializableRunnable("check durable cqs for client 2") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(4, list.size());
         assertTrue(list.contains("client2DCQ1"));
@@ -1129,14 +1131,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     });
     
     client1.invoke(new CacheSerializableRunnable("check durable cqs for client 1") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(2, list.size());
         assertTrue(list.contains("client1DCQ1"));
@@ -1149,6 +1152,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     server.invoke(() -> CacheServerTestUtil.closeCache());
   }
   
+  @Test
   public void testGetDurableCqsFromServerCycleClients() {
     disconnectAllFromDS();
 
@@ -1175,14 +1179,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     cycleDurableClient(client2, "client2_dc", server1Port, regionName, timeout);
     
     client2.invoke(new CacheSerializableRunnable("check durable cqs for client 2") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(4, list.size());
         assertTrue(list.contains("client2DCQ1"));
@@ -1193,14 +1198,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     });
     
     client1.invoke(new CacheSerializableRunnable("check durable cqs for client 1") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(2, list.size());
         assertTrue(list.contains("client1DCQ1"));
@@ -1213,6 +1219,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     server.invoke(() -> CacheServerTestUtil.closeCache());
   }
   
+  @Test
   public void testGetDurableCqsFromServerCycleClientsAndMoreCqs() {
     final String regionName = "testGetAllDurableCqsFromServerCycleClients";
     final Host host = Host.getHost(0);
@@ -1238,6 +1245,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     cycleDurableClient(client2, "client2_dc", server1Port, regionName, timeout);
     
     client1.invoke(new CacheSerializableRunnable("Register more cq for client 1") {
+      @Override
       public void run2() throws CacheException {
         //register the cq's
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
@@ -1250,24 +1258,19 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client1MoreNoDC2", "Select * From /" + regionName + " where id = 3", attributes, false).execute();
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
       }
     });
     
     client2.invoke(new CacheSerializableRunnable("Register more cq for client 2") {
+      @Override
       public void run2() throws CacheException {
         //register the cq's
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
@@ -1280,19 +1283,13 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client2MoreDCQ4", "Select * From /" + regionName + " where id = 3", attributes, true).execute();
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
       }
     });
@@ -1302,14 +1299,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     cycleDurableClient(client2, "client2_dc", server1Port, regionName, timeout);
     
     client2.invoke(new CacheSerializableRunnable("check durable cqs for client 2") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(8, list.size());
         assertTrue(list.contains("client2DCQ1"));
@@ -1324,14 +1322,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     });
     
     client1.invoke(new CacheSerializableRunnable("check durable cqs for client 1") {
+      @Override
       public void run2() throws CacheException {
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
-        List<String> list;
+        List<String> list = null;
         try {
           list = queryService.getAllDurableCqsFromServer();
         }
         catch (CqException e) {
-          throw new CacheException(e) {};
+          fail("failed", e);
         }
         assertEquals(4, list.size());
         assertTrue(list.contains("client1DCQ1"));
@@ -1358,6 +1357,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
   //helper to create durable cqs to test out getAllDurableCqs functionality
   private void createClient1CqsAndDurableCqs(VM client, final String regionName) {
     client.invoke(new CacheSerializableRunnable("Register cq for client 1") {
+      @Override
       public void run2() throws CacheException {
         //register the cq's
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
@@ -1370,19 +1370,13 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client1NoDC2", "Select * From /" + regionName + " where id = 3", attributes, false).execute();
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
       }
     });
@@ -1390,6 +1384,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
   
   private void createClient2CqsAndDurableCqs(VM client, final String regionName) {
     client.invoke(new CacheSerializableRunnable("Register cq for client 2") {
+      @Override
       public void run2() throws CacheException {
         //register the cq's
         QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
@@ -1402,19 +1397,13 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           queryService.newCq("client2DCQ4", "Select * From /" + regionName + " where id = 3", attributes, true).execute();
         }
         catch (RegionNotFoundException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
         catch (CqExistsException e) {
-          throw new CacheException(e) {
-            
-          };
+          fail("failed", e);
         }
 
       }
@@ -1423,6 +1412,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
   
   private void cycleDurableClient(VM client, final String dcName, final int serverPort, final String regionName, final int durableClientTimeout) {
     client.invoke(new CacheSerializableRunnable("cycle client") {
+      @Override
       public void run2() throws CacheException {
         CacheServerTestUtil.closeCache(true);
       }
@@ -1430,7 +1420,6 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     
     client.invoke(() -> CacheServerTestUtil.createClientCache(getClientPool(NetworkUtils.getServerHostName(client.getHost()), serverPort), regionName, getDurableClientProperties(dcName, durableClientTimeout)));
   }
-  
 
   private CqQuery createCq(String regionName, String cqName) {
     // Create CQ Attributes.
@@ -1438,19 +1427,15 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
     
     // Initialize and set CqListener.
     CqListener[] cqListeners = { new CqListener() {
-
       @Override
       public void close() {
       }
-
       @Override
       public void onEvent(CqEvent aCqEvent) {
       }
-
       @Override
       public void onError(CqEvent aCqEvent) {
       }
-      
     }};
     cqAf.initCqListeners(cqListeners);
     CqAttributes cqa = cqAf.create();
@@ -1464,14 +1449,14 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
       query.execute();
     }
     catch (CqExistsException e) {
-      fail("Could not find specified region:" + regionName + ":" + e);
+      fail("Could not find specified region:" + regionName + ":", e);
     }
     catch (CqException e) {
-      fail("Could not find specified region:" + regionName + ":" + e);
+      fail("Could not find specified region:" + regionName + ":", e);
 
     }
     catch (RegionNotFoundException e) {
-      fail("Could not find specified region:" + regionName + ":" + e);
+      fail("Could not find specified region:" + regionName + ":", e);
     }
     return query;
   }
@@ -1492,10 +1477,10 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
       .setSubscriptionAckInterval(1).setSubscriptionEnabled(true);
     return ((PoolFactoryImpl)pf).getPoolAttributes();
   }
-  
 
   public CacheSerializableRunnable setTestHook() {
     SerializableRunnable sr = new CacheSerializableRunnable("TestHook") {
+      @Override
       public void run2() {
         class CqQueryTestHook implements CqQueryImpl.TestHook {
 
@@ -1503,27 +1488,30 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase {
           private int numEvents = 0;
           Cache cache = GemFireCacheImpl.getInstance();
           
+          @Override
           public void pauseUntilReady() {
             try {
               cache.getLogger().fine("CqQueryTestHook: Going to wait on latch until ready is called.");
               if (!latch.await(10, TimeUnit.SECONDS)) {
-                throw new TestException("query was never unlatched");
+                fail("query was never unlatched");
               }
             } catch (Exception e) {
-              e.printStackTrace();
-              Thread.currentThread().interrupt();
+              fail("interrupted", e);
             }
           }
 
+          @Override
           public void ready() {
             latch.countDown();
             cache.getLogger().fine("CqQueryTestHook: The latch has been released.");
           }
 
+          @Override
           public int numQueuedEvents() {
             return numEvents;
           }
           
+          @Override
           public void setEventCount(int count) {
             cache.getLogger().fine("CqQueryTestHook: Setting numEVents to: " + count);
             numEvents = count;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolOptimizedExecuteDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolOptimizedExecuteDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolOptimizedExecuteDUnitTest.java
index 03bc48b..6d66ed7 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolOptimizedExecuteDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolOptimizedExecuteDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 
 import com.gemstone.gemfire.cache.query.internal.cq.CqServiceImpl;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
@@ -26,10 +35,11 @@ import com.gemstone.gemfire.test.dunit.SerializableRunnable;
  * Test class for testing {@link CqServiceImpl#EXECUTE_QUERY_DURING_INIT} flag
  *
  */
+@Category(DistributedTest.class)
 public class CqDataUsingPoolOptimizedExecuteDUnitTest extends CqDataUsingPoolDUnitTest {
 
-  public CqDataUsingPoolOptimizedExecuteDUnitTest(String name) {
-    super(name);
+  public CqDataUsingPoolOptimizedExecuteDUnitTest() {
+    super();
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfDUnitTest.java
index fe8e23e..20b2a52 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -51,12 +60,13 @@ import com.gemstone.gemfire.test.junit.categories.FlakyTest;
  * This class tests the ContiunousQuery mechanism in GemFire.
  * This includes the test with diffetent data activities.
  */
-public class CqPerfDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class CqPerfDUnitTest extends JUnit4CacheTestCase {
 
-  protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest("CqPerfDUnitTest");
+  protected CqQueryDUnitTest cqDUnitTest = new CqQueryDUnitTest();
   
-  public CqPerfDUnitTest(String name) {
-    super(name);
+  public CqPerfDUnitTest() {
+    super();
   }
 
   @Override
@@ -181,6 +191,7 @@ public class CqPerfDUnitTest extends CacheTestCase {
    * Test for maintaining keys for update optimization.
    * @throws Exception
    */
+  @Test
   public void testKeyMaintainance() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -402,6 +413,7 @@ public class CqPerfDUnitTest extends CacheTestCase {
    * @throws Exception
    */
   @Category(FlakyTest.class) // GEODE-1164: random ports, thread sleeps, time sensitive, eats exceptions (fixed 1), async behavior
+  @Test
   public void testMatchingCqs() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -513,6 +525,7 @@ public class CqPerfDUnitTest extends CacheTestCase {
    * To test the changes relating to, executing CQ only once for all similar CQs.
    * @throws Exception
    */
+  @Test
   public void testMatchingCQWithMultipleClients() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -672,6 +685,7 @@ public class CqPerfDUnitTest extends CacheTestCase {
    * Test for CQ Fail over.
    * @throws Exception
    */
+  @Test
   public void testMatchingCQsWithMultipleServers() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -832,6 +846,7 @@ public class CqPerfDUnitTest extends CacheTestCase {
    * Test for CQ Fail over.
    * @throws Exception
    */
+  @Test
   public void testMatchingCQsOnDataNodeWithMultipleServers() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
index 2a91abb..0168419 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqPerfUsingPoolDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -51,12 +60,13 @@ import com.gemstone.gemfire.test.junit.categories.FlakyTest;
  * This class tests the ContiunousQuery mechanism in GemFire.
  * This includes the test with diffetent data activities.
  */
-public class CqPerfUsingPoolDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class CqPerfUsingPoolDUnitTest extends JUnit4CacheTestCase {
 
-  protected CqQueryUsingPoolDUnitTest cqDUnitTest = new CqQueryUsingPoolDUnitTest("CqPerfUsingPoolDUnitTest"); // TODO: get rid of this!
+  protected CqQueryUsingPoolDUnitTest cqDUnitTest = new CqQueryUsingPoolDUnitTest(); // TODO: get rid of this!
   
-  public CqPerfUsingPoolDUnitTest(String name) {
-    super(name);
+  public CqPerfUsingPoolDUnitTest() {
+    super();
   }
 
   @Override
@@ -181,6 +191,7 @@ public class CqPerfUsingPoolDUnitTest extends CacheTestCase {
    * Test for maintaining keys for update optimization.
    * @throws Exception
    */
+  @Test
   public void testKeyMaintenance() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -402,6 +413,7 @@ public class CqPerfUsingPoolDUnitTest extends CacheTestCase {
    * @throws Exception
    */
   @Category(FlakyTest.class) // GEODE-988: random ports, time sensitive, waitForCriterion, 20 second timeouts
+  @Test
   public void testMatchingCqs() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -516,6 +528,7 @@ public class CqPerfUsingPoolDUnitTest extends CacheTestCase {
    * To test the changes relating to, executing CQ only once for all similar CQs.
    * @throws Exception
    */
+  @Test
   public void testMatchingCQWithMultipleClients() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -679,6 +692,7 @@ public class CqPerfUsingPoolDUnitTest extends CacheTestCase {
    * Test for CQ Fail over.
    * @throws Exception
    */
+  @Test
   public void testMatchingCQsWithMultipleServers() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryDUnitTest.java
index 5c993ce..25d3380 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryDUnitTest.java
@@ -16,14 +16,50 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
-import com.gemstone.gemfire.cache.*;
-import com.gemstone.gemfire.cache.query.*;
+import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.EvictionAction;
+import com.gemstone.gemfire.cache.EvictionAttributes;
+import com.gemstone.gemfire.cache.MirrorType;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.RegionFactory;
+import com.gemstone.gemfire.cache.RegionShortcut;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.query.CqAttributes;
+import com.gemstone.gemfire.cache.query.CqAttributesFactory;
+import com.gemstone.gemfire.cache.query.CqAttributesMutator;
+import com.gemstone.gemfire.cache.query.CqClosedException;
+import com.gemstone.gemfire.cache.query.CqExistsException;
+import com.gemstone.gemfire.cache.query.CqListener;
+import com.gemstone.gemfire.cache.query.CqQuery;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.RegionNotFoundException;
+import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.data.Portfolio;
 import com.gemstone.gemfire.cache.query.internal.CqStateImpl;
 import com.gemstone.gemfire.cache.query.internal.DefaultQueryService;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.cache30.CertifiableTestCacheListener;
 import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
@@ -32,23 +68,26 @@ import com.gemstone.gemfire.internal.cache.DistributedRegion;
 import com.gemstone.gemfire.internal.cache.DistributedTombstoneOperation;
 import com.gemstone.gemfire.internal.cache.EventID;
 import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.dunit.*;
-
-import java.io.IOException;
-import java.util.*;
-
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.LOCATORS;
-import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.MCAST_PORT;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.LogWriterUtils;
+import com.gemstone.gemfire.test.dunit.NetworkUtils;
+import com.gemstone.gemfire.test.dunit.SerializableRunnable;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 /**
  * This class tests the ContiunousQuery mechanism in GemFire.
  * It does so by creating a cache server with a cache and a pre-defined region and
  * a data loader. The client creates the same region and attaches the connection pool.
- * 
- *
  */
+@Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class CqQueryDUnitTest extends CacheTestCase {
+public class CqQueryDUnitTest extends JUnit4CacheTestCase {
   
   /** The port on which the bridge server was started in this VM */
   private static int bridgeServerPort;
@@ -133,10 +172,6 @@ public class CqQueryDUnitTest extends CacheTestCase {
   // 11 - Test for "short" number type
   "SELECT ALL * FROM /root/" + regions[0] + " p where p.shortID IN SET(1,2,3,4,5)" };
 
-  public CqQueryDUnitTest(String name) {
-    super(name);
-  }
-
   @Override
   public final void postSetUp() throws Exception {
     // avoid IllegalStateException from HandShake by connecting all vms tor
@@ -1575,6 +1610,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * bug #47494 - CQs were destroyed when a server did a tombstone GC 
    */
+  @Test
   public void testCQRemainsWhenServerGCs() throws Exception {
 
     final Host host = Host.getHost(0);
@@ -1621,6 +1657,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for InterestList and CQ registered from same clients.
    * @throws Exception
    */
+  @Test
   public void testInterestListAndCQs() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -1790,6 +1827,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ register and UnRegister.
    * @throws Exception
    */
+  @Test
   public void testCQStopExecute() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -1874,6 +1912,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ Attributes Mutator functions
    * @throws Exception
    */
+  @Test
   public void testCQAttributesMutator() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -1969,6 +2008,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ register and UnRegister.
    * @throws Exception
    */
+  @Test
   public void testCQCreateClose() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -2156,6 +2196,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * The CQs on the destroy region needs to be closed.
    *
    */
+  @Test
   public void testRegionDestroy() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -2237,6 +2278,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * Test for CQ with multiple clients.
    */
+  @Test
   public void testCQWithMultipleClients() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -2389,6 +2431,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * Test for CQ ResultSet.
    */
+  @Test
   public void testCQResultSet() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -2460,6 +2503,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ Listener events.
    *
    */
+  @Test
   public void testCQEvents() throws Exception {
     
     final Host host = Host.getHost(0);
@@ -2557,6 +2601,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
     closeServer(server);
   }
   
+  @Test
   public void testCQMapValues() throws Exception {
 
     final Host host = Host.getHost(0);
@@ -2647,6 +2692,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for stopping and restarting CQs.
    * @throws Exception
    */
+  @Test
   public void testEnableDisableCQ() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -2789,6 +2835,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for Complex queries.
    * @throws Exception
    */
+  @Test
   public void testQuery() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -2830,6 +2877,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ Fail over.
    * @throws Exception
    */
+  @Test
   public void testCQFailOver() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -2916,6 +2964,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * Test for CQ Fail over/HA with redundancy level set.
    * @throws Exception
    */
+  @Test
   public void testCQHA() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3015,6 +3064,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * no CQService intiated.
    * @throws Exception
    */
+  @Test
   public void testWithoutCQs() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3077,6 +3127,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * Test getCQs for a regions
    */
+  @Test
   public void testGetCQsForARegionName() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -3144,6 +3195,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * Test exception message thrown when replicate region with local destroy is used
    */
+  @Test
   public void testCqExceptionForReplicateRegionWithEvictionLocalDestroy() throws Exception {
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -3179,6 +3231,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * 
    * @throws Exception
    */
+  @Test
   public void testQueryWithNULLInWhereClause() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -3228,6 +3281,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
    * 
    * @throws Exception
    */
+  @Test
   public void testForSupportedRegionAttributes() throws Exception
   {
     final Host host = Host.getHost(0);
@@ -3330,6 +3384,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * 
    */
+  @Test
   public void testCQWhereCondOnShort() throws Exception {
        
        final Host host = Host.getHost(0);
@@ -3362,6 +3417,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * 
    */
+  @Test
   public void testCQEquals() throws Exception {
        
        final Host host = Host.getHost(0);
@@ -3414,6 +3470,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /**
    * 
    */
+  @Test
   public void testCQEqualsWithIndex() throws Exception {
        
        final Host host = Host.getHost(0);
@@ -3465,6 +3522,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
 
   
   //Tests that cqs get an onCqDisconnect and onCqConnect
+  @Test
   public void testCQAllServersCrash() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3512,6 +3570,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   }
 
   //Tests that we receive both an onCqConnected and a onCqDisconnected message
+  @Test
   public void testCQAllServersLeave() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3557,6 +3616,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   //Test cqstatus listeners, onCqDisconnect should trigger when All servers leave
   //and onCqConnect should trigger when a cq is first connected and when the pool
   //goes from no primary queue to having a primary
+  @Test
   public void testCQAllServersLeaveAndRejoin() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3617,6 +3677,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   /*
    * Tests that the cqs do not get notified if primary leaves and a new primary is elected
    */
+  @Test
   public void testCQPrimaryLeaves() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3663,6 +3724,7 @@ public class CqQueryDUnitTest extends CacheTestCase {
   // Each cq uses a different pool and the servers are shutdown.
   // The listeners for each cq should receive a connect and disconnect
   // when their respective servers are shutdown
+  @Test
   public void testCQAllServersLeaveMultiplePool() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(0);
@@ -3715,7 +3777,8 @@ public class CqQueryDUnitTest extends CacheTestCase {
   }  
 
   
-public void testCqCloseAndExecuteWithInitialResults() throws Exception {
+  @Test
+  public void testCqCloseAndExecuteWithInitialResults() throws Exception {
     
     final Host host = Host.getHost(0);
     VM server = host.getVM(0);
@@ -3744,7 +3807,8 @@ public void testCqCloseAndExecuteWithInitialResults() throws Exception {
    closeServer(server);    
  }
 
-public void testCQEventsWithNotEqualsUndefined() throws Exception {
+  @Test
+  public void testCQEventsWithNotEqualsUndefined() throws Exception {
  
   final Host host = Host.getHost(0);
   VM server = host.getVM(0);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b914df23/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java
index 57d6adf..d63ffd7 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqQueryOptimizedExecuteDUnitTest.java
@@ -16,6 +16,15 @@
  */
 package com.gemstone.gemfire.cache.query.cq.dunit;
 
+import org.junit.experimental.categories.Category;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+
 import com.gemstone.gemfire.cache.CacheException;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.query.data.Portfolio;
@@ -31,10 +40,11 @@ import com.gemstone.gemfire.test.dunit.*;
  * Test class for testing {@link CqServiceImpl#EXECUTE_QUERY_DURING_INIT} flag
  *
  */
+@Category(DistributedTest.class)
 public class CqQueryOptimizedExecuteDUnitTest extends CqQueryDUnitTest {
 
-  public CqQueryOptimizedExecuteDUnitTest(String name) {
-    super(name);
+  public CqQueryOptimizedExecuteDUnitTest() {
+    super();
   }
 
   @Override
@@ -56,6 +66,7 @@ public class CqQueryOptimizedExecuteDUnitTest extends CqQueryDUnitTest {
     });
   }
   
+  @Test
   public void testCqExecuteWithoutQueryExecution() throws Exception {
     final Host host = Host.getHost(0);
     final VM server = host.getVM(0);
@@ -148,6 +159,7 @@ public class CqQueryOptimizedExecuteDUnitTest extends CqQueryDUnitTest {
     closeServer(server);    
   }
 
+  @Test
   public void testCqExecuteWithoutQueryExecutionAndNoRSCaching() throws Exception {
     final Host host = Host.getHost(0);
     final VM server = host.getVM(0);
@@ -251,6 +263,7 @@ public class CqQueryOptimizedExecuteDUnitTest extends CqQueryDUnitTest {
   // Each cq uses a different pool and the servers are shutdown.
   // The listeners for each cq should receive a connect and disconnect
   // when their respective servers are shutdown
+  @Test
   public void testCQAllServersLeaveMultiplePool() throws Exception {
     final Host host = Host.getHost(0);
     VM server1 = host.getVM(1);