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/03/08 19:11:52 UTC

[2/3] incubator-geode git commit: Cleanup of dunit and CacheTestCase

Cleanup of dunit and CacheTestCase


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/ce38338e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/ce38338e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/ce38338e

Branch: refs/heads/feature/GEODE-1050
Commit: ce38338ef4306f8637e3992452866d40a85b0adf
Parents: 7baa2a7
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 8 09:55:34 2016 -0800
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 8 09:55:34 2016 -0800

----------------------------------------------------------------------
 .../gemfire/cache30/CacheCloseDUnitTest.java    |   3 +-
 .../gemstone/gemfire/cache30/CacheTestCase.java |  99 ++--
 .../gemfire/cache30/MultiVMRegionTestCase.java  |  13 +-
 .../ReconnectedCacheServerDUnitTest.java        |  19 +-
 .../distributed/DistributedSystemDUnitTest.java |   7 +-
 .../internal/DistributionManagerDUnitTest.java  |   4 +-
 .../gemfire/disttx/DistTXDebugDUnitTest.java    |  96 +--
 .../disttx/DistTXPersistentDebugDUnitTest.java  |   8 +-
 .../cache/InterruptClientServerDUnitTest.java   |   2 +-
 .../internal/cache/InterruptsDUnitTest.java     |   2 +-
 .../cache/PartitionedRegionAPIDUnitTest.java    |  43 +-
 ...gionBucketCreationDistributionDUnitTest.java |  67 ++-
 .../cache/execute/LocalDataSetDUnitTest.java    |  14 +-
 .../cache/ha/HAConflationDUnitTest.java         |  32 +-
 .../gemfire/test/dunit/DistributedTestCase.java | 150 +++--
 .../dunit/cache/internal/CacheTestFixture.java  |  40 ++
 .../cache/internal/JUnit3CacheTestCase.java     | 271 +++++++++
 .../cache/internal/JUnit4CacheTestCase.java     | 586 +++++++++++++++++++
 .../dunit/internal/DistributedTestFixture.java  |   2 +-
 .../internal/JUnit3DistributedTestCase.java     |  69 +--
 .../internal/JUnit4DistributedTestCase.java     |  34 +-
 .../security/ClientAuthzObjectModDUnitTest.java |   5 -
 22 files changed, 1217 insertions(+), 349 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheCloseDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheCloseDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheCloseDUnitTest.java
index 1938483..ea17a4d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheCloseDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheCloseDUnitTest.java
@@ -26,6 +26,7 @@ import com.gemstone.gemfire.cache.CacheLoaderException;
 import com.gemstone.gemfire.cache.LoaderHelper;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit3CacheTestCase;
 
 /**
  * Test to make sure cache close is working.
@@ -33,7 +34,7 @@ import com.gemstone.gemfire.cache.RegionAttributes;
  * @author darrel
  * @since 3.0
  */
