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 2018/03/01 17:30:57 UTC

[geode] branch develop updated: GEODE-4734: cleanup tests for use as examples in Geode wiki (#1518)

This is an automated email from the ASF dual-hosted git repository.

klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new ce0251d  GEODE-4734: cleanup tests for use as examples in Geode wiki (#1518)
ce0251d is described below

commit ce0251dd40a48f35dc869126aebe0136e0e9108a
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu Mar 1 09:30:54 2018 -0800

    GEODE-4734: cleanup tests for use as examples in Geode wiki (#1518)
---
 .../CreateAndLocalDestroyInTXRegressionTest.java   | 154 +++++++++++++++
 .../PRCacheListenerDistributedTest.java}           |  18 +-
 ...tenerWithInterestPolicyAllDistributedTest.java} |  24 +--
 .../PRCreationTotalNumBucketsDistributedTest.java  |  56 +++---
 .../cache/RegionExpirationIntegrationTest.java     |   2 +-
 .../ReplicateCacheListenerDistributedTest.java}    |  87 ++++-----
 .../CreateAndLocalDestroyInTXRegressionTest.java   | 167 ----------------
 .../EntriesDoNotExpireDuringGIIRegressionTest.java | 210 ---------------------
 .../EntriesDoNotExpireDuringGiiRegressionTest.java | 182 ++++++++++++++++++
 ...a => PREntryIdleExpirationDistributedTest.java} |   3 +-
 ... => PartitionedRegionCloseDistributedTest.java} |  21 ++-
 ...plicateEntryIdleExpirationDistributedTest.java} |   2 +-
 .../ClientFunctionTimeoutRegressionTest.java       | 202 +++++++++++---------
 .../FunctionExecution_ExceptionDUnitTest.java      |   2 +-
 .../BucketRebalanceStatRegressionTest.java         | 178 +++++++++--------
 ...va => ClientProxyWithDeltaDistributedTest.java} |  26 +--
 ...ClientWithInterestFailoverDistributedTest.java} |   9 +-
 ...sterInterestServerMetaDataDistributedTest.java} |   4 +-
 ...chiveWithMissingResourceTypeRegressionTest.java |  22 ++-
 ...ServerBridgeClientMembershipRegressionTest.java |  24 +--
 .../test/java/org/apache/geode/test/dunit/VM.java  | 114 +++++------
 .../apache/geode/test/dunit/rules/CacheRule.java   |  49 ++---
 .../GatewayLegacyAuthenticationRegressionTest.java | 179 +++++++++---------
 23 files changed, 863 insertions(+), 872 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java
new file mode 100644
index 0000000..e0cd355
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/cache/CreateAndLocalDestroyInTXRegressionTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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 org.apache.geode.cache;
+
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE_PROXY;
+import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION;
+import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.io.Serializable;
+import java.util.function.Consumer;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+
+import org.apache.geode.cache.Region.Entry;
+import org.apache.geode.i18n.StringId;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
+
+/**
+ * Create and LocalDestroy/LocalInvalidate should create event with NewValue
+ *
+ * <p>
+ * TRAC #34387: TX in Proxy Regions with create followed by localDestroy on same key results in
+ * remote VMs receiving create events with null getNewValue().
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+@RunWith(JUnitParamsRunner.class)
+@SuppressWarnings("serial")
+public class CreateAndLocalDestroyInTXRegressionTest implements Serializable {
+
+  private static final String REGION_NAME = "r1";
+  private static final String KEY = "createKey";
+  private static final String VALUE = "createValue";
+
+  private transient CacheListener<String, String> spyCacheListener;
+
+  private VM otherVM;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = new CacheRule();
+
+  @Rule
+  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
+
+  @Before
+  public void setUp() throws Exception {
+    otherVM = getHost(0).getVM(0);
+    spyCacheListener = mock(CacheListener.class);
+
+    otherVM.invoke(() -> {
+      RegionFactory<String, String> regionFactory =
+          cacheRule.getOrCreateCache().createRegionFactory(REPLICATE_PROXY);
+      regionFactory.create(REGION_NAME);
+    });
+
+    RegionFactory<String, String> regionFactory =
+        cacheRule.getOrCreateCache().createRegionFactory(REPLICATE);
+    regionFactory.addCacheListener(spyCacheListener);
+    regionFactory.create(REGION_NAME);
+  }
+
+  @Test
+  @Parameters({"LOCAL_DESTROY", "LOCAL_INVALIDATE"})
+  @TestCaseName("{method}({params})")
+  public void createAndLocalOpShouldCreateEventWithNewValue(final LocalOperation operation) {
+    otherVM.invoke(() -> {
+      CacheTransactionManager transactionManager =
+          cacheRule.getCache().getCacheTransactionManager();
+      Region<String, String> region = cacheRule.getCache().getRegion(REGION_NAME);
+
+      transactionManager.begin();
+      try {
+        region.create(KEY, VALUE);
+
+        assertThatThrownBy(() -> operation.invoke(region))
+            .isInstanceOf(UnsupportedOperationInTransactionException.class)
+            .hasMessage(operation.getMessage());
+      } finally {
+        transactionManager.commit();
+      }
+    });
+
+    Region<String, String> region = cacheRule.getCache().getRegion(REGION_NAME);
+    Entry<String, String> entry = region.getEntry(KEY);
+
+    assertThat(entry.getValue()).isEqualTo(VALUE);
+
+    ArgumentCaptor<EntryEvent<String, String>> argument = ArgumentCaptor.forClass(EntryEvent.class);
+    verify(spyCacheListener, times(1)).afterCreate(argument.capture());
+
+    EntryEvent<String, String> event = argument.getValue();
+    assertThat(event.getKey()).isEqualTo(KEY);
+    assertThat(event.getNewValue()).isEqualTo(VALUE);
+  }
+
+  private enum LocalOperation {
+    LOCAL_DESTROY((region) -> region.localDestroy(KEY),
+        TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION),
+    LOCAL_INVALIDATE((region) -> region.localInvalidate(KEY),
+        TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION);
+
+    private final Consumer<Region<String, String>> strategy;
+    private final StringId stringId;
+
+    LocalOperation(final Consumer<Region<String, String>> strategy, final StringId stringId) {
+      this.strategy = strategy;
+      this.stringId = stringId;
+    }
+
+    void invoke(final Region<String, String> region) {
+      strategy.accept(region);
+    }
+
+    String getMessage() {
+      return stringId.toLocalizedString();
+    }
+  }
+}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerInvocationTest.java b/geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerDistributedTest.java
similarity index 77%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerInvocationTest.java
rename to geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerDistributedTest.java
index cf103bc..5c0cb96 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerInvocationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerDistributedTest.java
@@ -12,7 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.internal.cache;
+package org.apache.geode.cache;
 
 import java.util.Arrays;
 
@@ -21,12 +21,8 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
 
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
 
@@ -40,9 +36,9 @@ import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactor
  */
 @Category(DistributedTest.class)
 @RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+@UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
 @SuppressWarnings("serial")