-public class CacheCloseDUnitTest extends CacheTestCase {
+public class CacheCloseDUnitTest extends JUnit3CacheTestCase {
 
   public CacheCloseDUnitTest(String name) {
     super(name);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java
index 5187dc8..1258269 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheTestCase.java
@@ -79,7 +79,7 @@ public abstract class CacheTestCase extends DistributedTestCase {
    * All references synchronized via <code>CacheTestCase.class</code>
    * */
   // static so it doesn't get serialized with SerializableRunnable inner classes
-  protected static Cache cache;
+  private static Cache cache; // TODO: make private
   
   ////////  Constructors
 
@@ -156,32 +156,6 @@ public abstract class CacheTestCase extends DistributedTestCase {
       return cache;
     }
   }
-  
-  /**
-   * Creates the <code>Cache</code> for this test that is not connected
-   * to other members.
-   * Added specifically to test scenario of defect #47181.
-   */
-  public final Cache createLonerCacheWithEnforceUniqueHost() {
-    synchronized(CacheTestCase.class) {
-      try {
-        System.setProperty("gemfire.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true");
-        Cache c = CacheFactory.create(getLonerSystemWithEnforceUniqueHost()); 
-        cache = c;
-      } catch (CacheExistsException e) {
-        Assert.fail("the cache already exists", e);
-
-      } catch (RuntimeException ex) {
-        throw ex;
-
-      } catch (Exception ex) {
-        Assert.fail("Checked exception while initializing cache??", ex);
-      } finally {
-        System.clearProperty("gemfire.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE");
-      }
-      return cache;
-    }
-  }
 
   /**
    * Sets this test up with a CacheCreation as its cache.
@@ -337,11 +311,6 @@ public abstract class CacheTestCase extends DistributedTestCase {
       return cache;
   }
 
-  public static synchronized final void disconnectFromDS() {
-    closeCache();
-    DistributedTestCase.disconnectFromDS();
-  }
-  
   /** Close the cache */
   public static synchronized final void closeCache() {
     //Workaround for that fact that some classes are now extending
@@ -522,21 +491,21 @@ public abstract class CacheTestCase extends DistributedTestCase {
   }
 
 
-  /**
-   * send an unordered message requiring an ack to all connected members 
-   * in order to flush the unordered communication channel
-   */
-  public final void sendUnorderedMessageToAll() {
-    //if (getCache() instanceof distcache.gemfire.GemFireCacheImpl) {
-      try {
-        com.gemstone.gemfire.distributed.internal.HighPriorityAckedMessage msg = new com.gemstone.gemfire.distributed.internal.HighPriorityAckedMessage();
-        msg.send(InternalDistributedSystem.getConnectedInstance().getDM().getNormalDistributionManagerIds(), false);
-      }
-      catch (Exception e) {
-        throw new RuntimeException("Unable to send unordered message due to exception", e);
-      }
-    //}
-  }
+//  /**
+//   * send an unordered message requiring an ack to all connected members
+//   * in order to flush the unordered communication channel
+//   */
+//  public final void sendUnorderedMessageToAll() {
+//    //if (getCache() instanceof distcache.gemfire.GemFireCacheImpl) {
+//      try {
+//        com.gemstone.gemfire.distributed.internal.HighPriorityAckedMessage msg = new com.gemstone.gemfire.distributed.internal.HighPriorityAckedMessage();
+//        msg.send(InternalDistributedSystem.getConnectedInstance().getDM().getNormalDistributionManagerIds(), false);
+//      }
+//      catch (Exception e) {
+//        throw new RuntimeException("Unable to send unordered message due to exception", e);
+//      }
+//    //}
+//  }
 
   /**
    * send an unordered message requiring an ack to all connected admin members 
@@ -554,27 +523,27 @@ public abstract class CacheTestCase extends DistributedTestCase {
 //    //}
 //  }
 
-  /**
-   * send an ordered message requiring an ack to all connected members 
-   * in order to flush the ordered communication channel
-   */
-  public void sendSerialMessageToAll() {
-    if (getCache() instanceof GemFireCacheImpl) {
-      try {
-        com.gemstone.gemfire.distributed.internal.SerialAckedMessage msg = new com.gemstone.gemfire.distributed.internal.SerialAckedMessage();
-        msg.send(InternalDistributedSystem.getConnectedInstance().getDM().getNormalDistributionManagerIds(), false);
-      }
-      catch (Exception e) {
-        throw new RuntimeException("Unable to send serial message due to exception", e);
-      }
-    }
-  }
+//  /**
+//   * send an ordered message requiring an ack to all connected members
+//   * in order to flush the ordered communication channel
+//   */
+//  public final void sendSerialMessageToAll() {
+//    if (getCache() instanceof GemFireCacheImpl) {
+//      try {
+//        com.gemstone.gemfire.distributed.internal.SerialAckedMessage msg = new com.gemstone.gemfire.distributed.internal.SerialAckedMessage();
+//        msg.send(InternalDistributedSystem.getConnectedInstance().getDM().getNormalDistributionManagerIds(), false);
+//      }
+//      catch (Exception e) {
+//        throw new RuntimeException("Unable to send serial message due to exception", e);
+//      }
+//    }
+//  }
 
   /**
    * @deprecated Use DistributedTestCase.addExpectedException
    */
   @Deprecated
-  protected CacheSerializableRunnable addExceptionTag1(final String expectedException) {
+  protected final CacheSerializableRunnable addExceptionTag1(final String expectedException) {
     CacheSerializableRunnable addExceptionTag = new CacheSerializableRunnable(
     "addExceptionTag") {
       public void run2()
@@ -592,7 +561,7 @@ public abstract class CacheTestCase extends DistributedTestCase {
    * @deprecated Use DistributedTestCase.addExpectedException
    */
   @Deprecated
-  protected CacheSerializableRunnable removeExceptionTag1(final String expectedException) {
+  protected final CacheSerializableRunnable removeExceptionTag1(final String expectedException) {
     CacheSerializableRunnable removeExceptionTag = new CacheSerializableRunnable(
     "removeExceptionTag") {
       public void run2() throws CacheException {
@@ -608,7 +577,7 @@ public abstract class CacheTestCase extends DistributedTestCase {
    * Used to generate a cache.xml. Basically just a CacheCreation
    * with a few more methods implemented.
    */
-  static class TestCacheCreation extends CacheCreation {
+  private static final class TestCacheCreation extends CacheCreation {
     private boolean closed = false;
     @Override
     public void close() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
index 7a4d09e..a49d7d8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/MultiVMRegionTestCase.java
@@ -171,7 +171,6 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
   
   @Override
   protected final void postTearDownRegionTestCase() throws Exception {
-    DistributedTestCase.cleanupAllVms();
     CCRegion = null;
   }
 
@@ -5713,7 +5712,6 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
    */
   private static void unregisterAllSerializers() {
     DistributedTestUtils.unregisterAllDataSerializersFromAllVms();
-    cleanupAllVms();
   }
 
   /**
@@ -9128,6 +9126,17 @@ public abstract class MultiVMRegionTestCase extends RegionTestCase {
     return CCRegion.getDistributionManager().getDistributionManagerId();
   }
 
+  public void sendSerialMessageToAll() {
+    if (getCache() instanceof GemFireCacheImpl) {
+      try {
+        com.gemstone.gemfire.distributed.internal.SerialAckedMessage msg = new com.gemstone.gemfire.distributed.internal.SerialAckedMessage();
+        msg.send(InternalDistributedSystem.getConnectedInstance().getDM().getNormalDistributionManagerIds(), false);
+      }
+      catch (Exception e) {
+        throw new RuntimeException("Unable to send serial message due to exception", e);
+      }
+    }
+  }
 
   /** a class for testing handling of concurrent delta operations */
   static class DeltaValue implements com.gemstone.gemfire.Delta, Serializable {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/cache30/ReconnectedCacheServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/ReconnectedCacheServerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/cache30/ReconnectedCacheServerDUnitTest.java
index 6daf213..f3d6964 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/ReconnectedCacheServerDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/ReconnectedCacheServerDUnitTest.java
@@ -16,6 +16,7 @@
  */
 package com.gemstone.gemfire.cache30;
 
+import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper;
 import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershipManager;
@@ -32,22 +33,24 @@ public class ReconnectedCacheServerDUnitTest extends CacheTestCase {
   private static final long serialVersionUID = 1L;
   
   private boolean addedCacheServer = false;
-  
+
+  private Cache cache;
+
   @Override
   public void setUp() {
-    getCache();
-    if (cache.getCacheServers().isEmpty()) {
-      cache.addCacheServer();
+    this.cache = getCache();
+    if (this.cache.getCacheServers().isEmpty()) {
+      this.cache.addCacheServer();
       addedCacheServer = true;
     }
   }
   
   @Override
   protected final void preTearDownCacheTestCase() throws Exception {
-    if (addedCacheServer && cache != null && !cache.isClosed()) {
+    if (addedCacheServer && this.cache != null && !this.cache.isClosed()) {
       // since I polluted the cache I should shut it down in order
       // to avoid affecting other tests
-      cache.close();
+      this.cache.close();
     }
   }
 
@@ -55,7 +58,7 @@ public class ReconnectedCacheServerDUnitTest extends CacheTestCase {
     // make sure the environment isn't polluted
     assertFalse(Boolean.getBoolean("gemfire.autoReconnect-useCacheXMLFile"));
 
-    GemFireCacheImpl gc = (GemFireCacheImpl)cache;
+    GemFireCacheImpl gc = (GemFireCacheImpl)this.cache;
     
     // fool the system into thinking cluster-config is being used
     GMSMembershipManager mgr = (GMSMembershipManager)MembershipManagerHelper
@@ -71,7 +74,7 @@ public class ReconnectedCacheServerDUnitTest extends CacheTestCase {
     
     assertFalse(Boolean.getBoolean("gemfire.autoReconnect-useCacheXMLFile"));
     
-    GemFireCacheImpl gc = (GemFireCacheImpl)cache;
+    GemFireCacheImpl gc = (GemFireCacheImpl)this.cache;
 
     // fool the system into thinking cluster-config is being used
     GMSMembershipManager mgr = (GMSMembershipManager)MembershipManagerHelper

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
index b341ae6..f32c26f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemDUnitTest.java
@@ -45,11 +45,12 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershi
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -64,10 +65,6 @@ import org.junit.experimental.categories.Category;
 @Category(DistributedTest.class)
 public class DistributedSystemDUnitTest extends JUnit4DistributedTestCase {
 
-//  public DistributedSystemDUnitTest(String name) {
-//    super(name);
-//  }
-  
   public void postSetUp() throws Exception {
     disconnectAllFromDS();
   }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionManagerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionManagerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionManagerDUnitTest.java
index 2164fdc..084ada5 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionManagerDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionManagerDUnitTest.java
@@ -46,6 +46,7 @@ import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManage
 import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manager;
 import com.gemstone.gemfire.distributed.internal.membership.gms.mgr.GMSMembershipManager;
 import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
@@ -75,9 +76,8 @@ public class DistributionManagerDUnitTest extends DistributedTestCase {
   }
   
   @Override
-  public void setUp() throws Exception {
+  public void preSetUp() throws Exception {
     disconnectAllFromDS();
-    super.setUp();
   }
 
   ////////  Test Methods

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXDebugDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXDebugDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXDebugDUnitTest.java
index dcb9ae7..768b800 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXDebugDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXDebugDUnitTest.java
@@ -124,8 +124,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     // assertNotNull(basicGetCache());
     // Region pr = basicGetCache().createRegion(partitionedRegionName,
     // attr.create());
-    assertNotNull(cache);
-    Region pr = cache.createRegion(partitionedRegionName, attr.create());
+    assertNotNull(basicGetCache());
+    Region pr = basicGetCache().createRegion(partitionedRegionName, attr.create());
     assertNotNull(pr);
     LogWriterUtils.getLogWriter().info(
         "Partitioned Region " + partitionedRegionName
@@ -145,8 +145,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     // assertNotNull(basicGetCache());
     // Region pr = basicGetCache().getRegion(partitionedRegionName);
 
-    assertNotNull(cache);
-    Region pr = cache.getRegion(partitionedRegionName);
+    assertNotNull(basicGetCache());
+    Region pr = basicGetCache().getRegion(partitionedRegionName);
     assertNotNull(pr);
     LogWriterUtils.getLogWriter().info(
         "Destroying Partitioned Region " + partitionedRegionName);
@@ -163,7 +163,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     }
     // Region rr = basicGetCache().createRegion(replicatedRegionName,
     // af.create());
-    Region rr = cache.createRegion(replicatedRegionName, af.create());
+    Region rr = basicGetCache().createRegion(replicatedRegionName, af.create());
     assertNotNull(rr);
     LogWriterUtils.getLogWriter().info(
         "Replicated Region " + replicatedRegionName + " created Successfully :"
@@ -191,7 +191,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // PartitionedRegion pr1 = (PartitionedRegion)
         // basicGetCache().getRegion(
         // "pregion1");
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         // put some data (non tx ops)
         for (int i = 1; i <= 3; i++) {
           DummyKeyBasedRoutingResolver dummy = new DummyKeyBasedRoutingResolver(
@@ -203,7 +203,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // put in tx and commit
         // CacheTransactionManager ctx = basicGetCache()
         // .getCacheTransactionManager();
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -262,7 +262,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         SerializableCallable verifySize = new SerializableCallable("getOps") {
           @Override
           public Object call() throws CacheException {
-            PartitionedRegion pr1 = (PartitionedRegion) cache
+            PartitionedRegion pr1 = (PartitionedRegion) basicGetCache()
                 .getRegion("pregion1");
             LogWriterUtils.getLogWriter().info(
                 " calling pr.getLocalSize " + pr1.getLocalSize());
@@ -295,8 +295,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
-        Region rr1 = cache.getRegion("rregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
 
         // put some data (non tx ops)
         for (int i = 1; i <= 6; i++) {
@@ -307,7 +307,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
           rr1.put(dummy, "1_entry__" + i);
         }
 
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         // destroy data in tx and commit
         ctx.begin();
@@ -350,8 +350,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
-        Region rr1 = cache.getRegion("rregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr1.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
@@ -382,9 +382,9 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // PartitionedRegion pr1 = (PartitionedRegion)
         // basicGetCache().getRegion(
         // "pregion1");
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         // Region rr1 = basicGetCache().getRegion("rregion1");
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         // put some data (non tx ops)
         for (int i = 1; i <= 3; i++) {
           DummyKeyBasedRoutingResolver dummy = new DummyKeyBasedRoutingResolver(
@@ -398,7 +398,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // put in tx and commit
         // CacheTransactionManager ctx = basicGetCache()
         // .getCacheTransactionManager();
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -430,12 +430,12 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
 
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter()
             .info(" calling rr.getLocalSize " + rr1.size());
         assertEquals(3, rr1.size());
@@ -461,12 +461,12 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // PartitionedRegion pr1 = (PartitionedRegion)
         // basicGetCache().getRegion(
         // "pregion1");
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
 
         // put in tx and commit
         // CacheTransactionManager ctx = basicGetCache()
         // .getCacheTransactionManager();
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -493,8 +493,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxGetOps = new SerializableCallable("TxGetOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
@@ -512,12 +512,12 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         // PartitionedRegion pr1 = (PartitionedRegion)
         // basicGetCache().getRegion(
         // "pregion1");
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
 
         // put in tx and commit
         // CacheTransactionManager ctx = basicGetCache()
         // .getCacheTransactionManager();
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -558,9 +558,9 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
-        Region rr1 = cache.getRegion("rregion1");
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -595,12 +595,12 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter()
             .info(" calling rr.getLocalSize " + rr1.size());
         assertEquals(3, rr1.size());
         
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
@@ -624,10 +624,10 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
-        Region rr1 = cache.getRegion("rregion1");     
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         HashMap<DummyKeyBasedRoutingResolver, String> phm = new HashMap<DummyKeyBasedRoutingResolver, String>();
@@ -663,12 +663,12 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter()
             .info(" calling rr.getLocalSize " + rr1.size());
         assertEquals(3, rr1.size());
         
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
@@ -691,9 +691,9 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         HashMap<DummyKeyBasedRoutingResolver, String> phm = new HashMap<DummyKeyBasedRoutingResolver, String>();
@@ -725,7 +725,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(2, pr1.getLocalSize());
@@ -760,7 +760,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");     
+        Region rr1 = basicGetCache().getRegion("rregion1");
         //put some data
         HashMap<Integer, String> rhm = new HashMap<Integer, String>();
         for (int i = 1; i <= 3; i++) {
@@ -768,7 +768,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         }
         rr1.putAll(rhm);
         
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         rr1.removeAll(rhm.keySet());
@@ -795,7 +795,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter()
             .info(" calling rr.getLocalSize " + rr1.size());
         assertEquals(0, rr1.size());
@@ -818,7 +818,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         HashMap<DummyKeyBasedRoutingResolver, String> phm = new HashMap<DummyKeyBasedRoutingResolver, String>();
         for (int i = 1; i <= 3; i++) {
           DummyKeyBasedRoutingResolver dummy = new DummyKeyBasedRoutingResolver(
@@ -827,7 +827,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
         }
         pr1.putAll(phm);
         
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         pr1.removeAll(phm.keySet());
@@ -850,7 +850,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        PartitionedRegion pr1 = (PartitionedRegion) cache.getRegion("pregion1");
+        PartitionedRegion pr1 = (PartitionedRegion) basicGetCache().getRegion("pregion1");
         LogWriterUtils.getLogWriter().info(
             " calling pr.getLocalSize " + pr1.getLocalSize());
         assertEquals(0, pr1.getLocalSize());
@@ -877,8 +877,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        Region rr1 = basicGetCache().getRegion("rregion1");
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {
@@ -907,7 +907,7 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable verifySize = new SerializableCallable("getOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
+        Region rr1 = basicGetCache().getRegion("rregion1");
         LogWriterUtils.getLogWriter()
             .info(" calling rr.getLocalSize " + rr1.size());
         assertEquals(3, rr1.size());
@@ -921,8 +921,8 @@ public class DistTXDebugDUnitTest extends CacheTestCase {
     SerializableCallable TxRollbackOps = new SerializableCallable("TxOps") {
       @Override
       public Object call() throws CacheException {
-        Region rr1 = cache.getRegion("rregion1");
-        CacheTransactionManager ctx = cache.getCacheTransactionManager();
+        Region rr1 = basicGetCache().getRegion("rregion1");
+        CacheTransactionManager ctx = basicGetCache().getCacheTransactionManager();
         ctx.setDistributed(true);
         ctx.begin();
         for (int i = 1; i <= 3; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXPersistentDebugDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXPersistentDebugDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXPersistentDebugDUnitTest.java
index 2cfeae7..80fad20 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXPersistentDebugDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/disttx/DistTXPersistentDebugDUnitTest.java
@@ -72,8 +72,8 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
   }
   
   public static void createPersistentPR(String regionName) {
-    assertNotNull(cache);
-    cache.createRegion(regionName, getPersistentPRAttributes(1, -1, cache, 113, true));
+    assertNotNull(basicGetCache());
+    basicGetCache().createRegion(regionName, getPersistentPRAttributes(1, -1, basicGetCache(), 113, true));
   }
   
   protected static RegionAttributes getPersistentPRAttributes(final int redundancy, final int recoveryDelay,
@@ -105,11 +105,11 @@ public class DistTXPersistentDebugDUnitTest extends DistTXDebugDUnitTest {
     SerializableCallable TxOps = new SerializableCallable() {
       @Override
       public Object call() throws Exception {
-        CacheTransactionManager mgr = cache.getCacheTransactionManager();
+        CacheTransactionManager mgr = basicGetCache().getCacheTransactionManager();
         mgr.setDistributed(true);
         LogWriterUtils.getLogWriter().fine("SJ:TX BEGIN");
         mgr.begin();
-        Region<CustId, Customer> prRegion = cache.getRegion(regionName);
+        Region<CustId, Customer> prRegion = basicGetCache().getRegion(regionName);
 
         CustId custIdOne = new CustId(1);
         Customer customerOne = new Customer("name1", "addr1");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptClientServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptClientServerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptClientServerDUnitTest.java
index fdf2a5b..5927289 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptClientServerDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptClientServerDUnitTest.java
@@ -218,7 +218,7 @@ public class InterruptClientServerDUnitTest extends CacheTestCase {
     return vm.invoke(new SerializableCallable() {
       @Override
       public Object call() throws Exception {
-        assertFalse(cache.isClosed());
+        assertFalse(basicGetCache().isClosed());
         Region<Object, Object> region = getCache().getRegion("region");
         return region.get(0);
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptsDUnitTest.java
index 6a0ffba..028d3fa 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/InterruptsDUnitTest.java
@@ -179,7 +179,7 @@ public class InterruptsDUnitTest extends CacheTestCase {
     return vm.invoke(new SerializableCallable() {
       @Override
       public Object call() throws Exception {
-        assertFalse(cache.isClosed());
+        assertFalse(basicGetCache().isClosed());
         Region<Object, Object> region = getCache().getRegion("region");
         return region.get(0);
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionAPIDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionAPIDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionAPIDUnitTest.java
index 466dfa4..a23baf6 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionAPIDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionAPIDUnitTest.java
@@ -16,12 +16,6 @@
  */
 package com.gemstone.gemfire.internal.cache;
 
-/**
- * This is a dunit test for PartitionedRegion creation and Region API's
- * functionality. This test is performed for different region scopes - D_ACK and
- * D_NO_ACK for PartitionedRegion.
- */
-
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.Properties;
@@ -51,8 +45,12 @@ import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
 
-public class PartitionedRegionAPIDUnitTest extends
-		PartitionedRegionDUnitTestCase {
+/**
+ * This is a dunit test for PartitionedRegion creation and Region API's
+ * functionality. This test is performed for different region scopes - D_ACK and
+ * D_NO_ACK for PartitionedRegion.
+ */
+public class PartitionedRegionAPIDUnitTest extends PartitionedRegionDUnitTestCase {
 
 	public PartitionedRegionAPIDUnitTest(String name) {
 		super(name);
@@ -1431,34 +1429,7 @@ public class PartitionedRegionAPIDUnitTest extends
 		});
 	}
 
-	protected CacheSerializableRunnable addExceptionTag1(final String expectedException) {
-	  CacheSerializableRunnable addExceptionTag = new CacheSerializableRunnable(
-	  "addExceptionTag") {
-	    public void run2()
-	    {
-	      getCache().getLogger().info(
-	          "<ExpectedException action=add>" + expectedException
-	          + "</ExpectedException>");
-	    }
-	  };
-	  
-	  return addExceptionTag;
-	}
-
-	protected CacheSerializableRunnable removeExceptionTag1(final String expectedException) {
-	  CacheSerializableRunnable removeExceptionTag = new CacheSerializableRunnable(
-	  "removeExceptionTag") {
-	    public void run2() throws CacheException {
-	      getCache().getLogger().info(
-	          "<ExpectedException action=remove>" + expectedException
-	          + "</ExpectedException>");
-	    }
-	  };
-	  return removeExceptionTag;
-	}
-
-        
-	public void testCacherLoaderHelper() throws Exception 
+	public void testCacherLoaderHelper() throws Exception
 	{
 	  final String rName = getUniqueName();
 	  Host host = Host.getHost(0);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java
index 79669b2..f59c832 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionBucketCreationDistributionDUnitTest.java
@@ -21,11 +21,14 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
+import java.util.Properties;
 import java.util.Set;
 
 import com.gemstone.gemfire.cache.AttributesFactory;
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheExistsException;
+import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.cache.MirrorType;
 import com.gemstone.gemfire.cache.PartitionAttributes;
 import com.gemstone.gemfire.cache.PartitionAttributesFactory;
@@ -34,6 +37,8 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionAttributes;
 import com.gemstone.gemfire.cache.Scope;
 import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore.BucketVisitor;
 import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.AsyncInvocation;
@@ -465,20 +470,70 @@ public class PartitionedRegionBucketCreationDistributionDUnitTest extends
    * redundancy-zone = "zone"
    */
   public void testEnforceUniqueHostForLonerDistributedSystem() {
-	  Cache cache = createLonerCacheWithEnforceUniqueHost();
-      
-	  AttributesFactory attr = new AttributesFactory();
+	  Cache myCache = createLonerCacheWithEnforceUniqueHost();
+    try {
+      AttributesFactory attr = new AttributesFactory();
       PartitionAttributesFactory paf = new PartitionAttributesFactory();
       PartitionAttributes prAttr = paf.create();
       attr.setPartitionAttributes(prAttr);
       RegionAttributes regionAttribs = attr.create();
-      Region region = cache.createRegion("PR1", regionAttribs);
-      
+      Region region = myCache.createRegion("PR1", regionAttribs);
+
       for (int i = 0; i < 113; i++) {
-    	region.put("Key_" + i, new Integer(i));
+        region.put("Key_" + i, new Integer(i));
       }
       //verify region size
       assertEquals(113, region.size());
+    } finally {
+      myCache.close();
+      myCache.getDistributedSystem().disconnect();
+    }
+  }
+
+  /**
+   * Creates the <code>Cache</code> for this test that is not connected
+   * to other members.
+   *
+   * <p>Used by test {@link #testEnforceUniqueHostForLonerDistributedSystem()}.
+   * Moved from DistributedTestCase to this test is the exclusive caller.
+   *
+   * <p>Added specifically to test scenario of defect #47181.
+   */
+  private final Cache createLonerCacheWithEnforceUniqueHost() {
+    Cache myCache = null;
+    try {
+      System.setProperty("gemfire.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE", "true");
+      myCache = CacheFactory.create(getLonerSystemWithEnforceUniqueHost());
+    } catch (CacheExistsException e) {
+      Assert.fail("the cache already exists", e);
+
+    } catch (RuntimeException ex) {
+      throw ex;
+
+    } catch (Exception ex) {
+      Assert.fail("Checked exception while initializing cache??", ex);
+    } finally {
+      System.clearProperty("gemfire.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE");
+    }
+    return myCache;
+  }
+
+  /**
+   * Returns a loner distributed system in combination with enforceUniqueHost
+   * and redundancyZone properties.
+   *
+   * <p>Used by test {@link #testEnforceUniqueHostForLonerDistributedSystem()}.
+   * Moved from DistributedTestCase to this test is the exclusive caller.
+   *
+   * <p>Added specifically to test scenario of defect #47181.
+   */
+  private final InternalDistributedSystem getLonerSystemWithEnforceUniqueHost() {
+    Properties props = getDistributedSystemProperties();
+    props.put(DistributionConfig.MCAST_PORT_NAME, "0");
+    props.put(DistributionConfig.LOCATORS_NAME, "");
+    props.put(DistributionConfig.ENFORCE_UNIQUE_HOST_NAME, "true");
+    props.put(DistributionConfig.REDUNDANCY_ZONE_NAME, "zone1");
+    return getSystem(props);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/LocalDataSetDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/LocalDataSetDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/LocalDataSetDUnitTest.java
index f55970f..96fc72c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/LocalDataSetDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/execute/LocalDataSetDUnitTest.java
@@ -103,7 +103,7 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
 
     SerializableCallable installHook = new SerializableCallable() {
       public Object call() throws Exception {
-        PartitionedRegion pr = (PartitionedRegion)cache.getRegion("CustomerPR");
+        PartitionedRegion pr = (PartitionedRegion)basicGetCache().getRegion("CustomerPR");
         Runnable r = new ReadHook();
         pr.getDataStore().setBucketReadHook(r);
         return null;
@@ -112,7 +112,7 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
     invokeInAllDataStores(installHook);
     accessor.invoke(new SerializableCallable() {
       public Object call() throws Exception {
-        Region region = cache.getRegion("CustomerPR");
+        Region region = basicGetCache().getRegion("CustomerPR");
         Set filter = new HashSet();
         filter.add("1");
         FunctionService.onRegion(region).withFilter(filter).execute(IterateFunction.id, true, false, true).getResult();
@@ -248,7 +248,7 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
   public void createCache() {
     try {
       getCache();
-      assertNotNull(cache);
+      assertNotNull(basicGetCache());
     }
     catch (Exception e) {
       Assert.fail("Failed while creating the cache", e);
@@ -299,10 +299,10 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
         .setPartitionResolver(new LDSPartitionResolver()).create();
     AttributesFactory attr = new AttributesFactory();
     attr.setPartitionAttributes(prAttr);
-    assertNotNull(cache);
+    assertNotNull(basicGetCache());
 
     if (partitionedRegionName.equals("CustomerPR")) {
-      customerPR = cache.createRegion(partitionedRegionName, attr.create());
+      customerPR = basicGetCache().createRegion(partitionedRegionName, attr.create());
       assertNotNull(customerPR);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region " + partitionedRegionName
@@ -310,7 +310,7 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
 
     }
     if (partitionedRegionName.equals("OrderPR")) {
-      orderPR = cache.createRegion(partitionedRegionName, attr.create());
+      orderPR = basicGetCache().createRegion(partitionedRegionName, attr.create());
       assertNotNull(orderPR);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region " + partitionedRegionName
@@ -319,7 +319,7 @@ public class LocalDataSetDUnitTest extends CacheTestCase {
     }
 
     if (partitionedRegionName.equals("ShipmentPR")) {
-      shipmentPR = cache.createRegion(partitionedRegionName, attr.create());
+      shipmentPR = basicGetCache().createRegion(partitionedRegionName, attr.create());
       assertNotNull(shipmentPR);
       LogWriterUtils.getLogWriter().info(
           "Partitioned Region " + partitionedRegionName

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HAConflationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HAConflationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HAConflationDUnitTest.java
index 7b23f91..8edefa6 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HAConflationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/ha/HAConflationDUnitTest.java
@@ -123,9 +123,9 @@ public class HAConflationDUnitTest extends CacheTestCase
   
   public static void closeCacheAndDisconnect()
   {
-    if (cache != null && !cache.isClosed()) {
-      cache.close();
-      cache.getDistributedSystem().disconnect();
+    if (basicGetCache() != null && !basicGetCache().isClosed()) {
+      basicGetCache().close();
+      basicGetCache().getDistributedSystem().disconnect();
     }
   }
 
@@ -212,11 +212,11 @@ public class HAConflationDUnitTest extends CacheTestCase
         "putFromServer") {
       public void run2() throws CacheException
       {
-        Region region = cache.getRegion(Region.SEPARATOR + regionName);
+        Region region = basicGetCache().getRegion(Region.SEPARATOR + regionName);
         assertNotNull(region);
-        cache.getLogger().info("starting put()");
+        basicGetCache().getLogger().info("starting put()");
         region.put(key, value);
-        cache.getLogger().info("finished put()");
+        basicGetCache().getLogger().info("finished put()");
       }
     };
 
@@ -229,10 +229,10 @@ public class HAConflationDUnitTest extends CacheTestCase
         "invalidateFromServer") {
       public void run2() throws CacheException
       {
-        Region region = cache.getRegion(Region.SEPARATOR + regionName);
+        Region region = basicGetCache().getRegion(Region.SEPARATOR + regionName);
         assertNotNull(region);
         region.invalidate(key);
-        cache.getLogger().info("done invalidate() successfully");
+        basicGetCache().getLogger().info("done invalidate() successfully");
 
       }
     };
@@ -246,10 +246,10 @@ public class HAConflationDUnitTest extends CacheTestCase
         "performDestroy") {
       public void run2() throws CacheException
       {
-        Region region = cache.getRegion(Region.SEPARATOR + regionName);
+        Region region = basicGetCache().getRegion(Region.SEPARATOR + regionName);
         assertNotNull(region);
         region.destroy(key);
-        cache.getLogger().info("done destroy successfully");
+        basicGetCache().getLogger().info("done destroy successfully");
 
       }
     };
@@ -302,8 +302,8 @@ public class HAConflationDUnitTest extends CacheTestCase
     assertNotNull(ds);
     ds.disconnect();
     ds = getSystem(props);
-    cache = CacheFactory.create(ds);
-    assertNotNull(cache);
+    getCache();
+    assertNotNull(basicGetCache());
   }
 
   public static void createClientCache(String host, Integer port1, Boolean isListenerPresent)
@@ -323,8 +323,8 @@ public class HAConflationDUnitTest extends CacheTestCase
       factory.setCacheListener(clientListener);
     }
     RegionAttributes attrs = factory.create();
-    cache.createRegion(regionName, attrs);
-    Region region = cache.getRegion(Region.SEPARATOR + regionName);
+    basicGetCache().createRegion(regionName, attrs);
+    Region region = basicGetCache().getRegion(Region.SEPARATOR + regionName);
     assertNotNull(region);
 
     region.registerInterest(KEY1);
@@ -349,8 +349,8 @@ public class HAConflationDUnitTest extends CacheTestCase
       factory.setCacheListener(serverListener);
     }
     RegionAttributes attrs = factory.create();
-    cache.createRegion(regionName, attrs);
-    CacheServerImpl server = (CacheServerImpl)cache.addCacheServer();
+    basicGetCache().createRegion(regionName, attrs);
+    CacheServerImpl server = (CacheServerImpl)basicGetCache().addCacheServer();
     assertNotNull(server);
     int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     server.setPort(port);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
index 65224e8..6ddbf0d 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
@@ -81,7 +81,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   private static final Set<String> testHistory = new LinkedHashSet<String>();
 
   /** This VM's connection to the distributed system */
-  public static InternalDistributedSystem system;
+  public static InternalDistributedSystem system; // TODO: make private
   private static Class lastSystemCreatedInTest;
   private static Properties lastSystemProperties;
   private static volatile String testMethodName;
@@ -89,13 +89,12 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   /** For formatting timing info */
   private static final DecimalFormat format = new DecimalFormat("###.###");
 
-  public static boolean reconnect = false;
+  public static boolean reconnect = false; // TODO: make private
 
-  public static final boolean logPerTest = Boolean.getBoolean("dunitLogPerTest");
+  public static final boolean logPerTest = Boolean.getBoolean("dunitLogPerTest"); // TODO: make private
 
   /**
-   * Creates a new <code>DistributedTestCase</code> test with the
-   * given name.
+   * Creates a new <code>DistributedTestCase</code> test with the given name.
    */
   public DistributedTestCase(final String name) {
     super(name);
@@ -105,25 +104,30 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   //---------------------------------------------------------------------------
   // methods for tests
   //---------------------------------------------------------------------------
-  
-  public final void setSystem(final Properties props, final DistributedSystem ds) { // TODO: override getDistributedSystemProperties and then delete
+
+  /**
+   * @deprecated Please override {@link #getDistributedSystemProperties()} instead.
+   */
+  @Deprecated
+  public final void setSystem(final Properties props, final DistributedSystem ds) { // TODO: delete
     system = (InternalDistributedSystem)ds;
     lastSystemProperties = props;
     lastSystemCreatedInTest = getClass(); // used to be getDeclaringClass()
   }
   
   /**
-   * Returns this VM's connection to the distributed system.  If
-   * necessary, the connection will be lazily created using the given
-   * <code>Properties</code>.  Note that this method uses hydra's
-   * configuration to determine the location of log files, etc.
-   * Note: "final" was removed so that WANTestBase can override this method.
+   * Returns this VM's connection to the distributed system.  If necessary, the
+   * connection will be lazily created using the given {@code Properties}.
+   *
+   * <p>Do not override this method. Override {@link #getDistributedSystemProperties()}
+   * instead.
+   *
+   * <p>Note: "final" was removed so that WANTestBase can override this method.
    * This was part of the xd offheap merge.
    *
-   * see hydra.DistributedConnectionMgr#connect
    * @since 3.0
    */
-  public /*final*/ InternalDistributedSystem getSystem(final Properties props) { // TODO: make final
+  public /*final*/ InternalDistributedSystem getSystem(final Properties props) { // TODO: restore final
     // Setting the default disk store name is now done in setUp
     if (system == null) {
       system = InternalDistributedSystem.getAnyInstance();
@@ -183,10 +187,12 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   }
 
   /**
-   * Returns this VM's connection to the distributed system.  If
-   * necessary, the connection will be lazily created using the
-   * <code>Properties</code> returned by {@link
-   * #getDistributedSystemProperties}.
+   * Returns this VM's connection to the distributed system.  If necessary, the
+   * connection will be lazily created using the {@code Properties} returned by
+   * {@link #getDistributedSystemProperties()}.
+   *
+   * <p>Do not override this method. Override {@link #getDistributedSystemProperties()}
+   * instead.
    *
    * @see #getSystem(Properties)
    *
@@ -197,8 +203,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   }
 
   /**
-   * Returns a loner distributed system that isn't connected to other
-   * vms
+   * Returns a loner distributed system that isn't connected to other vms.
    * 
    * @since 6.5
    */
@@ -210,33 +215,16 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   }
   
   /**
-   * Returns a loner distributed system in combination with enforceUniqueHost
-   * and redundancyZone properties.
-   * Added specifically to test scenario of defect #47181.
-   */
-  public final InternalDistributedSystem getLonerSystemWithEnforceUniqueHost() {
-    Properties props = getDistributedSystemProperties();
-    props.put(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.put(DistributionConfig.LOCATORS_NAME, "");
-    props.put(DistributionConfig.ENFORCE_UNIQUE_HOST_NAME, "true");
-    props.put(DistributionConfig.REDUNDANCY_ZONE_NAME, "zone1");
-    return getSystem(props);
-  }
-
-  /**
-   * Returns whether or this VM is connected to a {@link
-   * DistributedSystem}.
+   * Returns whether or this VM is connected to a {@link DistributedSystem}.
    */
   public final boolean isConnectedToDS() {
     return system != null && system.isConnected();
   }
 
   /**
-   * Returns a <code>Properties</code> object used to configure a
-   * connection to a {@link
-   * com.gemstone.gemfire.distributed.DistributedSystem}.
-   * Unless overridden, this method will return an empty
-   * <code>Properties</code> object.
+   * Returns a {@code Properties} object used to configure a connection to a
+   * {@link DistributedSystem}. Unless overridden, this method will return an
+   * empty {@code Properties} object.
    *
    * @since 3.0
    */
@@ -244,7 +232,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     return new Properties();
   }
 
-  public static void disconnectAllFromDS() {
+  public static final void disconnectAllFromDS() {
     disconnectFromDS();
     Invoke.invokeInEveryVM(()->disconnectFromDS());
   }
@@ -252,7 +240,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   /**
    * Disconnects this VM from the distributed system
    */
-  public static void disconnectFromDS() {
+  public static final void disconnectFromDS() {
     setTestMethodName(null);
     GemFireCacheImpl.testCacheXml = null;
     if (system != null) {
@@ -282,11 +270,11 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   // name methods
   //---------------------------------------------------------------------------
   
-  public static String getTestMethodName() {
+  public static final String getTestMethodName() {
     return testMethodName;
   }
 
-  public static void setTestMethodName(final String testMethodName) { // TODO: delete
+  public static final void setTestMethodName(final String testMethodName) { // TODO: delete
     DistributedTestCase.testMethodName = testMethodName;
   }
   
@@ -294,35 +282,35 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
    * Returns a unique name for this test method.  It is based on the
    * name of the class as well as the name of the method.
    */
-  public String getUniqueName() {
+  public final String getUniqueName() {
     return getClass().getSimpleName() + "_" + getName();
   }
 
   //---------------------------------------------------------------------------
   // setup methods
   //---------------------------------------------------------------------------
-  
+
   /**
    * Sets up the DistributedTestCase.
-   * <p>
-   * Do not override this method. Override {@link #preSetUp()} with work that
+   *
+   * <p> Do not override this method. Override {@link #preSetUp()} with work that
    * needs to occur before setUp() or override {@link #postSetUp()} with work
    * that needs to occur after setUp().
    */
   @Override
-  public void setUp() throws Exception {
+  public void setUp() throws Exception { // TODO: make final and force subclasses to override template methods
     preSetUp();
     setUpDistributedTestCase();
     postSetUp();
   }
-  
+
   /**
    * Sets up DistributedTest in controller and remote VMs. This includes the
-   * defining the test name, setting the default disk store name, logging the 
+   * defining the test name, setting the default disk store name, logging the
    * test history, and capturing a creation stack for detecting the source of
    * incompatible DistributedSystem connections.
-   * <p>
-   * Do not override this method.
+   *
+   * <p>Do not override this method.
    */
   private final void setUpDistributedTestCase() {
     final String className = getClass().getCanonicalName();
@@ -344,37 +332,37 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
   }
 
   /**
-   * <code>preSetUp()</code> is invoked before {@link #setUpDistributedTestCase()}.
-   * <p>
-   * Override this as needed. Default implementation is empty.
+   * {@code preSetUp()} is invoked before {@link #setUpDistributedTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
    */
   protected void preSetUp() throws Exception {
   }
-  
+
   /**
-   * <code>postSetUp()</code> is invoked after {@link #setUpDistributedTestCase()}.
-   * <p>
-   * Override this as needed. Default implementation is empty.
+   * {@code postSetUp()} is invoked after {@link #setUpDistributedTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
    */
   protected void postSetUp() throws Exception {
   }
   
-  private static String getDefaultDiskStoreName(final int hostIndex, final int vmIndex, final String className, final String methodName) {
+  private static final String getDefaultDiskStoreName(final int hostIndex, final int vmIndex, final String className, final String methodName) {
     return "DiskStore-" + String.valueOf(hostIndex) + "-" + String.valueOf(vmIndex) + "-" + className + "." + methodName; // used to be getDeclaringClass()
   }
   
-  private static void setUpVM(final String methodName, final String defaultDiskStoreName) {
+  private static final void setUpVM(final String methodName, final String defaultDiskStoreName) {
     setTestMethodName(methodName);
     GemFireCacheImpl.setDefaultDiskStoreName(defaultDiskStoreName);
     System.setProperty(HoplogConfig.ALLOW_LOCAL_HDFS_PROP, "true");    
     setUpCreationStackGenerator();
   }
 
-  private void logTestStart() {
+  private final void logTestStart() {
     System.out.println("\n\n[setup] START TEST " + getClass().getSimpleName()+"."+testMethodName+"\n\n");
   }
   
-  private static void setUpCreationStackGenerator() {
+  private static final void setUpCreationStackGenerator() {
     // the following is moved from InternalDistributedSystem to fix #51058
     InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(
     new CreationStackGenerator() {
@@ -405,7 +393,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
    * Write a message to the log about what tests have ran previously. This
    * makes it easier to figure out if a previous test may have caused problems
    */
-  private void logTestHistory() {
+  private final void logTestHistory() {
     String classname = getClass().getSimpleName();
     testHistory.add(classname);
     System.out.println("Previously run tests: " + testHistory);
@@ -417,8 +405,8 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
 
   /**
    * Tears down the DistributedTestCase.
-   * <p>
-   * Do not override this method. Override {@link #preTearDown()} with work that
+   *
+   * <p>Do not override this method. Override {@link #preTearDown()} with work that
    * needs to occur before tearDown() or override {@link #postTearDown()} with work
    * that needs to occur after tearDown().
    */
@@ -437,24 +425,24 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     }
     cleanupAllVms();
   }
-  
+
   /**
-   * <code>preTearDown()</code> is invoked before {@link #tearDownDistributedTestCase()}.
-   * <p>
-   * Override this as needed. Default implementation is empty.
+   * {@code preTearDown()} is invoked before {@link #tearDownDistributedTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
    */
   protected void preTearDown() throws Exception {
   }
-  
+
   /**
-   * <code>postTearDown()</code> is invoked after {@link #tearDownDistributedTestCase()}.
-   * <p>
-   * Override this as needed. Default implementation is empty.
+   * {@code postTearDown()} is invoked after {@link #tearDownDistributedTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
    */
   protected void postTearDown() throws Exception {
   }
   
-  public static void cleanupAllVms() { // TODO: make private
+  private static final void cleanupAllVms() {
     tearDownVM();
     Invoke.invokeInEveryVM(()->tearDownVM());
     Invoke.invokeInLocator(()->{
@@ -464,7 +452,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     DUnitLauncher.closeAndCheckForSuspects();
   }
 
-  private static void tearDownVM() {
+  private static final void tearDownVM() {
     closeCache();
 
     // keep alphabetized to detect duplicate lines
@@ -499,7 +487,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     IgnoredException.removeAllExpectedExceptions();
   }
 
-  private static void closeCache() {
+  private static final void closeCache() { // TODO: this should move to CacheTestCase
     GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
     if (cache != null && !cache.isClosed()) {
       destroyRegions(cache);
@@ -507,7 +495,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     }
   }
   
-  protected static final void destroyRegions(final Cache cache) { // TODO: make private
+  protected static final void destroyRegions(final Cache cache) { // TODO: this should move to CacheTestCase
     if (cache != null && !cache.isClosed()) {
       // try to destroy the root regions first so that we clean up any persistent files.
       for (Iterator itr = cache.rootRegions().iterator(); itr.hasNext();) {
@@ -526,7 +514,7 @@ public abstract class DistributedTestCase extends TestCase implements java.io.Se
     }
   }
   
-  private static void tearDownCreationStackGenerator() {
+  private static final void tearDownCreationStackGenerator() {
     InternalDistributedSystem.TEST_CREATION_STACK_GENERATOR.set(InternalDistributedSystem.DEFAULT_CREATION_STACK_GENERATOR);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/CacheTestFixture.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/CacheTestFixture.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/CacheTestFixture.java
new file mode 100644
index 0000000..6f33fd9
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/CacheTestFixture.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.cache.internal;
+
+import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
+
+/**
+ * Defines the {@code CacheTestCase} methods that can be overridden by its subclasses.
+ */
+public interface CacheTestFixture {
+
+  /**
+   * {@code preTearDownCacheTestCase()} is invoked before {@code CacheTestCase#tearDownCacheTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
+   */
+  public void preTearDownCacheTestCase() throws Exception;
+
+  /**
+   * {@code postTearDownCacheTestCase()} is invoked after {@code CacheTestCase#tearDownCacheTestCase()}.
+   *
+   * <p>Override this as needed. Default implementation is empty.
+   */
+  public void postTearDownCacheTestCase() throws Exception;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/ce38338e/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java
new file mode 100644
index 0000000..ea827c6
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/cache/internal/JUnit3CacheTestCase.java
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.dunit.cache.internal;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Map;
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheException;
+import com.gemstone.gemfire.cache.CacheExistsException;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheTransactionManager;
+import com.gemstone.gemfire.cache.ExpirationAttributes;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.RegionExistsException;
+import com.gemstone.gemfire.cache.TimeoutException;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache30.CacheSerializableRunnable;
+import com.gemstone.gemfire.distributed.internal.DistributionMessageObserver;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.FileUtil;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.InternalRegionArguments;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+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.VM;
+import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit3DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * The abstract superclass of tests that require the creation of a
+ * {@link Cache}.
+ */
+public abstract class JUnit3CacheTestCase extends JUnit3DistributedTestCase implements CacheTestFixture {
+
+  private final JUnit4CacheTestCase delegate = new JUnit4CacheTestCase(this);
+
+//  private static final Logger logger = LogService.getLogger();
+//
+//  /** The Cache from which regions are obtained
+//   *
+//   * All references synchronized via <code>JUnit3CacheTestCase.class</code>
+//   * */
+//  // static so it doesn't get serialized with SerializableRunnable inner classes
+//  protected static Cache cache;
+
+  public JUnit3CacheTestCase(final String name) {
+    super(name);
+  }
+
+  /**
+   * Creates the <code>Cache</code> for this test that is not connected
+   * to other members
+   */
+  public final Cache createLonerCache() {
+    return delegate.createLonerCache();
+  }
+
+  /**
+   * Sets this test up with a CacheCreation as its cache.
+   * Any existing cache is closed. Whoever calls this must also call finishCacheXml
+   */
+  public static final synchronized void beginCacheXml() {
+    JUnit4CacheTestCase.beginCacheXml();
+  }
+
+  /**
+   * Finish what beginCacheXml started. It does this be generating a cache.xml
+   * file and then creating a real cache using that cache.xml.
+   */
+  public final void finishCacheXml(final String name) {
+    delegate.finishCacheXml(name);
+  }
+
+  /**
+   * Finish what beginCacheXml started. It does this be generating a cache.xml
+   * file and then creating a real cache using that cache.xml.
+   */
+  public final void finishCacheXml(final String name, final boolean useSchema, final String xmlVersion) {
+    delegate.finishCacheXml(name, useSchema, xmlVersion);
+  }
+
+  /**
+   * Return a cache for obtaining regions, created lazily.
+   */
+  public final Cache getCache() {
+    return delegate.getCache();
+  }
+
+  public final Cache getCache(final CacheFactory factory) {
+    return delegate.getCache(factory);
+  }
+
+  public final Cache getCache(final boolean client) {
+    return delegate.getCache(client);
+  }
+
+  public final Cache getCache(final boolean client, final CacheFactory factory) {
+    return delegate.getCache(client, factory);
+  }
+
+  /**
+   * creates a client cache from the factory if one does not already exist
+   * @since 6.5
+   */
+  public final ClientCache getClientCache(final ClientCacheFactory factory) {
+    return delegate.getClientCache(factory);
+  }
+
+  /**
+   * same as {@link #getCache()} but with casting
+   */
+  public final GemFireCacheImpl getGemfireCache() { // TODO: remove?
+    return delegate.getGemfireCache();
+  }
+
+  public static synchronized final boolean hasCache() {
+    return JUnit4CacheTestCase.hasCache();
+  }
+
+  /**
+   * Return current cache without creating one.
+   */
+  public static synchronized final Cache basicGetCache() {
+    return JUnit4CacheTestCase.basicGetCache();
+  }
+
+  public static synchronized final void disconnectFromDS() {
+    JUnit4CacheTestCase.disconnectFromDS();
+  }
+
+  /** Close the cache */
+  public static synchronized final void closeCache() {
+    JUnit4CacheTestCase.closeCache();
+  }
+
+  /** Closed the cache in all VMs. */
+  protected final void closeAllCache() {
+    delegate.closeAllCache();
+  }
+
+  @Override
+  public final void preTearDown() throws Exception {
+    delegate.preTearDown();
+  }
+
+  @Override
+  public void preTearDownCacheTestCase() throws Exception {
+  }
+
+  @Override
+  public void postTearDownCacheTestCase() throws Exception {
+  }
+
+  /**
+   * Local destroy all root regions and close the cache.
+   */
+  protected final synchronized static void remoteTearDown() {
+    JUnit4CacheTestCase.remoteTearDown();
+  }
+
+  /**
+   * Returns a region with the given name and attributes
+   */
+  public final Region createRegion(final String name, final RegionAttributes attributes) throws CacheException {
+    return delegate.createRegion(name, attributes);
+  }
+
+  /**
+   * Provide any internal region arguments, typically required when internal
+   * use (aka meta-data) regions are needed.
+   *
+   * @return internal arguments, which may be null.  If null, then default
+   *         InternalRegionArguments are used to construct the Region
+   */
+  public final InternalRegionArguments getInternalRegionArguments() {
+    return delegate.getInternalRegionArguments();
+  }
+
+  public final Region createRegion(final String name, final String rootName, final RegionAttributes attributes) throws CacheException {
+    return delegate.createRegion(name, rootName, attributes);
+  }
+
+  public final Region getRootRegion() {
+    return delegate.getRootRegion();
+  }
+
+  public final Region getRootRegion(final String rootName) {
+    return delegate.getRootRegion(rootName);
+  }
+
+  protected final Region createRootRegion(final RegionAttributes attributes) throws RegionExistsException, TimeoutException {
+    return delegate.createRootRegion(attributes);
+  }
+
+  public final Region createRootRegion(final String rootName, final RegionAttributes attributes) throws RegionExistsException, TimeoutException {
+    return delegate.createRootRegion(rootName, attributes);
+  }
+
+  public final Region createExpiryRootRegion(final String rootName, final RegionAttributes attributes) throws RegionExistsException, TimeoutException {
+    return delegate.createExpiryRootRegion(rootName, attributes);
+  }
+
+  /**
+   * @deprecated Please use {@link IgnoredException#addIgnoredException(String)} instead.
+   */
+  @Deprecated
+  public CacheSerializableRunnable addExceptionTag1(final String exceptionStringToIgnore) {
+    return delegate.addExceptionTag1(exceptionStringToIgnore);
+  }
+
+  /**
+   * @deprecated Please use {@link IgnoredException#remove()} instead.
+   */
+  @Deprecated
+  public CacheSerializableRunnable removeExceptionTag1(final String exceptionStringToIgnore) {
+    return delegate.removeExceptionTag1(exceptionStringToIgnore);
+  }
+
+  public static final File getDiskDir() {
+    return JUnit4CacheTestCase.getDiskDir();
+  }
+
+  /**
+   * Return a set of disk directories
+   * for persistence tests. These directories
+   * will be automatically cleaned up
+   * on test case closure.
+   */
+  public static final File[] getDiskDirs() {
+    return JUnit4CacheTestCase.getDiskDirs();
+  }
+
+  public static final void cleanDiskDirs() throws IOException {
+    JUnit4CacheTestCase.cleanDiskDirs();
+  }
+}