-public class PRCacheListenerInvocationTest extends ReplicateCacheListenerInvocationTest {
+public class PRCacheListenerDistributedTest extends ReplicateCacheListenerDistributedTest {
 
   @Parameters(name = "{index}: redundancy={0}")
   public static Iterable<Integer> data() {
@@ -55,13 +51,13 @@ public class PRCacheListenerInvocationTest extends ReplicateCacheListenerInvocat
   @Override
   protected Region<String, Integer> createRegion(final String name,
       final CacheListener<String, Integer> listener) {
-    PartitionAttributesFactory partitionFactory = new PartitionAttributesFactory();
-    partitionFactory.setRedundantCopies(redundancy);
+    PartitionAttributesFactory<String, Integer> paf = new PartitionAttributesFactory<>();
+    paf.setRedundantCopies(redundancy);
 
     RegionFactory<String, Integer> regionFactory = cacheRule.getCache().createRegionFactory();
     regionFactory.addCacheListener(listener);
     regionFactory.setDataPolicy(DataPolicy.PARTITION);
-    regionFactory.setPartitionAttributes(partitionFactory.create());
+    regionFactory.setPartitionAttributes(paf.create());
 
     return regionFactory.create(name);
   }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerWithInterestPolicyAllInvocationTest.java b/geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerWithInterestPolicyAllDistributedTest.java
similarity index 70%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerWithInterestPolicyAllInvocationTest.java
rename to geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerWithInterestPolicyAllDistributedTest.java
index c69b7c4..9a50619 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCacheListenerWithInterestPolicyAllInvocationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/PRCacheListenerWithInterestPolicyAllDistributedTest.java
@@ -12,7 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.internal.cache;
+package org.apache.geode.cache;
 
 import java.util.Arrays;
 
@@ -21,19 +21,13 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 import org.junit.runners.Parameterized.Parameters;
+import org.junit.runners.Parameterized.UseParametersRunnerFactory;
 
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.InterestPolicy;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.SubscriptionAttributes;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
 
 /**
- * This class tests event triggering and handling in partitioned regions.
+ * Verifies behavior of CacheListener with InterestPolicy.ALL for Partitioned region.
  *
  * <p>
  * Converted from JUnit 3.
@@ -42,10 +36,10 @@ import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactor
  */
 @Category(DistributedTest.class)
 @RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+@UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
 @SuppressWarnings("serial")
-public class PRCacheListenerWithInterestPolicyAllInvocationTest
-    extends ReplicateCacheListenerInvocationTest {
+public class PRCacheListenerWithInterestPolicyAllDistributedTest
+    extends ReplicateCacheListenerDistributedTest {
 
   @Parameters(name = "{index}: redundancy={0}")
   public static Iterable<Integer> data() {
@@ -58,13 +52,13 @@ public class PRCacheListenerWithInterestPolicyAllInvocationTest
   @Override
   protected Region<String, Integer> createRegion(final String name,
       final CacheListener<String, Integer> listener) {
-    PartitionAttributesFactory partitionFactory = new PartitionAttributesFactory();
-    partitionFactory.setRedundantCopies(redundancy);
+    PartitionAttributesFactory<String, Integer> paf = new PartitionAttributesFactory<>();
+    paf.setRedundantCopies(redundancy);
 
     RegionFactory<String, Integer> regionFactory = cacheRule.getCache().createRegionFactory();
     regionFactory.addCacheListener(listener);
     regionFactory.setDataPolicy(DataPolicy.PARTITION);
-    regionFactory.setPartitionAttributes(partitionFactory.create());
+    regionFactory.setPartitionAttributes(paf.create());
     regionFactory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
 
     return regionFactory.create(name);
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCreationTotalNumBucketsDistributedTest.java b/geode-core/src/test/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
similarity index 66%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/PRCreationTotalNumBucketsDistributedTest.java
rename to geode-core/src/test/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
index 46ac37a..f73b8f2 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PRCreationTotalNumBucketsDistributedTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/PRCreationTotalNumBucketsDistributedTest.java
@@ -12,7 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.internal.cache;
+package org.apache.geode.cache;
 
 import static org.apache.geode.cache.PartitionAttributesFactory.GLOBAL_MAX_BUCKETS_DEFAULT;
 import static org.apache.geode.cache.PartitionAttributesFactory.GLOBAL_MAX_BUCKETS_PROPERTY;
@@ -31,9 +31,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.internal.cache.PartitionedRegion;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.rules.CacheRule;
@@ -41,6 +39,7 @@ import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
+@SuppressWarnings("serial")
 public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
 
   private VM vm0;
@@ -64,24 +63,24 @@ public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
   @Test
   public void testSetTotalNumBuckets() throws Exception {
     vm0.invoke(() -> {
-      Cache cache = cacheRule.createCache();
+      Cache cache = cacheRule.getOrCreateCache();
 
-      RegionFactory regionFactory = cache.createRegionFactory(PARTITION);
+      RegionFactory<String, String> regionFactory = cache.createRegionFactory(PARTITION);
       regionFactory.create("PR1");
 
-      PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
-      partitionAttributesFactory.setTotalNumBuckets(totalNumBuckets);
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
+      paf.setTotalNumBuckets(totalNumBuckets);
+      regionFactory.setPartitionAttributes(paf.create());
       regionFactory.create("PR2");
     });
 
     vm1.invoke(() -> {
-      Cache cache = cacheRule.createCache();
+      Cache cache = cacheRule.getOrCreateCache();
 
-      PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
-      partitionAttributesFactory.setLocalMaxMemory(0);
-      RegionFactory regionFactory = cache.createRegionFactory(PARTITION);
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
+      paf.setLocalMaxMemory(0);
+      RegionFactory<String, String> regionFactory = cache.createRegionFactory(PARTITION);
+      regionFactory.setPartitionAttributes(paf.create());
       PartitionedRegion accessor = (PartitionedRegion) regionFactory.create("PR1");
 
       assertThat(accessor.getTotalNumberOfBuckets()).isEqualTo(GLOBAL_MAX_BUCKETS_DEFAULT);
@@ -91,32 +90,35 @@ public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
             .isInstanceOf(IllegalStateException.class);
       }
 
-      partitionAttributesFactory.setTotalNumBuckets(totalNumBuckets);
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      paf.setTotalNumBuckets(totalNumBuckets);
+      regionFactory.setPartitionAttributes(paf.create());
       accessor = (PartitionedRegion) regionFactory.create("PR2");
 
       assertThat(accessor.getTotalNumberOfBuckets()).isEqualTo(totalNumBuckets);
     });
   }
 
+  /**
+   * Tests {@link PartitionAttributesFactory#setGlobalProperties(Properties)} which is deprecated.
+   */
   @Test
   public void testSetGlobalProperties() throws Exception {
     vm0.invoke(() -> {
-      Cache cache = cacheRule.createCache();
+      Cache cache = cacheRule.getOrCreateCache();
 
-      RegionFactory regionFactory = cache.createRegionFactory(PARTITION);
-      PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
-      partitionAttributesFactory.setTotalNumBuckets(totalNumBuckets);
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      RegionFactory<String, String> regionFactory = cache.createRegionFactory(PARTITION);
+      PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
+      paf.setTotalNumBuckets(totalNumBuckets);
+      regionFactory.setPartitionAttributes(paf.create());
       regionFactory.create("PR1");
     });
 
     vm1.invoke(() -> {
-      Cache cache = cacheRule.createCache();
+      Cache cache = cacheRule.getOrCreateCache();
 
-      RegionFactory regionFactory = cache.createRegionFactory(PARTITION);
-      PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      RegionFactory<String, String> regionFactory = cache.createRegionFactory(PARTITION);
+      PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
+      regionFactory.setPartitionAttributes(paf.create());
 
       try (IgnoredException ie = addIgnoredException(IllegalStateException.class)) {
         assertThatThrownBy(() -> regionFactory.create("PR1"))
@@ -125,8 +127,8 @@ public class PRCreationTotalNumBucketsDistributedTest implements Serializable {
 
       Properties globalProperties = new Properties();
       globalProperties.setProperty(GLOBAL_MAX_BUCKETS_PROPERTY, "" + totalNumBuckets);
-      partitionAttributesFactory.setGlobalProperties(globalProperties);
-      regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
+      paf.setGlobalProperties(globalProperties);
+      regionFactory.setPartitionAttributes(paf.create());
       PartitionedRegion accessor = (PartitionedRegion) regionFactory.create("PR1");
 
       assertThat(accessor.getTotalNumberOfBuckets()).isEqualTo(totalNumBuckets);
diff --git a/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
index 9d2cda2..89c2114 100644
--- a/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/RegionExpirationIntegrationTest.java
@@ -55,7 +55,7 @@ public class RegionExpirationIntegrationTest {
 
   @Before
   public void setUp() {
-    regionName = getClass().getSimpleName() + "_" + testName.getMethodName();
+    regionName = testName.getMethodName() + "_Region";
     spyCacheListener = mock(CacheListener.class);
 
     cache = new CacheFactory().set(LOCATORS, "").set(MCAST_PORT, "0").create();
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateCacheListenerInvocationTest.java b/geode-core/src/test/java/org/apache/geode/cache/ReplicateCacheListenerDistributedTest.java
similarity index 76%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateCacheListenerInvocationTest.java
rename to geode-core/src/test/java/org/apache/geode/cache/ReplicateCacheListenerDistributedTest.java
index 32d567b..6f5268f 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateCacheListenerInvocationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/cache/ReplicateCacheListenerDistributedTest.java
@@ -12,7 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.internal.cache;
+package org.apache.geode.cache;
 
 import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -24,23 +24,13 @@ import static org.hamcrest.Matchers.nullValue;
 
 import java.io.Serializable;
 
-import org.apache.logging.log4j.Logger;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.Operation;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionEvent;
-import org.apache.geode.cache.RegionFactory;
-import org.apache.geode.cache.Scope;
 import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.test.dunit.rules.CacheRule;
 import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.dunit.rules.SharedCountersRule;
@@ -49,8 +39,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
 
 /**
- * Registers a {@code CacheListener} in the Controller and all DUnit VMs. Verifies
- * {@code CacheListener} invocations for {@code Region} operations.
+ * Verifies {@code CacheListener} invocations for {@code Region} operations in multiple members.
  *
  * <p>
  * Converted from JUnit 3.
@@ -59,20 +48,19 @@ import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
  */
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class ReplicateCacheListenerInvocationTest implements Serializable {
-
-  private static final Logger logger = LogService.getLogger();
-
-  protected static final int ENTRY_VALUE = 0;
-  protected static final int UPDATED_ENTRY_VALUE = 1;
+public class ReplicateCacheListenerDistributedTest implements Serializable {
 
   private static final String CREATES = "CREATES";
   private static final String UPDATES = "UPDATES";
   private static final String INVALIDATES = "INVALIDATES";
   private static final String DESTROYS = "DESTROYS";
 
-  protected String regionName;
-  private String key;
+  private static final int ENTRY_VALUE = 0;
+  private static final int UPDATED_ENTRY_VALUE = 1;
+
+  private static final String KEY = "key-1";
+
+  private String regionName;
 
   @ClassRule
   public static DistributedTestRule distributedTestRule = new DistributedTestRule();
@@ -92,7 +80,6 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
   @Before
   public void setUp() throws Exception {
     regionName = getClass().getSimpleName();
-    key = "key-1";
 
     sharedCountersRule.initialize(CREATES);
     sharedCountersRule.initialize(DESTROYS);
@@ -110,7 +97,7 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
       });
     }
 
-    region.put(key, ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
+    region.put(KEY, ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
 
     assertThat(sharedCountersRule.getTotal(CREATES)).isEqualTo(expectedCreates());
   }
@@ -125,8 +112,8 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
       });
     }
 
-    region.put(key, ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
-    region.put(key, UPDATED_ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
+    region.put(KEY, ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
+    region.put(KEY, UPDATED_ENTRY_VALUE, cacheRule.getSystem().getDistributedMember());
 
     assertThat(sharedCountersRule.getTotal(UPDATES)).isEqualTo(expectedUpdates());
   }
@@ -141,11 +128,11 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
       });
     }
 
-    region.put(key, 0, cacheRule.getSystem().getDistributedMember());
-    region.invalidate(key);
+    region.put(KEY, 0, cacheRule.getSystem().getDistributedMember());
+    region.invalidate(KEY);
 
     assertThat(sharedCountersRule.getTotal(INVALIDATES)).isEqualTo(expectedInvalidates());
-    assertThat(region.get(key)).isNull();
+    assertThat(region.get(KEY)).isNull();
   }
 
   @Test
@@ -158,8 +145,8 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
       });
     }
 
-    region.put(key, 0, cacheRule.getSystem().getDistributedMember());
-    region.destroy(key);
+    region.put(KEY, 0, cacheRule.getSystem().getDistributedMember());
+    region.destroy(KEY);
 
     assertThat(sharedCountersRule.getTotal(DESTROYS)).isEqualTo(expectedDestroys());
   }
@@ -193,40 +180,39 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
   /**
    * Overridden within tests to increment shared counters.
    */
-  abstract static class BaseCacheListener extends CacheListenerAdapter<String, Integer>
+  private abstract static class BaseCacheListener extends CacheListenerAdapter<String, Integer>
       implements Serializable {
 
     @Override
-    public void afterCreate(final EntryEvent event) {
+    public void afterCreate(final EntryEvent<String, Integer> event) {
       fail("Unexpected listener callback: afterCreate");
     }
 
     @Override
-    public void afterInvalidate(final EntryEvent event) {
+    public void afterInvalidate(final EntryEvent<String, Integer> event) {
       fail("Unexpected listener callback: afterInvalidate");
     }
 
     @Override
-    public void afterDestroy(final EntryEvent event) {
+    public void afterDestroy(final EntryEvent<String, Integer> event) {
       fail("Unexpected listener callback: afterDestroy");
     }
 
     @Override
-    public void afterUpdate(final EntryEvent event) {
+    public void afterUpdate(final EntryEvent<String, Integer> event) {
       fail("Unexpected listener callback: afterUpdate");
     }
 
     @Override
-    public void afterRegionInvalidate(final RegionEvent event) {
+    public void afterRegionInvalidate(final RegionEvent<String, Integer> event) {
       fail("Unexpected listener callback: afterRegionInvalidate");
     }
   }
 
-  class CreateCountingCacheListener extends BaseCacheListener {
+  private class CreateCountingCacheListener extends BaseCacheListener {
 
     @Override
-    public void afterCreate(final EntryEvent event) {
-      logger.info("Invoking afterCreate on listener; name={}", event.getKey());
+    public void afterCreate(final EntryEvent<String, Integer> event) {
       sharedCountersRule.increment(CREATES);
 
       errorCollector.checkThat(event.getDistributedMember(), equalTo(event.getCallbackArgument()));
@@ -242,21 +228,18 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
         errorCollector.checkThat(event.getSerializedNewValue().getDeserializedValue(),
             equalTo(event.getNewValue()));
       }
-
-      logger.info("create event new value is: {}", event.getNewValue());
     }
   }
 
-  class UpdateCountingCacheListener extends BaseCacheListener {
+  private class UpdateCountingCacheListener extends BaseCacheListener {
 
     @Override
-    public void afterCreate(final EntryEvent event) {
+    public void afterCreate(final EntryEvent<String, Integer> event) {
       // nothing
     }
 
     @Override
-    public void afterUpdate(final EntryEvent event) {
-      logger.info("Invoking afterUpdate on listener; name=" + event.getKey());
+    public void afterUpdate(final EntryEvent<String, Integer> event) {
       sharedCountersRule.increment(UPDATES);
 
       errorCollector.checkThat(event.getDistributedMember(), equalTo(event.getCallbackArgument()));
@@ -275,16 +258,15 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
     }
   }
 
-  class InvalidateCountingCacheListener extends BaseCacheListener {
+  private class InvalidateCountingCacheListener extends BaseCacheListener {
 
     @Override
-    public void afterCreate(final EntryEvent event) {
+    public void afterCreate(final EntryEvent<String, Integer> event) {
       // ignore
     }
 
     @Override
-    public void afterInvalidate(final EntryEvent event) {
-      logger.info("Invoking tests invalidated listener");
+    public void afterInvalidate(final EntryEvent<String, Integer> event) {
       sharedCountersRule.increment(INVALIDATES);
 
       if (event.isOriginRemote()) {
@@ -300,16 +282,15 @@ public class ReplicateCacheListenerInvocationTest implements Serializable {
     }
   }
 
-  class DestroyCountingCacheListener extends BaseCacheListener {
+  private class DestroyCountingCacheListener extends BaseCacheListener {
 
     @Override
-    public void afterCreate(final EntryEvent event) {
+    public void afterCreate(final EntryEvent<String, Integer> event) {
       // ignore
     }
 
     @Override
-    public void afterDestroy(final EntryEvent event) {
-      logger.info("Invoking objectDestroyed listener");
+    public void afterDestroy(final EntryEvent<String, Integer> event) {
       sharedCountersRule.increment(DESTROYS);
 
       if (event.isOriginRemote()) {
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java
deleted file mode 100644
index a3fba22..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/CreateAndLocalDestroyInTXRegressionTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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 org.apache.geode.cache30;
-
-import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION;
-import static org.apache.geode.internal.i18n.LocalizedStrings.TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.CacheTransactionManager;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.UnsupportedOperationInTransactionException;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
-
-/**
- * Test create + localDestroy for bug 34387
- *
- * <p>
- * TRAC #34387: TX in Proxy Regions with create followed by localDestroy on same key results in
- * remote VMs receiving create events with null getNewValue().
- *
- * <p>
- * Create and LocalDestroy/LocalInvalidate should create event with NewValue
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class CreateAndLocalDestroyInTXRegressionTest extends CacheTestCase {
-
-  private static final String REGION_NAME = "r1";
-
-  private int invokeCount;
-  private VM otherVM;
-  private transient Region region;
-
-  @Rule
-  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
-
-  @Before
-  public void setUp() throws Exception {
-    this.invokeCount = 0;
-    this.otherVM = Host.getHost(0).getVM(0);
-
-    initOtherVM(this.otherVM);
-    AttributesFactory af = new AttributesFactory();
-    af.setDataPolicy(DataPolicy.REPLICATE);
-    af.setScope(Scope.DISTRIBUTED_ACK);
-    af.setConcurrencyChecksEnabled(true);
-
-    CacheListener cl1 = new CacheListenerAdapter() {
-      @Override
-      public void afterCreate(EntryEvent e) {
-        errorCollector.checkThat("Keys not equal", "createKey", equalTo(e.getKey()));
-        errorCollector.checkThat("Values not equal", "createValue", equalTo(e.getNewValue()));
-        CreateAndLocalDestroyInTXRegressionTest.this.invokeCount++;
-      }
-    };
-
-    af.addCacheListener(cl1);
-    this.region = createRootRegion(REGION_NAME, af.create());
-
-    assertNull(this.region.getEntry("createKey"));
-  }
-
-  /**
-   * test create followed by localDestroy
-   */
-  @Test
-  public void createAndLocalDestroyShouldCreateEventWithNewValue() throws CacheException {
-    doCommitInOtherVm(otherVM, true);
-
-    assertNotNull(this.region.getEntry("createKey"));
-    assertEquals("createValue", this.region.getEntry("createKey").getValue());
-    assertEquals(1, this.invokeCount);
-  }
-
-  /**
-   * test create followed by localInvalidate
-   */
-  @Test
-  public void createAndLocalInvalidateShouldCreateEventWithNewValue() throws CacheException {
-    doCommitInOtherVm(this.otherVM, false);
-
-    assertNotNull(this.region.getEntry("createKey"));
-    assertEquals("createValue", this.region.getEntry("createKey").getValue());
-    assertEquals(1, this.invokeCount);
-  }
-
-  private void initOtherVM(VM otherVM) {
-    otherVM.invoke(new CacheSerializableRunnable("Connect") {
-      @Override
-      public void run2() throws CacheException {
-        getCache();
-      }
-    });
-  }
-
-  private void doCommitInOtherVm(VM otherVM, boolean doDestroy) {
-    otherVM.invoke(new CacheSerializableRunnable("create root") {
-      @Override
-      public void run2() throws CacheException {
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.DISTRIBUTED_ACK);
-        factory.setConcurrencyChecksEnabled(true);
-
-        Region region = createRootRegion(REGION_NAME, factory.create());
-
-        CacheTransactionManager transactionManager = getCache().getCacheTransactionManager();
-        transactionManager.begin();
-
-        region.create("createKey", "createValue");
-
-        if (doDestroy) {
-          try {
-            region.localDestroy("createKey");
-            fail("expected exception not thrown");
-          } catch (UnsupportedOperationInTransactionException e) {
-            assertEquals(TXStateStub_LOCAL_DESTROY_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString(),
-                e.getMessage());
-          }
-        } else {
-          try {
-            region.localInvalidate("createKey");
-            fail("expected exception not thrown");
-          } catch (UnsupportedOperationInTransactionException e) {
-            assertEquals(
-                TXStateStub_LOCAL_INVALIDATE_NOT_ALLOWED_IN_TRANSACTION.toLocalizedString(),
-                e.getMessage());
-          }
-        }
-
-        transactionManager.commit();
-      }
-    });
-  }
-
-}
diff --git a/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java b/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java
deleted file mode 100644
index d2189fa..0000000
--- a/geode-core/src/test/java/org/apache/geode/cache30/EntriesDoNotExpireDuringGIIRegressionTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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 org.apache.geode.cache30;
-
-import static java.util.concurrent.TimeUnit.MINUTES;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.core.Is.is;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.awaitility.Awaitility;
-import org.awaitility.core.ConditionFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.CacheException;
-import org.apache.geode.cache.CacheListener;
-import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EntryEvent;
-import org.apache.geode.cache.ExpirationAction;
-import org.apache.geode.cache.ExpirationAttributes;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.RegionEvent;
-import org.apache.geode.cache.Scope;
-import org.apache.geode.cache.util.CacheListenerAdapter;
-import org.apache.geode.internal.cache.CacheDistributionAdvisor;
-import org.apache.geode.internal.cache.DistributedRegion;
-import org.apache.geode.internal.cache.InitialImageOperation;
-import org.apache.geode.internal.cache.LocalRegion;
-import org.apache.geode.test.dunit.AsyncInvocation;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
-import org.apache.geode.test.junit.categories.DistributedTest;
-import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
-
-/**
- * Make sure entry expiration does not happen during gii for bug 35214
- *
- * <p>
- * TRAC #35214: hang during getInitialImage due to entry expiration
- *
- * <p>
- * Entries should not expire during GII
- *
- * @since GemFire 5.0
- */
-@Category(DistributedTest.class)
-public class EntriesDoNotExpireDuringGIIRegressionTest extends CacheTestCase {
-
-  private static final int ENTRY_COUNT = 100;
-  private static final String REGION_NAME = "r1";
-
-  // TODO: value of expirationCount is not validated
-  private AtomicInteger expirationCount;
-  private AtomicBoolean afterRegionCreateInvoked;
-  private VM otherVM;
-
-  @Rule
-  public DistributedRestoreSystemProperties restoreSystemProperties =
-      new DistributedRestoreSystemProperties();
-
-  @Rule
-  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
-
-  @Before
-  public void setUp() throws Exception {
-    this.expirationCount = new AtomicInteger(0);
-    this.afterRegionCreateInvoked = new AtomicBoolean(false);
-    this.otherVM = Host.getHost(0).getVM(0);
-    initOtherVm(this.otherVM);
-
-    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
-    InitialImageOperation.slowImageProcessing = 30;
-  }
-
-  @After
-  public void tearDown() throws Exception {
-    InitialImageOperation.slowImageProcessing = 0;
-  }
-
-  /**
-   * make sure entries do not expire during a GII
-   */
-  @Test
-  public void entriesShouldNotExpireDuringGII() throws Exception {
-    AsyncInvocation updater = updateOtherVm(this.otherVM);
-
-    AttributesFactory factory = new AttributesFactory();
-    factory.setDataPolicy(DataPolicy.REPLICATE);
-    factory.setScope(Scope.DISTRIBUTED_ACK);
-    factory.setStatisticsEnabled(true);
-    factory.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE));
-    factory.addCacheListener(createCacheListener());
-
-    Region region = createRootRegion(REGION_NAME, factory.create());
-
-    updater.await();
-
-    await().until(() -> region.values().size() == 0);
-
-    assertThat(region.values().size()).isEqualTo(0);
-    assertThat(region.keySet().size()).isEqualTo(ENTRY_COUNT);
-  }
-
-  private void initOtherVm(final VM otherVM) {
-    otherVM.invoke(new CacheSerializableRunnable("init") {
-
-      @Override
-      public void run2() throws CacheException {
-        getCache();
-
-        AttributesFactory factory = new AttributesFactory();
-        factory.setScope(Scope.DISTRIBUTED_ACK);
-
-        Region region = createRootRegion(REGION_NAME, factory.create());
-
-        for (int i = 1; i <= ENTRY_COUNT; i++) {
-          region.put("key" + i, "value" + i);
-        }
-      }
-    });
-  }
-
-  private AsyncInvocation updateOtherVm(final VM otherVM) {
-    return otherVM.invokeAsync(new CacheSerializableRunnable("update") {
-
-      @Override
-      public void run2() throws CacheException {
-        Region region = getRootRegion(REGION_NAME);
-        // let the main guys gii get started; we want to do updates during his gii
-
-        // wait for profile of getInitialImage cache to show up
-        CacheDistributionAdvisor advisor =
-            ((DistributedRegion) region).getCacheDistributionAdvisor();
-        int expectedProfiles = 1;
-        await().until(
-            () -> assertThat(numberProfiles(advisor)).isGreaterThanOrEqualTo(expectedProfiles));
-
-        // start doing updates of the keys to see if we can get deadlocked
-        int updateCount = 1;
-        do {
-          for (int i = 1; i <= ENTRY_COUNT; i++) {
-            String key = "key" + i;
-            if (region.containsKey(key)) {
-              region.destroy(key);
-            } else {
-              region.put(key, "value" + i + "uc" + updateCount);
-            }
-          }
-        } while (updateCount++ < 20);
-
-        // do one more loop with no destroys
-        for (int i = 1; i <= ENTRY_COUNT; i++) {
-          String key = "key" + i;
-          if (!region.containsKey(key)) {
-            region.put(key, "value" + i + "uc" + updateCount);
-          }
-        }
-      }
-    });
-  }
-
-  private int numberProfiles(final CacheDistributionAdvisor advisor) {
-    return advisor.adviseInitialImage(null).getReplicates().size();
-  }
-
-  private CacheListener createCacheListener() {
-    return new CacheListenerAdapter() {
-
-      @Override
-      public void afterRegionCreate(final RegionEvent event) {
-        afterRegionCreateInvoked.set(true);
-      }
-
-      @Override
-      public void afterInvalidate(final EntryEvent event) {
-        errorCollector.checkThat("afterRegionCreate should have been seen",
-            afterRegionCreateInvoked.get(), is(true));
-        errorCollector.checkThat("Region should have been initialized",
-            ((LocalRegion) event.getRegion()).isInitialized(), is(true));
-
-        expirationCount.incrementAndGet();
-
-        InitialImageOperation.slowImageProcessing = 0;
-      }
-    };
-  }
-
-  private ConditionFactory await() {
-    return Awaitility.await().atMost(2, MINUTES);
-  }
-}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java
new file mode 100644
index 0000000..7784b03
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/EntriesDoNotExpireDuringGiiRegressionTest.java
@@ -0,0 +1,182 @@
+/*
+ * 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 org.apache.geode.internal.cache;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static org.apache.geode.cache.ExpirationAction.INVALIDATE;
+import static org.apache.geode.cache.RegionShortcut.REPLICATE;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.core.Is.is;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.EntryEvent;
+import org.apache.geode.cache.ExpirationAttributes;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionEvent;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.util.CacheListenerAdapter;
+import org.apache.geode.test.dunit.AsyncInvocation;
+import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
+import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableErrorCollector;
+
+/**
+ * Entries should not expire during GII
+ *
+ * <p>
+ * TRAC #35214: hang during getInitialImage due to entry expiration
+ *
+ * @since GemFire 5.0
+ */
+@Category(DistributedTest.class)
+@SuppressWarnings("serial")
+public class EntriesDoNotExpireDuringGiiRegressionTest implements Serializable {
+
+  private static final int ENTRY_COUNT = 100;
+  private static final String REGION_NAME = "r1";
+
+  private final AtomicInteger expirationCount = new AtomicInteger(0);
+  private final AtomicBoolean afterRegionCreateInvoked = new AtomicBoolean(false);
+
+  private VM otherVM;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = new CacheRule();
+
+  @Rule
+  public DistributedRestoreSystemProperties restoreSystemProperties =
+      new DistributedRestoreSystemProperties();
+
+  @Rule
+  public SerializableErrorCollector errorCollector = new SerializableErrorCollector();
+
+  @Before
+  public void setUp() throws Exception {
+    otherVM = getHost(0).getVM(0);
+
+    otherVM.invoke(() -> {
+      RegionFactory<String, String> regionFactory =
+          cacheRule.getOrCreateCache().createRegionFactory(REPLICATE);
+      Region<String, String> region = regionFactory.create(REGION_NAME);
+
+      for (int i = 1; i <= ENTRY_COUNT; i++) {
+        region.put("key" + i, "value" + i);
+      }
+    });
+
+    System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
+    InitialImageOperation.slowImageProcessing = 30;
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    InitialImageOperation.slowImageProcessing = 0;
+  }
+
+  @Test
+  public void entriesShouldNotExpireDuringGII() throws Exception {
+    AsyncInvocation<Void> doRegionOps = otherVM.invokeAsync(() -> doRegionOps());
+
+    RegionFactory<String, String> regionFactory =
+        cacheRule.getOrCreateCache().createRegionFactory(REPLICATE);
+    regionFactory.addCacheListener(new SlowGiiCacheListener());
+    regionFactory.setEntryIdleTimeout(new ExpirationAttributes(1, INVALIDATE));
+    regionFactory.setStatisticsEnabled(true);
+
+    Region<String, String> region = regionFactory.create(REGION_NAME);
+
+    doRegionOps.await();
+
+    await().until(() -> region.values().isEmpty());
+
+    assertThat(region.values()).hasSize(0);
+    assertThat(region.keySet()).hasSize(ENTRY_COUNT);
+    assertThat(expirationCount.get()).isGreaterThan(ENTRY_COUNT);
+  }
+
+  private void doRegionOps() {
+    Region<String, String> region = cacheRule.getCache().getRegion(REGION_NAME);
+    // let the main guys gii get started; we want to do updates during his gii
+
+    // wait for profile of getInitialImage cache to show up
+    CacheDistributionAdvisor advisor = ((DistributedRegion) region).getCacheDistributionAdvisor();
+    int expectedProfiles = 1;
+    await().atMost(2, MINUTES)
+        .until(() -> assertThat(numberProfiles(advisor)).isGreaterThanOrEqualTo(expectedProfiles));
+
+    // start doing updates of the keys to see if we can get deadlocked
+    int updateCount = 1;
+    do {
+      for (int i = 1; i <= ENTRY_COUNT; i++) {
+        String key = "key" + i;
+        if (region.containsKey(key)) {
+          region.destroy(key);
+        } else {
+          region.put(key, "value" + i + "uc" + updateCount);
+        }
+      }
+    } while (updateCount++ < 20);
+
+    // do one more loop with no destroys
+    for (int i = 1; i <= ENTRY_COUNT; i++) {
+      String key = "key" + i;
+      if (!region.containsKey(key)) {
+        region.put(key, "value" + i + "uc" + updateCount);
+      }
+    }
+  }
+
+  private int numberProfiles(final CacheDistributionAdvisor advisor) {
+    return advisor.adviseInitialImage(null).getReplicates().size();
+  }
+
+  private class SlowGiiCacheListener extends CacheListenerAdapter<String, String> {
+
+    @Override
+    public void afterRegionCreate(final RegionEvent<java.lang.String, java.lang.String> event) {
+      afterRegionCreateInvoked.set(true);
+    }
+
+    @Override
+    public void afterInvalidate(final EntryEvent<java.lang.String, java.lang.String> event) {
+      errorCollector.checkThat("afterRegionCreate should have been seen",
+          afterRegionCreateInvoked.get(), is(true));
+      errorCollector.checkThat("Region should have been initialized",
+          ((LocalRegion) event.getRegion()).isInitialized(), is(true));
+
+      expirationCount.incrementAndGet();
+
+      InitialImageOperation.slowImageProcessing = 0;
+    }
+  }
+}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
similarity index 94%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
index 630cf8a..acbc37d 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PREntryIdleExpirationDistributedTest.java
@@ -28,7 +28,8 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class PREntryIdleExpirationTest extends ReplicateEntryIdleExpirationTest {
+public class PREntryIdleExpirationDistributedTest
+    extends ReplicateEntryIdleExpirationDistributedTest {
 
   @Before
   public void setUpPREntryIdleExpirationTest() throws Exception {
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
similarity index 92%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
index e67ba2d..fe5ebf9 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionedRegionCloseDistributedTest.java
@@ -43,13 +43,14 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 @Category(DistributedTest.class)
 @RunWith(JUnitParamsRunner.class)
 @SuppressWarnings("serial")
-public class PartitionedRegionCloseDUnitTest implements Serializable {
+public class PartitionedRegionCloseDistributedTest implements Serializable {
 
+  private static final int REDUNDANT_COPIES = 1;
   private static final int TOTAL_NUM_BUCKETS = 3;
   private static final int NUM_PUTS = 3;
-  private static final int REDUNDANT_COPIES = 1;
 
   private String regionName;
+
   private VM accessor;
   private VM[] datastores;
 
@@ -165,16 +166,16 @@ public class PartitionedRegionCloseDUnitTest implements Serializable {
   }
 
   private void createRegion(final boolean accessor) {
-    PartitionAttributesFactory partitionFactory = new PartitionAttributesFactory();
-    partitionFactory.setRedundantCopies(REDUNDANT_COPIES);
+    PartitionAttributesFactory<String, Integer> paf = new PartitionAttributesFactory<>();
+    paf.setRedundantCopies(REDUNDANT_COPIES);
     if (accessor) {
-      partitionFactory.setLocalMaxMemory(0);
+      paf.setLocalMaxMemory(0);
     }
-    partitionFactory.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
+    paf.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
 
     RegionFactory<String, Integer> regionFactory = cacheRule.getCache().createRegionFactory();
     regionFactory.setDataPolicy(DataPolicy.PARTITION);
-    regionFactory.setPartitionAttributes(partitionFactory.create());
+    regionFactory.setPartitionAttributes(paf.create());
 
     regionFactory.create(regionName);
   }
@@ -183,13 +184,13 @@ public class PartitionedRegionCloseDUnitTest implements Serializable {
     CLOSE_REGION((region) -> region.close()),
     LOCAL_DESTROY_REGION((region) -> region.localDestroyRegion());
 
-    private final Consumer<Region> strategy;
+    private final Consumer<Region<Integer, String>> strategy;
 
-    RegionRemoval(final Consumer<Region> strategy) {
+    RegionRemoval(final Consumer<Region<Integer, String>> strategy) {
       this.strategy = strategy;
     }
 
-    void remove(final Region region) {
+    void remove(final Region<Integer, String> region) {
       strategy.accept(region);
     }
   }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
similarity index 98%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
index eb26680..e1d32ce 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/ReplicateEntryIdleExpirationDistributedTest.java
@@ -43,7 +43,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class ReplicateEntryIdleExpirationTest implements Serializable {
+public class ReplicateEntryIdleExpirationDistributedTest implements Serializable {
 
   @ClassRule
   public static DistributedTestRule distributedTestRule = new DistributedTestRule();
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
index 6a170c7..809d8fd 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientFunctionTimeoutRegressionTest.java
@@ -16,16 +16,23 @@ package org.apache.geode.internal.cache.execute;
 
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER;
+import static org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
+import static org.apache.geode.test.dunit.DistributedTestUtils.getLocatorPort;
+import static org.apache.geode.test.dunit.Host.getHost;
+import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
-import java.util.ArrayList;
+import java.io.Serializable;
+import java.util.List;
 import java.util.Properties;
 
 import junitparams.JUnitParamsRunner;
 import junitparams.Parameters;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -33,7 +40,6 @@ import org.junit.runner.RunWith;
 
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.PartitionAttributesFactory;
-import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.client.ClientCacheFactory;
@@ -42,170 +48,182 @@ import org.apache.geode.cache.client.ClientRegionShortcut;
 import org.apache.geode.cache.client.internal.InternalClientCache;
 import org.apache.geode.cache.execute.Execution;
 import org.apache.geode.cache.execute.Function;
-import org.apache.geode.cache.execute.FunctionAdapter;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.FunctionService;
 import org.apache.geode.cache.execute.ResultCollector;
 import org.apache.geode.cache.server.CacheServer;
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.internal.DistributionConfig;
-import org.apache.geode.internal.AvailablePort;
-import org.apache.geode.internal.cache.CacheServerImpl;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.InternalCacheServer;
 import org.apache.geode.internal.cache.tier.ServerSideHandshake;
 import org.apache.geode.internal.cache.tier.sockets.AcceptorImpl;
 import org.apache.geode.internal.cache.tier.sockets.ServerConnection;
-import org.apache.geode.test.dunit.DistributedTestUtils;
-import org.apache.geode.test.dunit.Host;
-import org.apache.geode.test.dunit.Invoke;
 import org.apache.geode.test.dunit.VM;
-import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase;
 import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 
+/**
+ * Server should terminate client function execution when it times out. Client sends
+ * CLIENT_FUNCTION_TIMEOUT to server when default is overridden by client.
+ *
+ * <p>
+ * TRAC #51193: The function execution connection on the server is never terminated even if the
+ * gemfire.CLIENT_FUNCTION_TIMEOUT property is set
+ */
 @Category(DistributedTest.class)
 @RunWith(JUnitParamsRunner.class)
 @SuppressWarnings("serial")
-public class ClientFunctionTimeoutRegressionTest extends JUnit4DistributedTestCase {
+public class ClientFunctionTimeoutRegressionTest implements Serializable {
 
-  private static final String REGION_NAME =
-      ClientFunctionTimeoutRegressionTest.class.getSimpleName() + "_region";
+  private static final String REGION_NAME = "TheRegion";
+  private static final int TOTAL_NUM_BUCKETS = 4;
+  private static final int REDUNDANT_COPIES = 1;
 
   private static InternalCache serverCache;
-
   private static InternalClientCache clientCache;
 
   private VM server;
-
   private VM client;
 
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
+
   @Rule
   public DistributedRestoreSystemProperties restoreSystemProperties =
       new DistributedRestoreSystemProperties();
 
   @Before
   public void before() throws Exception {
-    server = Host.getHost(0).getVM(0);
-    client = Host.getHost(0).getVM(1);
-
-    disconnectAllFromDS();
+    server = getHost(0).getVM(0);
+    client = getHost(0).getVM(1);
   }
 
   @After
   public void after() throws Exception {
-    Invoke.invokeInEveryVM(() -> closeCache());
+    invokeInEveryVM(() -> {
+      if (clientCache != null) {
+        clientCache.close();
+      }
+      if (serverCache != null) {
+        serverCache.close();
+      }
+      clientCache = null;
+      serverCache = null;
+    });
   }
 
   @Test
-  @Parameters({"false,0,server", "false,6000,server", "false,0,region", "false,6000,region",
-      "true,0,region", "true,6000,region"})
-  public void testExecuteFunctionReadsDefaultTimeout(boolean createPR, int timeout, String mode)
-      throws Exception {
-    // start server
-    int port = server.invoke(() -> createServerCache(createPR));
-    // start client
+  @Parameters({"SERVER,REPLICATE,0", "SERVER,REPLICATE,6000", "REGION,REPLICATE,0",
+      "REGION,REPLICATE,6000", "REGION,PARTITION,0", "REGION,PARTITION,6000"})
+  public void executeFunctionUsesClientTimeoutOnServer(final ExecutionTarget executionTarget,
+      final RegionType regionType, final int timeout) throws Exception {
+    int port = server.invoke(() -> createServerCache(regionType));
     client.invoke(() -> createClientCache(client.getHost().getHostName(), port, timeout));
-    // do puts and get
-    server.invoke(() -> doPutsAndGet(10));
-    // execute function & verify timeout has been received at server.
-    client.invoke(() -> executeFunction(mode, timeout));
-  }
 
-  private void closeCache() {
-    if (clientCache != null) {
-      clientCache.close();
-      clientCache = null;
-    }
-    if (serverCache != null) {
-      serverCache.close();
-      serverCache = null;
-    }
+    client.invoke(() -> executeFunctionToVerifyClientTimeoutOnServer(executionTarget, timeout));
   }
 
-  private void createClientCache(String hostName, Integer port, Integer timeout) {
+  private void createClientCache(final String hostName, final int port, final int timeout) {
     if (timeout > 0) {
-      System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "CLIENT_FUNCTION_TIMEOUT",
-          String.valueOf(timeout));
+      System.setProperty(GEMFIRE_PREFIX + "CLIENT_FUNCTION_TIMEOUT", String.valueOf(timeout));
     }
 
-    Properties props = new Properties();
-    props.setProperty(LOCATORS, "");
-    props.setProperty(MCAST_PORT, "0");
+    Properties config = new Properties();
+    config.setProperty(LOCATORS, "");
+    config.setProperty(MCAST_PORT, "0");
+
+    ClientCacheFactory clientCacheFactory = new ClientCacheFactory(config);
+    clientCacheFactory.addPoolServer(hostName, port);
 
-    ClientCacheFactory ccf = new ClientCacheFactory(props);
-    ccf.addPoolServer(hostName, port);
-    clientCache = (InternalClientCache) ccf.create();
+    clientCache = (InternalClientCache) clientCacheFactory.create();
 
-    ClientRegionFactory<String, String> crf =
+    ClientRegionFactory<String, String> clientRegionFactory =
         clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
 
-    crf.create(REGION_NAME);
+    clientRegionFactory.create(REGION_NAME);
   }
 
-  private Integer createServerCache(Boolean createPR) throws IOException {
-    Properties props = new Properties();
-    props.setProperty(LOCATORS, "localhost[" + DistributedTestUtils.getDUnitLocatorPort() + "]");
-    props.setProperty(ConfigurationProperties.SERIALIZABLE_OBJECT_FILTER,
+  private int createServerCache(final RegionType regionType) throws IOException {
+    assertThat(regionType).isNotNull();
+
+    Properties config = new Properties();
+    config.setProperty(LOCATORS, "localhost[" + getLocatorPort() + "]");
+    config.setProperty(SERIALIZABLE_OBJECT_FILTER,
         "org.apache.geode.internal.cache.execute.ClientFunctionTimeoutRegressionTest*");
 
-    serverCache = (InternalCache) new CacheFactory(props).create();
+    serverCache = (InternalCache) new CacheFactory(config).create();
+
+    RegionFactory<String, String> regionFactory;
+
+    if (regionType == RegionType.PARTITION) {
+      PartitionAttributesFactory<String, String> paf = new PartitionAttributesFactory<>();
+      paf.setRedundantCopies(REDUNDANT_COPIES);
+      paf.setTotalNumBuckets(TOTAL_NUM_BUCKETS);
+
+      regionFactory = serverCache.createRegionFactory(RegionShortcut.PARTITION);
+      regionFactory.setPartitionAttributes(paf.create());
 
-    RegionFactory<String, String> rf;
-    if (createPR) {
-      rf = serverCache.createRegionFactory(RegionShortcut.PARTITION);
-      rf.setPartitionAttributes(new PartitionAttributesFactory<String, String>()
-          .setRedundantCopies(1).setTotalNumBuckets(4).create());
     } else {
-      rf = serverCache.createRegionFactory(RegionShortcut.REPLICATE);
+      regionFactory = serverCache.createRegionFactory(RegionShortcut.REPLICATE);
     }
 
-    rf.create(REGION_NAME);
+    regionFactory.create(REGION_NAME);
 
     CacheServer server = serverCache.addCacheServer();
-    server.setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    server.setPort(0);
     server.start();
     return server.getPort();
   }
 
-  private void executeFunction(String mode, Integer timeout) {
-    Function function = new TestFunction(mode + timeout);
+  private void executeFunctionToVerifyClientTimeoutOnServer(
+      final ExecutionTarget functionServiceTarget, final int timeout) {
+    assertThat(functionServiceTarget).isNotNull();
+
+    Function<Integer> function = new CheckClientReadTimeout();
     FunctionService.registerFunction(function);
-    Execution dataSet;
-    if ("region".equalsIgnoreCase(mode)) {
-      dataSet = FunctionService.onRegion(clientCache.getRegion(REGION_NAME)).setArguments(timeout);
-    } else if ("server".equalsIgnoreCase(mode)) {
-      dataSet = FunctionService.onServer(clientCache.getDefaultPool()).setArguments(timeout);
+    Execution<Integer, Boolean, List<Boolean>> execution = null;
+
+    if (functionServiceTarget == ExecutionTarget.REGION) {
+      execution =
+          FunctionService.onRegion(clientCache.getRegion(REGION_NAME)).setArguments(timeout);
     } else {
-      dataSet = FunctionService.onServers(clientCache).setArguments(timeout);
+      execution = FunctionService.onServer(clientCache.getDefaultPool()).setArguments(timeout);
     }
-    ResultCollector rs = dataSet.execute(function);
-    assertThat((Boolean) ((ArrayList) rs.getResult()).get(0))
-        .as("Server did not read client_function_timeout from client.").isTrue();
+
+    ResultCollector<Boolean, List<Boolean>> resultCollector = execution.execute(function);
+
+    String description = "Server did not read client_function_timeout from client.";
+    assertThat(resultCollector.getResult().get(0)).as(description).isTrue();
   }
 
-  private void doPutsAndGet(Integer num) {
-    Region r = serverCache.getRegion(REGION_NAME);
-    for (int i = 0; i < num; ++i) {
-      r.put("KEY_" + i, "VALUE_" + i);
-    }
-    r.get("KEY_0");
+  private enum RegionType {
+    PARTITION, REPLICATE
   }
 
-  private static class TestFunction extends FunctionAdapter {
+  private enum ExecutionTarget {
+    REGION, SERVER
+  }
 
-    private final String id;
+  /**
+   * Input: client function timeout <br>
+   * Output: true if server has client timeout equal to the input
+   */
+  private static class CheckClientReadTimeout implements Function<Integer> {
 
-    public TestFunction(String id) {
-      this.id = id;
+    public CheckClientReadTimeout() {
+      // nothing
     }
 
     @Override
-    public void execute(FunctionContext context) {
+    public void execute(FunctionContext<Integer> context) {
       boolean timeoutMatches = false;
-      int expected = (Integer) context.getArguments();
-      AcceptorImpl acceptor =
-          ((CacheServerImpl) serverCache.getCacheServers().get(0)).getAcceptor();
+      int expected = context.getArguments();
+
+      InternalCacheServer cacheServer =
+          (InternalCacheServer) context.getCache().getCacheServers().get(0);
+      AcceptorImpl acceptor = (AcceptorImpl) cacheServer.getAcceptor();
       ServerConnection[] scs = acceptor.getAllServerConnectionList();
+
       for (ServerConnection sc : scs) {
         ServerSideHandshake hs = sc.getHandshake();
         if (hs != null && expected == hs.getClientReadTimeout()) {
@@ -218,7 +236,7 @@ public class ClientFunctionTimeoutRegressionTest extends JUnit4DistributedTestCa
 
     @Override
     public String getId() {
-      return this.id;
+      return CheckClientReadTimeout.class.getName();
     }
 
     @Override
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionExecution_ExceptionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionExecution_ExceptionDUnitTest.java
index 6834223..540377f 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionExecution_ExceptionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/execute/FunctionExecution_ExceptionDUnitTest.java
@@ -106,7 +106,7 @@ public class FunctionExecution_ExceptionDUnitTest implements Serializable {
     PartitionAttributesFactory<?, ?> partitionAttributesFactory = new PartitionAttributesFactory();
     partitionAttributesFactory.setRedundantCopies(0).setLocalMaxMemory(localMaxMemory);
 
-    RegionFactory<?, ?> regionFactory = cacheRule.createCache().createRegionFactory(PARTITION);
+    RegionFactory<?, ?> regionFactory = cacheRule.getOrCreateCache().createRegionFactory(PARTITION);
     regionFactory.setPartitionAttributes(partitionAttributesFactory.create());
 
     regionFactory.create(regionName);
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
index 69cc6cb..7075d98 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/partitioned/BucketRebalanceStatRegressionTest.java
@@ -1,7 +1,7 @@
 /*
  * 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
+ * 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
  *
@@ -14,52 +14,82 @@
  */
 package org.apache.geode.internal.cache.partitioned;
 
+import static org.apache.geode.cache.EvictionAction.OVERFLOW_TO_DISK;
+import static org.apache.geode.cache.EvictionAttributes.createLRUEntryAttributes;
+import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS;
+import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.DiskStore;
 import org.apache.geode.cache.DiskStoreFactory;
-import org.apache.geode.cache.EvictionAction;
-import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionFactory;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.control.RebalanceFactory;
 import org.apache.geode.cache.control.RebalanceOperation;
-import org.apache.geode.cache.control.RebalanceResults;
 import org.apache.geode.cache.control.ResourceManager;
-import org.apache.geode.cache30.CacheTestCase;
 import org.apache.geode.internal.cache.BucketRegion;
 import org.apache.geode.internal.cache.PartitionedRegion;
-import org.apache.geode.test.dunit.Host;
 import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
 
-@Category({DistributedTest.class})
-public class BucketRebalanceStatRegressionTest extends CacheTestCase {
+/**
+ * Moving a bucket during rebalancing should update overflow stats (numEntriesInVM and
+ * numOverflowOnDisk).
+ *
+ * <p>
+ * GEODE-3566: Moving a bucket during rebalancing does not update overflow stats
+ */
+@Category(DistributedTest.class)
+@SuppressWarnings("serial")
+public class BucketRebalanceStatRegressionTest implements Serializable {
+
+  private static final String REGION_NAME = "TestRegion";
 
+  private static final int TOTAL_NUMBER_BUCKETS = 2;
   private static final int LRU_ENTRY_COUNT = 4;
   private static final int ENTRIES_IN_REGION = 20;
-  private static final int TOTAL_NUMBER_BUCKETS = 2;
-  private static final String REGION_NAME = "TestRegion";
-  private final VM vm0 = Host.getHost(0).getVM(0);
-  private final VM vm1 = Host.getHost(0).getVM(1);
+  private static final int BYTES_SIZE = 100;
+
+  private VM vm0;
+  private VM vm1;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
+
+  @Rule
+  public CacheRule cacheRule = new CacheRule();
+
+  @Rule
+  public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
+
+  @Rule
+  public SerializableTestName testName = new SerializableTestName();
 
   @Before
   public void setUp() throws Exception {
-    getSystem();
-    getCache();
+    vm0 = getHost(0).getVM(0);
+    vm1 = getHost(0).getVM(1);
   }
 
   @After
@@ -70,42 +100,41 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
   @Test
   public void statsUpdatedAfterRebalancePersistentOverflowPR() throws Exception {
     initializeRegions(RegionShortcut.PARTITION_PERSISTENT, true);
+
     validateInitialOverflowStats();
     validateInitialRegion();
-    statsUpdatedAfterRebalance();
+    validateStatsUpdatedAfterRebalance();
   }
 
   @Test
   public void statsUpdatedAfterRebalanceOverflowPR() throws Exception {
     initializeRegions(RegionShortcut.PARTITION, true);
+
     validateInitialOverflowStats();
     validateInitialRegion();
-    statsUpdatedAfterRebalance();
+    validateStatsUpdatedAfterRebalance();
   }
 
   @Test
   public void statsUpdatedAfterRebalancePersistentPR() throws Exception {
     initializeRegions(RegionShortcut.PARTITION_PERSISTENT, false);
+
     validateInitialRegion();
-    statsUpdatedAfterRebalance();
+    validateStatsUpdatedAfterRebalance();
   }
 
   /**
    * Verify that overflow stats are updated when a bucket moves due to rebalancing.
-   *
-   * @param shortcut The region shortcut to use to create the region.
-   * @param overflow If true the region is configured for overflow to disk, false otherwise.
-   * @throws Exception
    */
-  private void statsUpdatedAfterRebalance() throws Exception {
+  private void validateStatsUpdatedAfterRebalance() {
     vm0.invoke(() -> rebalance());
-    assertThat(vm0.invoke(() -> getCache().getRegion(REGION_NAME).size()))
+    assertThat(vm0.invoke(() -> cacheRule.getCache().getRegion(REGION_NAME).size()))
         .isEqualTo(ENTRIES_IN_REGION);
-    assertThat(vm1.invoke(() -> getCache().getRegion(REGION_NAME).size()))
+    assertThat(vm1.invoke(() -> cacheRule.getCache().getRegion(REGION_NAME).size()))
         .isEqualTo(ENTRIES_IN_REGION);
-    assertThat(vm0.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm0.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getLocalBucketsListTestOnly().size())).isEqualTo(TOTAL_NUMBER_BUCKETS / 2);
-    assertThat(vm1.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm1.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getLocalBucketsListTestOnly().size())).isEqualTo(TOTAL_NUMBER_BUCKETS / 2);
     validateOverflowStats(vm0, "vm0");
     validateOverflowStats(vm1, "vm1");
@@ -117,55 +146,43 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
    * @param shortcut The region shortcut to use to create the region.
    * @param overflow If true, use overflow on the region, false otherwise.
    */
-  private void initializeRegions(RegionShortcut shortcut, boolean overflow) {
+  private void initializeRegions(final RegionShortcut shortcut, final boolean overflow) {
     // arrange: create regions and data
-    vm0.invoke(() -> {
-      createRegion(shortcut, overflow);
-    });
+    vm0.invoke(() -> createRegion(shortcut, overflow));
     vm0.invoke(() -> loadRegion());
-    vm1.invoke(() -> {
-      createRegion(shortcut, overflow);
-    });
+    vm1.invoke(() -> createRegion(shortcut, overflow));
   }
 
   /**
    * Do validation on the initial region before rebalancing. It is expected that all buckets and
    * data live on vm0; vm1 does not host any buckets.
-   *
-   * @param overflow If true the region is set for overflow to disk, false otherwise.
-   * @param vm0 One of the members hosting the partitioned region under test.
-   * @param vm1 Another member hosting the partitioned region under test.
    */
   private void validateInitialRegion() {
-    assertThat(vm0.invoke(() -> getCache().getRegion(REGION_NAME).size()))
+    assertThat(vm0.invoke(() -> cacheRule.getCache().getRegion(REGION_NAME).size()))
         .isEqualTo(ENTRIES_IN_REGION);
-    assertThat(vm1.invoke(() -> getCache().getRegion(REGION_NAME).size()))
+    assertThat(vm1.invoke(() -> cacheRule.getCache().getRegion(REGION_NAME).size()))
         .isEqualTo(ENTRIES_IN_REGION);
-    assertThat(vm0.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm0.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getLocalBucketsListTestOnly().size())).isEqualTo(TOTAL_NUMBER_BUCKETS);
-    assertThat(vm1.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm1.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getLocalBucketsListTestOnly().size())).isEqualTo(0);
   }
 
   /**
    * Do validation the initial region for the member containing all the data
-   *
    */
   private void validateInitialOverflowStats() {
-    assertThat(vm0.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm0.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getDiskRegionStats().getNumEntriesInVM())).isEqualTo(LRU_ENTRY_COUNT);
-    assertThat(vm0.invoke(() -> ((PartitionedRegion) (getCache().getRegion(REGION_NAME)))
+    assertThat(vm0.invoke(() -> ((PartitionedRegion) (cacheRule.getCache().getRegion(REGION_NAME)))
         .getDiskRegionStats().getNumOverflowOnDisk()))
             .isEqualTo(ENTRIES_IN_REGION - LRU_ENTRY_COUNT);
   }
 
   /**
    * Validate that the overflow stats are as expected on the given member.
-   *
-   * @param vm The member to check stats on.
-   * @param vmName The name of the member.
    */
-  private void validateOverflowStats(VM vm, String vmName) {
+  private void validateOverflowStats(final VM vm, final String vmName) {
     long[] overflowStats = vm.invoke(() -> getOverflowStats());
     long[] overflowEntries = vm.invoke(() -> getActualOverflowEntries());
 
@@ -180,14 +197,14 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
 
   /**
    * Rebalance the region, waiting for the rebalance operation to complete
-   *
-   * @throws Exception
    */
   private void rebalance() throws Exception {
-    ResourceManager resMan = getCache().getResourceManager();
-    RebalanceFactory factory = resMan.createRebalanceFactory();
-    RebalanceOperation rebalanceOp = factory.start();
-    RebalanceResults results = rebalanceOp.getResults(); // wait for rebalance to complete
+    ResourceManager resourceManager = cacheRule.getCache().getResourceManager();
+    RebalanceFactory rebalanceFactory = resourceManager.createRebalanceFactory();
+    RebalanceOperation rebalanceOperation = rebalanceFactory.start();
+
+    // wait for rebalance to complete
+    assertThat(rebalanceOperation.getResults()).isNotNull();
   }
 
   /**
@@ -195,9 +212,9 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
    *
    */
   private void loadRegion() {
-    Region aRegion = getCache().getRegion(REGION_NAME);
+    Region<Integer, byte[]> region = cacheRule.getCache().getRegion(REGION_NAME);
     for (int i = 1; i <= ENTRIES_IN_REGION; i++) {
-      aRegion.put(i, new byte[100]);
+      region.put(i, new byte[BYTES_SIZE]);
     }
   }
 
@@ -208,8 +225,9 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
    * @return [0] numEntriesInVM stat [1] numOverflowOnDisk stat
    */
   private long[] getOverflowStats() {
-    Region testRegion = getCache().getRegion(REGION_NAME);
-    PartitionedRegion partitionedRegion = (PartitionedRegion) testRegion;
+    Region<Integer, byte[]> region = cacheRule.getCache().getRegion(REGION_NAME);
+    PartitionedRegion partitionedRegion = (PartitionedRegion) region;
+
     long numEntriesInVM = partitionedRegion.getDiskRegionStats().getNumEntriesInVM();
     long numOverflowOnDisk = partitionedRegion.getDiskRegionStats().getNumOverflowOnDisk();
     return new long[] {numEntriesInVM, numOverflowOnDisk};
@@ -222,11 +240,13 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
    * @return [0] total entries in VM [1] total entries on disk
    */
   private long[] getActualOverflowEntries() {
-    Region testRegion = getCache().getRegion(REGION_NAME);
-    PartitionedRegion pr = (PartitionedRegion) testRegion;
+    Region<Integer, byte[]> region = cacheRule.getCache().getRegion(REGION_NAME);
+    PartitionedRegion partitionedRegion = (PartitionedRegion) region;
+
     int totalBucketEntriesInVM = 0;
     int totalBucketEntriesOnDisk = 0;
-    Set<Entry<Integer, BucketRegion>> buckets = pr.getDataStore().getAllLocalBuckets();
+    Set<Entry<Integer, BucketRegion>> buckets =
+        partitionedRegion.getDataStore().getAllLocalBuckets();
     for (Map.Entry<Integer, BucketRegion> entry : buckets) {
       BucketRegion bucket = entry.getValue();
       if (bucket != null) {
@@ -234,34 +254,36 @@ public class BucketRebalanceStatRegressionTest extends CacheTestCase {
         totalBucketEntriesOnDisk += bucket.testHookGetValuesOnDisk();
       }
     }
+
     return new long[] {totalBucketEntriesInVM, totalBucketEntriesOnDisk};
   }
 
-  /**
-   * Create a PartitionedRegion
-   */
-  private Region<?, ?> createRegion(RegionShortcut shortcut, boolean overflow) {
-    Cache cache = getCache();
+  private void createRegion(final RegionShortcut shortcut, final boolean overflow)
+      throws IOException {
+    Cache cache = cacheRule.getOrCreateCache();
     DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
-    File[] diskDirs = getDiskDirs();
-    diskStoreFactory.setDiskDirs(diskDirs);
-    DiskStore diskStore = diskStoreFactory.create(getUniqueName());
+    diskStoreFactory.setDiskDirs(getDiskDirs());
+    DiskStore diskStore = diskStoreFactory.create(testName.getMethodName());
 
-    RegionFactory<String, String> regionFactory = cache.createRegionFactory(shortcut);
+    RegionFactory<Integer, byte[]> regionFactory = cache.createRegionFactory(shortcut);
     regionFactory.setDiskStoreName(diskStore.getName());
     regionFactory.setDiskSynchronous(true);
+
     if (overflow) {
-      EvictionAttributes evAttr = EvictionAttributes.createLRUEntryAttributes(LRU_ENTRY_COUNT,
-          EvictionAction.OVERFLOW_TO_DISK);
-      regionFactory.setEvictionAttributes(evAttr);
+      regionFactory
+          .setEvictionAttributes(createLRUEntryAttributes(LRU_ENTRY_COUNT, OVERFLOW_TO_DISK));
     }
 
-    PartitionAttributesFactory prFactory = new PartitionAttributesFactory();
-    prFactory.setTotalNumBuckets(TOTAL_NUMBER_BUCKETS);
-    prFactory.setRedundantCopies(0);
-    regionFactory.setPartitionAttributes(prFactory.create());
+    PartitionAttributesFactory<Integer, byte[]> paf = new PartitionAttributesFactory<>();
+    paf.setRedundantCopies(0);
+    paf.setTotalNumBuckets(TOTAL_NUMBER_BUCKETS);
+    regionFactory.setPartitionAttributes(paf.create());
 
-    return regionFactory.create(REGION_NAME);
+    regionFactory.create(REGION_NAME);
   }
 
+  private File[] getDiskDirs() throws IOException {
+    File dir = temporaryFolder.newFolder("disk" + VM.getCurrentVMNum()).getAbsoluteFile();
+    return new File[] {dir};
+  }
 }
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
similarity index 94%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
index 62e8be2..7837b85 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientProxyWithDeltaDistributedTest.java
@@ -63,7 +63,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class ClientProxyWithDeltaTest implements Serializable {
+public class ClientProxyWithDeltaDistributedTest implements Serializable {
 
   private static final String PROXY_NAME = "PROXY_NAME";
   private static final String CACHING_PROXY_NAME = "CACHING_PROXY_NAME";
@@ -72,11 +72,11 @@ public class ClientProxyWithDeltaTest implements Serializable {
   private static InternalClientCache clientCache;
 
   private String hostName;
+  private int serverPort;
 
   private VM server;
   private VM client1;
   private VM client2;
-  private int serverPort;
 
   @ClassRule
   public static DistributedTestRule distributedTestRule = new DistributedTestRule();
@@ -169,7 +169,7 @@ public class ClientProxyWithDeltaTest implements Serializable {
     });
 
     client2.invoke(() -> {
-      await().atMost(30, SECONDS).until(() -> ClientListener.keyZeroCreated.get());
+      await().atMost(30, SECONDS).until(() -> ClientListener.KEY_ZERO_CREATED.get());
       assertThat(CacheClientUpdater.fullValueRequested).isFalse();
       assertThat(DeltaEnabledObject.fromDeltaInvoked()).isFalse();
     });
@@ -261,11 +261,11 @@ public class ClientProxyWithDeltaTest implements Serializable {
 
   private static class ClientListener extends CacheListenerAdapter<Integer, DeltaEnabledObject> {
 
-    static AtomicBoolean keyZeroCreated = new AtomicBoolean(false);
+    static final AtomicBoolean KEY_ZERO_CREATED = new AtomicBoolean(false);
 
     @Override
     public void afterCreate(EntryEvent<Integer, DeltaEnabledObject> event) {
-      keyZeroCreated.set(true);
+      KEY_ZERO_CREATED.set(true);
     }
   }
 
@@ -274,11 +274,13 @@ public class ClientProxyWithDeltaTest implements Serializable {
    */
   private static class DeltaEnabledObject implements Delta, DataSerializable {
 
-    private static final AtomicBoolean fromDeltaInvoked = new AtomicBoolean();
+    private static final AtomicBoolean FROM_DELTA_INVOKED = new AtomicBoolean();
 
     private int value = 0;
 
-    public DeltaEnabledObject() {}
+    public DeltaEnabledObject() {
+      // nothing
+    }
 
     public void setValue(int value) {
       this.value = value;
@@ -286,8 +288,8 @@ public class ClientProxyWithDeltaTest implements Serializable {
 
     @Override
     public void fromDelta(DataInput in) throws IOException {
-      fromDeltaInvoked.set(true);
-      this.value = DataSerializer.readPrimitiveInt(in);
+      FROM_DELTA_INVOKED.set(true);
+      value = DataSerializer.readPrimitiveInt(in);
     }
 
     @Override
@@ -297,15 +299,15 @@ public class ClientProxyWithDeltaTest implements Serializable {
 
     @Override
     public void toDelta(DataOutput out) throws IOException {
-      DataSerializer.writePrimitiveInt(this.value, out);
+      DataSerializer.writePrimitiveInt(value, out);
     }
 
     static void resetFromDeltaInvoked() {
-      fromDeltaInvoked.set(false);
+      FROM_DELTA_INVOKED.set(false);
     }
 
     static boolean fromDeltaInvoked() {
-      return fromDeltaInvoked.get();
+      return FROM_DELTA_INVOKED.get();
     }
 
     @Override
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
similarity index 99%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
index a655ad5..1656f1e 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/ClientWithInterestFailoverDistributedTest.java
@@ -57,7 +57,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class ClientWithInterestFailoverTest implements Serializable {
+public class ClientWithInterestFailoverDistributedTest implements Serializable {
 
   private static final String PROXY_REGION_NAME = "PROXY_REGION_NAME";
   private static final String CACHING_PROXY_REGION_NAME = "CACHING_PROXY_REGION_NAME";
@@ -66,13 +66,14 @@ public class ClientWithInterestFailoverTest implements Serializable {
   private static InternalCache cache;
   private static InternalClientCache clientCache;
 
-  private VM client;
-  private VM server;
-  private VM server2;
   private int serverPort1;
   private int serverPort2;
   private int primaryServerPort;
 
+  private VM client;
+  private VM server;
+  private VM server2;
+
   @ClassRule
   public static DistributedTestRule distributedTestRule = new DistributedTestRule();
 
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
similarity index 99%
rename from geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataTest.java
rename to geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
index 0511d4b..f97a6e2 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/RegisterInterestServerMetaDataDistributedTest.java
@@ -56,7 +56,7 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 @SuppressWarnings("serial")
-public class RegisterInterestServerMetaDataTest implements Serializable {
+public class RegisterInterestServerMetaDataDistributedTest implements Serializable {
 
   private static final String PROXY_REGION_NAME = "PROXY_REGION_NAME";
   private static final String CACHING_PROXY_REGION_NAME = "CACHING_PROXY_REGION_NAME";
@@ -65,10 +65,10 @@ public class RegisterInterestServerMetaDataTest implements Serializable {
   private static InternalClientCache clientCache;
 
   private String hostName;
+  private int serverPort1;
 
   private VM server;
   private VM client;
-  private int serverPort1;
 
   @ClassRule
   public static DistributedTestRule distributedTestRule = new DistributedTestRule();
diff --git a/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
index 69617be..1056b0e 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java
@@ -30,6 +30,18 @@ import org.junit.rules.TemporaryFolder;
 
 import org.apache.geode.test.junit.categories.IntegrationTest;
 
+/**
+ * StatArchiveReader should throw IllegalStateException with detailed information instead of
+ * throwing NullPointerException when encountering a Geode Stats file (.gfs) with a missing
+ * ResourceType.
+ *
+ * <p>
+ * {@code StatArchiveWithMissingResourceTypeRegressionTest.gfs} was hacked to have a missing
+ * ResourceType. There is no way to generate an equivalent .gfs file.
+ *
+ * <p>
+ * GEODE-2013: StatArchiveReader throws NullPointerException due to missing ResourceType
+ */
 @Category(IntegrationTest.class)
 public class StatArchiveWithMissingResourceTypeRegressionTest {
 
@@ -46,9 +58,9 @@ public class StatArchiveWithMissingResourceTypeRegressionTest {
     URL url = getClass().getResource(ARCHIVE_FILE_NAME);
     assertThat(url).isNotNull(); // precondition
 
-    this.archiveFile = this.temporaryFolder.newFile(ARCHIVE_FILE_NAME);
-    FileUtils.copyURLToFile(url, this.archiveFile);
-    assertThat(this.archiveFile).exists(); // precondition
+    archiveFile = temporaryFolder.newFile(ARCHIVE_FILE_NAME);
+    FileUtils.copyURLToFile(url, archiveFile);
+    assertThat(archiveFile).exists(); // precondition
   }
 
   @After
@@ -56,9 +68,9 @@ public class StatArchiveWithMissingResourceTypeRegressionTest {
     StatisticsTypeFactoryImpl.clear();
   }
 
-  @Test // fixed GEODE-2013
+  @Test
   public void throwsIllegalStateExceptionWithMessage() throws Exception {
-    assertThatThrownBy(() -> new StatArchiveReader(new File[] {this.archiveFile}, null, true))
+    assertThatThrownBy(() -> new StatArchiveReader(new File[] {archiveFile}, null, true))
         .isExactlyInstanceOf(IllegalStateException.class) // was NullPointerException
         .hasMessageStartingWith("ResourceType is missing for resourceTypeId 0")
         .hasMessageContaining("resourceName statistics1");
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/beans/CacheServerBridgeClientMembershipRegressionTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/beans/CacheServerBridgeClientMembershipRegressionTest.java
index 1cc73c3..8702a34 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/beans/CacheServerBridgeClientMembershipRegressionTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/beans/CacheServerBridgeClientMembershipRegressionTest.java
@@ -31,9 +31,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.query.QueryService;
 import org.apache.geode.cache.query.internal.InternalQueryService;
 import org.apache.geode.internal.cache.CacheServerImpl;
 import org.apache.geode.internal.cache.InternalCache;
@@ -43,7 +41,7 @@ import org.apache.geode.management.internal.beans.stats.MBeanStatsMonitor;
 import org.apache.geode.test.junit.categories.UnitTest;
 
 /**
- * Regression test that confirms bug GEODE-3407.
+ * JMX and membership should not deadlock on CacheFactory.getAnyInstance.
  *
  * <p>
  * GEODE-3407: JMX and membership may deadlock on CacheFactory.getAnyInstance
@@ -54,8 +52,6 @@ public class CacheServerBridgeClientMembershipRegressionTest {
   private final AtomicBoolean after = new AtomicBoolean();
   private final AtomicBoolean before = new AtomicBoolean();
 
-  private CacheServerBridge cacheServerBridge;
-
   private ExecutorService synchronizing;
   private ExecutorService blocking;
   private CountDownLatch latch;
@@ -65,16 +61,18 @@ public class CacheServerBridgeClientMembershipRegressionTest {
   private AcceptorImpl acceptor;
   private MBeanStatsMonitor monitor;
 
+  private CacheServerBridge cacheServerBridge;
+
   @Before
   public void setUp() throws Exception {
-    this.synchronizing = Executors.newSingleThreadExecutor();
-    this.blocking = Executors.newSingleThreadExecutor();
-    this.latch = new CountDownLatch(1);
+    synchronizing = Executors.newSingleThreadExecutor();
+    blocking = Executors.newSingleThreadExecutor();
+    latch = new CountDownLatch(1);
 
-    this.cache = mock(InternalCache.class);
-    this.cacheServer = mock(CacheServerImpl.class);
-    this.acceptor = mock(AcceptorImpl.class);
-    this.monitor = mock(MBeanStatsMonitor.class);
+    cache = mock(InternalCache.class);
+    cacheServer = mock(CacheServerImpl.class);
+    acceptor = mock(AcceptorImpl.class);
+    monitor = mock(MBeanStatsMonitor.class);
 
     when(cache.getQueryService()).thenReturn(mock(InternalQueryService.class));
     when(acceptor.getStats()).thenReturn(mock(CacheServerStats.class));
@@ -99,7 +97,6 @@ public class CacheServerBridgeClientMembershipRegressionTest {
         // getNumSubscriptions -> getClientQueueSizes -> synchronizes on CacheFactory
         cacheServerBridge.getNumSubscriptions();
 
-      } catch (CacheClosedException ignored) {
       } finally {
         after.set(true);
       }
@@ -126,5 +123,4 @@ public class CacheServerBridgeClientMembershipRegressionTest {
   private void givenCacheServerBridge() {
     cacheServerBridge = new CacheServerBridge(cache, cacheServer, acceptor, monitor);
   }
-
 }
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/VM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/VM.java
index f1e371b..22a99c0 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/VM.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/VM.java
@@ -20,7 +20,6 @@ import java.io.Serializable;
 import java.io.StringWriter;
 import java.rmi.RemoteException;
 import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import hydra.MethExecutorResult;
 import org.awaitility.Awaitility;
@@ -38,7 +37,7 @@ import org.apache.geode.test.dunit.standalone.VersionManager;
 public class VM implements Serializable {
 
   /** The host on which this VM runs */
-  private Host host;
+  private final Host host;
 
   /** The sequential id of this VM */
   private int id;
@@ -64,8 +63,8 @@ public class VM implements Serializable {
    * restart an unavailable VM
    */
   public synchronized void makeAvailable() {
-    if (!this.available) {
-      this.available = true;
+    if (!available) {
+      available = true;
       bounce();
     }
   }
@@ -86,7 +85,7 @@ public class VM implements Serializable {
   /**
    * Returns the name of a VM for use in the RMI naming service or working directory on disk
    */
-  public static String getVMName(String version, int pid) {
+  public static String getVMName(final String version, final int pid) {
     if (pid == -2) {
       return "locator";
     }
@@ -100,7 +99,7 @@ public class VM implements Serializable {
   /**
    * Creates a new {@code VM} that runs on a given host with a given process id.
    */
-  public VM(final Host host, int id, final RemoteDUnitVMIF client) {
+  public VM(final Host host, final int id, final RemoteDUnitVMIF client) {
     this(host, VersionManager.CURRENT_VERSION, id, client);
   }
 
@@ -109,14 +108,14 @@ public class VM implements Serializable {
     this.id = id;
     this.version = version;
     this.client = client;
-    this.available = true;
+    available = true;
   }
 
   /**
    * Returns the {@code Host} on which this {@code VM} is running.
    */
   public Host getHost() {
-    return this.host;
+    return host;
   }
 
   /**
@@ -126,14 +125,14 @@ public class VM implements Serializable {
    * @see Host#getVM(String, int)
    */
   public String getVersion() {
-    return this.version;
+    return version;
   }
 
   /**
    * Returns the VM id of this {@code VM}.
    */
   public int getId() {
-    return this.id;
+    return id;
   }
 
   /**
@@ -154,7 +153,8 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
    */
-  public Object invoke(final Class targetClass, final String methodName) {
+  @Deprecated
+  public <V> V invoke(final Class<?> targetClass, final String methodName) {
     return invoke(targetClass, methodName, new Object[0]);
   }
 
@@ -167,7 +167,8 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
    */
-  public AsyncInvocation invokeAsync(final Class targetClass, final String methodName) {
+  @Deprecated
+  public <V> AsyncInvocation<V> invokeAsync(final Class<?> targetClass, final String methodName) {
     return invokeAsync(targetClass, methodName, null);
   }
 
@@ -184,8 +185,9 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
    */
-  public Object invoke(final Class targetClass, final String methodName, final Object[] args) {
-    if (!this.available) {
+  @Deprecated
+  public <V> V invoke(final Class<?> targetClass, final String methodName, final Object[] args) {
+    if (!available) {
       throw new RMIException(this, targetClass.getName(), methodName,
           new IllegalStateException("VM not available: " + this));
     }
@@ -193,7 +195,7 @@ public class VM implements Serializable {
     MethExecutorResult result = execute(targetClass, methodName, args);
 
     if (!result.exceptionOccurred()) {
-      return result.getResult();
+      return (V) result.getResult();
 
     } else {
       throw new RMIException(this, targetClass.getName(), methodName, result.getException(),
@@ -211,9 +213,10 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
    */
-  public AsyncInvocation invokeAsync(final Object targetObject, final String methodName,
+  @Deprecated
+  public <V> AsyncInvocation<V> invokeAsync(final Object targetObject, final String methodName,
       final Object[] args) {
-    return new AsyncInvocation(targetObject, methodName,
+    return new AsyncInvocation<V>(targetObject, methodName,
         () -> invoke(targetObject, methodName, args)).start();
   }
 
@@ -227,10 +230,11 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead
    */
-  public AsyncInvocation invokeAsync(final Class<?> targetClass, final String methodName,
+  @Deprecated
+  public <V> AsyncInvocation<V> invokeAsync(final Class<?> targetClass, final String methodName,
       final Object[] args) {
-    return new AsyncInvocation(targetClass, methodName, () -> invoke(targetClass, methodName, args))
-        .start();
+    return new AsyncInvocation<V>(targetClass, methodName,
+        () -> invoke(targetClass, methodName, args)).start();
   }
 
   /**
@@ -241,7 +245,7 @@ public class VM implements Serializable {
    *
    * @see SerializableRunnable
    */
-  public AsyncInvocation invokeAsync(final SerializableRunnableIF runnable) {
+  public <V> AsyncInvocation<V> invokeAsync(final SerializableRunnableIF runnable) {
     return invokeAsync(runnable, "run", new Object[0]);
   }
 
@@ -255,7 +259,8 @@ public class VM implements Serializable {
    *
    * @see SerializableRunnable
    */
-  public AsyncInvocation invokeAsync(final String name, final SerializableRunnableIF runnable) {
+  public <V> AsyncInvocation<V> invokeAsync(final String name,
+      final SerializableRunnableIF runnable) {
     return invokeAsync(new NamedRunnable(name, runnable), "run", new Object[0]);
   }
 
@@ -267,9 +272,9 @@ public class VM implements Serializable {
    *
    * @see SerializableCallable
    */
-  public <T> AsyncInvocation<T> invokeAsync(final String name,
-      final SerializableCallableIF<T> callable) {
-    return invokeAsync(new NamedCallable(name, callable), "call", new Object[0]);
+  public <V> AsyncInvocation<V> invokeAsync(final String name,
+      final SerializableCallableIF<V> callable) {
+    return invokeAsync(new NamedCallable<>(name, callable), "call", new Object[0]);
   }
 
   /**
@@ -279,7 +284,7 @@ public class VM implements Serializable {
    *
    * @see SerializableCallable
    */
-  public <T> AsyncInvocation<T> invokeAsync(final SerializableCallableIF<T> callable) {
+  public <V> AsyncInvocation<V> invokeAsync(final SerializableCallableIF<V> callable) {
     return invokeAsync(callable, "call", new Object[0]);
   }
 
@@ -316,8 +321,8 @@ public class VM implements Serializable {
    *
    * @see SerializableCallable
    */
-  public <T> T invoke(final String name, final SerializableCallableIF<T> callable) {
-    return (T) invoke(new NamedCallable(name, callable), "call");
+  public <V> V invoke(final String name, final SerializableCallableIF<V> callable) {
+    return invoke(new NamedCallable<>(name, callable), "call");
   }
 
   /**
@@ -327,8 +332,8 @@ public class VM implements Serializable {
    *
    * @see SerializableCallable
    */
-  public <T> T invoke(final SerializableCallableIF<T> callable) {
-    return (T) invoke(callable, "call");
+  public <V> V invoke(final SerializableCallableIF<V> callable) {
+    return invoke(callable, "call");
   }
 
   /**
@@ -341,6 +346,7 @@ public class VM implements Serializable {
    * @deprecated Please use {@link Awaitility} to await condition and then
    *             {@link #invoke(SerializableCallableIF)} instead.
    */
+  @Deprecated
   public void invokeRepeatingIfNecessary(final RepeatableRunnable runnable,
       final long repeatTimeoutMs) {
     invoke(runnable, "runRepeatingIfNecessary", new Object[] {repeatTimeoutMs});
@@ -359,7 +365,8 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead.
    */
-  public Object invoke(final Object targetObject, final String methodName) {
+  @Deprecated
+  public <V> V invoke(final Object targetObject, final String methodName) {
     return invoke(targetObject, methodName, new Object[0]);
   }
 
@@ -377,8 +384,9 @@ public class VM implements Serializable {
    *
    * @deprecated Please use {@link #invoke(SerializableCallableIF)} instead.
    */
-  public Object invoke(final Object targetObject, final String methodName, final Object[] args) {
-    if (!this.available) {
+  @Deprecated
+  public <V> V invoke(final Object targetObject, final String methodName, final Object[] args) {
+    if (!available) {
       throw new RMIException(this, targetObject.getClass().getName(), methodName,
           new IllegalStateException("VM not available: " + this));
     }
@@ -386,7 +394,7 @@ public class VM implements Serializable {
     MethExecutorResult result = execute(targetObject, methodName, args);
 
     if (!result.exceptionOccurred()) {
-      return result.getResult();
+      return (V) result.getResult();
 
     } else {
       throw new RMIException(this, targetObject.getClass().getName(), methodName,
@@ -402,43 +410,39 @@ public class VM implements Serializable {
    *
    * This method is currently not supported by the standalone DUnit runner.
    *
-   * @throws RMIException if an exception occurs while bouncing this {@code VM}, for example a
-   *         {@code HydraTimeoutException} if the {@code VM} fails to stop within
-   *         {@code hydra.Prms#maxClientShutdownWaitSec} or restart within
-   *         {@code hydra.Prms#maxClientStartupWaitSec}.
+   * @throws RMIException if an exception occurs while bouncing this {@code VM}
    */
   public synchronized void bounce() {
-    bounce(this.version);
+    bounce(version);
   }
 
-  public synchronized void bounce(String targetVersion) {
-    if (!this.available) {
+  public synchronized void bounce(final String targetVersion) {
+    if (!available) {
       throw new RMIException(this, getClass().getName(), "bounceVM",
           new IllegalStateException("VM not available: " + this));
     }
 
-    this.available = false;
+    available = false;
 
     try {
-      BounceResult result = DUnitEnv.get().bounce(targetVersion, this.id);
-      this.id = result.getNewId();
-      this.client = result.getNewClient();
-      this.version = targetVersion;
-      this.available = true;
+      BounceResult result = DUnitEnv.get().bounce(targetVersion, id);
+      id = result.getNewId();
+      client = result.getNewClient();
+      version = targetVersion;
+      available = true;
 
     } catch (UnsupportedOperationException e) {
-      this.available = true;
+      available = true;
       throw e;
 
     } catch (RemoteException e) {
       StringWriter sw = new StringWriter();
       e.printStackTrace(new PrintWriter(sw, true));
-      RMIException rmie =
-          new RMIException(this, getClass().getName(), "bounceVM", e, sw.toString());
-      throw rmie;
+      throw new RMIException(this, getClass().getName(), "bounceVM", e, sw.toString());
     }
   }
 
+  @Override
   public String toString() {
     return "VM " + getId() + " running on " + getHost()
         + (VersionManager.isCurrentVersion(version) ? "" : (" with version " + version));
@@ -448,10 +452,10 @@ public class VM implements Serializable {
     return DUnitEnv.get().getWorkingDirectory(getVersion(), getId());
   }
 
-  private MethExecutorResult execute(final Class targetClass, final String methodName,
+  private MethExecutorResult execute(final Class<?> targetClass, final String methodName,
       final Object[] args) {
     try {
-      return this.client.executeMethodOnClass(targetClass.getName(), methodName, args);
+      return client.executeMethodOnClass(targetClass.getName(), methodName, args);
     } catch (RemoteException exception) {
       throw new RMIException(this, targetClass.getName(), methodName, exception);
     }
@@ -461,9 +465,9 @@ public class VM implements Serializable {
       final Object[] args) {
     try {
       if (args == null) {
-        return this.client.executeMethodOnObject(targetObject, methodName);
+        return client.executeMethodOnObject(targetObject, methodName);
       } else {
-        return this.client.executeMethodOnObject(targetObject, methodName, args);
+        return client.executeMethodOnObject(targetObject, methodName, args);
       }
     } catch (RemoteException exception) {
       throw new RMIException(this, targetObject.getClass().getName(), methodName, exception);
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/CacheRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/CacheRule.java
index 06166db..42a3923 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/CacheRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/CacheRule.java
@@ -16,9 +16,9 @@ package org.apache.geode.test.dunit.rules;
 
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.apache.geode.test.dunit.DistributedTestUtils.getLocators;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 
@@ -57,7 +57,7 @@ import org.apache.geode.test.dunit.VM;
 @SuppressWarnings({"serial", "unused"})
 public class CacheRule extends DistributedExternalResource {
 
-  private static InternalCache cache;
+  private static volatile InternalCache cache;
 
   private final boolean createCacheInAll;
   private final boolean createCache;
@@ -71,22 +71,16 @@ public class CacheRule extends DistributedExternalResource {
   }
 
   public CacheRule() {
-    this.createCacheInAll = false;
-    this.createCache = false;
-    this.disconnectAfter = false;
-    this.createCacheInVMs = Collections.emptyList();
-    this.config = new Properties();
-    this.config.setProperty(LOCATORS, getLocators());
-    this.systemProperties = new Properties();
+    this(new Builder());
   }
 
   CacheRule(final Builder builder) {
-    this.createCacheInAll = builder.createCacheInAll;
-    this.createCache = builder.createCache;
-    this.disconnectAfter = builder.disconnectAfter;
-    this.createCacheInVMs = builder.createCacheInVMs;
-    this.config = builder.config;
-    this.systemProperties = builder.systemProperties;
+    createCacheInAll = builder.createCacheInAll;
+    createCache = builder.createCache;
+    disconnectAfter = builder.disconnectAfter;
+    createCacheInVMs = builder.createCacheInVMs;
+    config = builder.config;
+    systemProperties = builder.systemProperties;
   }
 
   @Override
@@ -121,16 +115,27 @@ public class CacheRule extends DistributedExternalResource {
     return cache.getInternalDistributedSystem();
   }
 
-  public InternalCache createCache() {
-    createCache(config, systemProperties);
-    return cache;
+  public void createCache() {
+    cache = (InternalCache) new CacheFactory(config).create();
+  }
+
+  public void createCache(final Properties config) {
+    cache = (InternalCache) new CacheFactory(config).create();
   }
 
-  private static void createCache(final Properties config, final Properties systemProperties) {
+  public void createCache(final Properties config, final Properties systemProperties) {
     System.getProperties().putAll(systemProperties);
     cache = (InternalCache) new CacheFactory(config).create();
   }
 
+  public InternalCache getOrCreateCache() {
+    if (cache == null) {
+      createCache();
+      assertThat(cache).isNotNull();
+    }
+    return cache;
+  }
+
   private static void closeAndNullCache() {
     closeCache();
     nullCache();
@@ -207,7 +212,7 @@ public class CacheRule extends DistributedExternalResource {
     }
 
     public Builder addConfig(final String key, final String value) {
-      this.config.put(key, value);
+      config.put(key, value);
       return this;
     }
 
@@ -217,12 +222,12 @@ public class CacheRule extends DistributedExternalResource {
     }
 
     public Builder addSystemProperty(final String key, final String value) {
-      this.systemProperties.put(key, value);
+      systemProperties.put(key, value);
       return this;
     }
 
     public Builder addSystemProperties(final Properties config) {
-      this.systemProperties.putAll(config);
+      systemProperties.putAll(config);
       return this;
     }
 
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/GatewayLegacyAuthenticationRegressionTest.java b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
similarity index 71%
rename from geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/GatewayLegacyAuthenticationRegressionTest.java
rename to geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
index c7ce6bd..a393272 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/misc/GatewayLegacyAuthenticationRegressionTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewayLegacyAuthenticationRegressionTest.java
@@ -12,7 +12,7 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-package org.apache.geode.internal.cache.wan.misc;
+package org.apache.geode.internal.cache.wan;
 
 import static java.util.concurrent.TimeUnit.MINUTES;
 import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
@@ -23,6 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_CLIE
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
 import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
 import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.internal.AvailablePortHelper.getRandomAvailableTCPPorts;
 import static org.apache.geode.test.dunit.Host.getHost;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.awaitility.Awaitility.await;
@@ -37,51 +38,47 @@ import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.junit.Before;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import org.apache.geode.LogWriter;
-import org.apache.geode.cache.AttributesFactory;
-import org.apache.geode.cache.Cache;
-import org.apache.geode.cache.CacheFactory;
-import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.DiskStore;
 import org.apache.geode.cache.DiskStoreFactory;
 import org.apache.geode.cache.Region;
-import org.apache.geode.cache.Scope;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.wan.GatewayReceiver;
 import org.apache.geode.cache.wan.GatewayReceiverFactory;
 import org.apache.geode.cache.wan.GatewaySender;
 import org.apache.geode.cache.wan.GatewaySenderFactory;
 import org.apache.geode.distributed.DistributedMember;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.AvailablePortHelper;
-import org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory;
 import org.apache.geode.security.AuthInitialize;
 import org.apache.geode.security.AuthenticationFailedException;
 import org.apache.geode.security.Authenticator;
-import org.apache.geode.test.dunit.DistributedTestCase;
 import org.apache.geode.test.dunit.VM;
+import org.apache.geode.test.dunit.rules.CacheRule;
+import org.apache.geode.test.dunit.rules.DistributedTestRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.apache.geode.test.junit.categories.WanTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 
 /**
- * Reproduces bug GEODE-3117: "Gateway authentication throws NullPointerException" and validates the
- * fix.
+ * Gateway authentication should not throw NullPointerException.
+ *
+ * <p>
+ * GEODE-3117: "Gateway authentication throws NullPointerException"
  */
 @Category({DistributedTest.class, SecurityTest.class, WanTest.class})
-public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCase {
+public class GatewayLegacyAuthenticationRegressionTest implements Serializable {
 
+  private static final String REGION_NAME = "TheRegion";
   private static final String USER_NAME = "security-username";
   private static final String PASSWORD = "security-password";
 
-  private static final AtomicInteger invokeAuthenticateCount = new AtomicInteger();
-
-  private static Cache cache;
-  private static GatewaySender sender;
+  private static final AtomicInteger AUTHENTICATE_COUNT = new AtomicInteger();
 
   private VM londonLocatorVM;
   private VM newYorkLocatorVM;
@@ -96,32 +93,38 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
 
   private int londonLocatorPort;
   private int newYorkLocatorPort;
+  private int londonReceiverPort;
+  private int newYorkReceiverPort;
+
+  @ClassRule
+  public static DistributedTestRule distributedTestRule = new DistributedTestRule();
 
-  private String regionName;
+  @Rule
+  public CacheRule cacheRule = new CacheRule();
 
   @Rule
   public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
 
   @Before
   public void before() {
-    invokeAuthenticateCount.set(0);
-
-    this.londonLocatorVM = getHost(0).getVM(0);
-    this.newYorkLocatorVM = getHost(0).getVM(1);
-    this.londonServerVM = getHost(0).getVM(2);
-    this.newYorkServerVM = getHost(0).getVM(3);
+    AUTHENTICATE_COUNT.set(0);
 
-    this.londonName = "ln";
-    this.newYorkName = "ny";
+    londonLocatorVM = getHost(0).getVM(0);
+    newYorkLocatorVM = getHost(0).getVM(1);
+    londonServerVM = getHost(0).getVM(2);
+    newYorkServerVM = getHost(0).getVM(3);
 
-    this.londonId = 1;
-    this.newYorkId = 2;
+    londonName = "ln";
+    newYorkName = "ny";
 
-    this.regionName = getTestMethodName() + "_RR";
+    londonId = 1;
+    newYorkId = 2;
 
-    int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    this.londonLocatorPort = ports[0];
-    this.newYorkLocatorPort = ports[1];
+    int[] ports = getRandomAvailableTCPPorts(4);
+    londonLocatorPort = ports[0];
+    newYorkLocatorPort = ports[1];
+    londonReceiverPort = ports[2];
+    newYorkReceiverPort = ports[3];
   }
 
   /**
@@ -130,62 +133,64 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
    */
   @Test
   public void gatewayHandShakeShouldAuthenticate() {
-    this.londonLocatorVM.invoke("start London locator", () -> {
-      getSystem(
-          createLocatorConfig(this.londonId, this.londonLocatorPort, this.newYorkLocatorPort));
+    londonLocatorVM.invoke("start London locator", () -> {
+      Properties config = createLocatorConfig(londonId, londonLocatorPort, newYorkLocatorPort);
+      cacheRule.createCache(config);
     });
 
-    this.newYorkLocatorVM.invoke("start New York locator", () -> {
-      getSystem(
-          createLocatorConfig(this.newYorkId, this.newYorkLocatorPort, this.londonLocatorPort));
+    newYorkLocatorVM.invoke("start New York locator", () -> {
+      Properties config = createLocatorConfig(newYorkId, newYorkLocatorPort, londonLocatorPort);
+      cacheRule.createCache(config);
     });
 
-    this.londonServerVM.invoke("create London server", () -> {
-      assertThat(invokeAuthenticateCount.get()).isEqualTo(0);
-      startServer(this.londonId, this.londonLocatorPort, this.newYorkId, this.newYorkName);
+    londonServerVM.invoke("create London server", () -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isEqualTo(0);
+      startServer(londonId, londonLocatorPort, newYorkId, newYorkName, londonReceiverPort);
     });
 
-    this.newYorkServerVM.invoke("create New York server", () -> {
-      assertThat(invokeAuthenticateCount.get()).isEqualTo(0);
-      startServer(this.newYorkId, this.newYorkLocatorPort, this.londonId, this.londonName);
+    newYorkServerVM.invoke("create New York server", () -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isEqualTo(0);
+      startServer(newYorkId, newYorkLocatorPort, londonId, londonName, newYorkReceiverPort);
     });
 
-    this.londonServerVM.invoke(() -> {
+    londonServerVM.invoke(() -> {
+      GatewaySender sender = cacheRule.getCache().getGatewaySender(newYorkName);
       await().atMost(1, MINUTES).until(() -> assertThat(isRunning(sender)).isTrue());
     });
 
-    this.newYorkServerVM.invoke(() -> {
+    newYorkServerVM.invoke(() -> {
+      GatewaySender sender = cacheRule.getCache().getGatewaySender(londonName);
       await().atMost(1, MINUTES).until(() -> assertThat(isRunning(sender)).isTrue());
     });
 
-    this.newYorkServerVM.invoke(() -> {
-      Region region = cache.getRegion(Region.SEPARATOR + this.regionName);
+    newYorkServerVM.invoke(() -> {
+      Region<Integer, Integer> region = cacheRule.getCache().getRegion(REGION_NAME);
       assertThat(region).isNotNull();
       assertThat(region.isEmpty()).isTrue();
     });
 
-    this.londonServerVM.invoke(() -> {
-      Region region = cache.getRegion(Region.SEPARATOR + this.regionName);
+    londonServerVM.invoke(() -> {
+      Region<Integer, Integer> region = cacheRule.getCache().getRegion(REGION_NAME);
       region.put(0, 0);
     });
 
-    this.newYorkServerVM.invoke(() -> {
-      Region region = cache.getRegion(Region.SEPARATOR + this.regionName);
+    newYorkServerVM.invoke(() -> {
+      Region<Integer, Integer> region = cacheRule.getCache().getRegion(REGION_NAME);
       assertThat(region).isNotNull();
       waitAtMost(1, MINUTES).until(() -> assertThat(region.isEmpty()).isFalse());
     });
 
-    this.newYorkLocatorVM.invoke(() -> {
-      assertThat(invokeAuthenticateCount.get()).isEqualTo(0);
+    newYorkLocatorVM.invoke(() -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isEqualTo(0);
     });
-    this.londonLocatorVM.invoke(() -> {
-      assertThat(invokeAuthenticateCount.get()).isEqualTo(0);
+    londonLocatorVM.invoke(() -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isEqualTo(0);
     });
-    this.newYorkServerVM.invoke(() -> {
-      assertThat(invokeAuthenticateCount.get()).isGreaterThanOrEqualTo(1);
+    newYorkServerVM.invoke(() -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isGreaterThanOrEqualTo(1);
     });
-    this.londonServerVM.invoke(() -> {
-      assertThat(invokeAuthenticateCount.get()).isGreaterThanOrEqualTo(1);
+    londonServerVM.invoke(() -> {
+      assertThat(AUTHENTICATE_COUNT.get()).isGreaterThanOrEqualTo(1);
     });
   }
 
@@ -194,7 +199,7 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
   }
 
   private Properties createLocatorConfig(int systemId, int locatorPort, int remoteLocatorPort) {
-    Properties config = getDistributedSystemProperties();
+    Properties config = new Properties();
     config.setProperty(MCAST_PORT, "0");
     config.setProperty(DISTRIBUTED_SYSTEM_ID, String.valueOf(systemId));
     config.setProperty(LOCATORS, "localhost[" + locatorPort + ']');
@@ -223,43 +228,40 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
     return config;
   }
 
-  private void startServer(int systemId, int locatorPort, int remoteSystemId, String remoteName)
-      throws IOException {
-    DistributedSystem system = getSystem(createServerConfig(locatorPort));
-    cache = CacheFactory.create(system);
+  private void startServer(int systemId, int locatorPort, int remoteSystemId, String remoteName,
+      int receiverPort) throws IOException {
+    cacheRule.createCache(createServerConfig(locatorPort));
 
     String uniqueName = "server-" + systemId;
-    File[] dirs = new File[] {this.temporaryFolder.newFolder(uniqueName)};
+    File[] dirs = new File[] {temporaryFolder.newFolder(uniqueName)};
 
     GatewaySenderFactory senderFactory = createGatewaySenderFactory(dirs, uniqueName);
-    sender = senderFactory.create(remoteName, remoteSystemId);
+    GatewaySender sender = senderFactory.create(remoteName, remoteSystemId);
     sender.start();
 
-    GatewayReceiverFactory receiverFactory = createGatewayReceiverFactory();
+    GatewayReceiverFactory receiverFactory = createGatewayReceiverFactory(receiverPort);
     GatewayReceiver receiver = receiverFactory.create();
     receiver.start();
 
-    AttributesFactory attributesFactory = new AttributesFactory();
-    attributesFactory.addGatewaySenderId(remoteName);
-    attributesFactory.setDataPolicy(DataPolicy.REPLICATE);
-    attributesFactory.setScope(Scope.DISTRIBUTED_ACK);
-    cache.createRegionFactory(attributesFactory.create()).create(this.regionName);
-  }
+    RegionFactory<Integer, Integer> regionFactory =
+        cacheRule.getCache().createRegionFactory(RegionShortcut.REPLICATE);
+    regionFactory.addGatewaySenderId(remoteName);
 
-  private GatewayReceiverFactory createGatewayReceiverFactory() {
-    GatewayReceiverFactory receiverFactory = cache.createGatewayReceiverFactory();
+    regionFactory.create(REGION_NAME);
+  }
 
-    int port = AvailablePortHelper.getRandomAvailableTCPPort();
+  private GatewayReceiverFactory createGatewayReceiverFactory(int receiverPort) {
+    GatewayReceiverFactory receiverFactory = cacheRule.getCache().createGatewayReceiverFactory();
 
-    receiverFactory.setStartPort(port);
-    receiverFactory.setEndPort(port);
+    receiverFactory.setStartPort(receiverPort);
+    receiverFactory.setEndPort(receiverPort);
     receiverFactory.setManualStart(true);
     return receiverFactory;
   }
 
   private GatewaySenderFactory createGatewaySenderFactory(File[] dirs, String diskStoreName) {
     InternalGatewaySenderFactory senderFactory =
-        (InternalGatewaySenderFactory) cache.createGatewaySenderFactory();
+        (InternalGatewaySenderFactory) cacheRule.getCache().createGatewaySenderFactory();
 
     senderFactory.setMaximumQueueMemory(100);
     senderFactory.setBatchSize(10);
@@ -268,35 +270,31 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
     senderFactory.setDispatcherThreads(1);
     senderFactory.setOrderPolicy(GatewaySender.DEFAULT_ORDER_POLICY);
 
-    DiskStoreFactory dsf = cache.createDiskStoreFactory();
+    DiskStoreFactory dsf = cacheRule.getCache().createDiskStoreFactory();
     DiskStore store = dsf.setDiskDirs(dirs).create(diskStoreName);
     senderFactory.setDiskStoreName(store.getName());
 
     return senderFactory;
   }
 
-  static class TestPrincipal implements Principal, Serializable {
+  private static class TestPrincipal implements Principal, Serializable {
 
     private final String userName;
     private final UUID uuid;
 
     TestPrincipal(String userName) {
       this.userName = userName;
-      this.uuid = UUID.randomUUID();
+      uuid = UUID.randomUUID();
     }
 
     @Override
     public String getName() {
-      return this.userName;
-    }
-
-    public UUID getUUID() {
-      return this.uuid;
+      return userName;
     }
 
     @Override
     public String toString() {
-      return this.userName + "->" + this.uuid;
+      return userName + "->" + uuid;
     }
   }
 
@@ -396,7 +394,7 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
     @Override
     public Principal authenticate(Properties props, DistributedMember member)
         throws AuthenticationFailedException {
-      invokeAuthenticateCount.incrementAndGet();
+      AUTHENTICATE_COUNT.incrementAndGet();
 
       System.out.println(
           Thread.currentThread().getName() + ": TestClientOrReceiverAuthenticator authenticating "
@@ -419,5 +417,4 @@ public class GatewayLegacyAuthenticationRegressionTest extends DistributedTestCa
       // nothing
     }
   }
-
 }

-- 
To stop receiving notification emails like this one, please contact
klund@apache.org.