geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstew...@apache.org
Subject [38/50] [abbrv] geode git commit: GEODE-2267: Enhance server/locator startup rules
Date Mon, 13 Mar 2017 17:43:05 GMT
GEODE-2267: Enhance server/locator startup rules

* be able to return the rule itself so that we can start the server/locator at rule declaration time.
* rearrange the class structure
* do not delete the workingDir if the rule is created with a workingDir (then it's up for the caller to delete it)


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

Branch: refs/heads/GEODE-2290
Commit: 5ca8dda8e8f10f7f548e075a352b63051a6904cf
Parents: c7c28f0
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Thu Mar 2 15:58:18 2017 -0800
Committer: Kevin J. Duling <kduling@pivotal.io>
Committed: Wed Mar 8 10:43:29 2017 -0800

----------------------------------------------------------------------
 .../web/RestSecurityIntegrationTest.java        |  5 +-
 .../web/RestSecurityPostProcessorTest.java      |  5 +-
 .../geode/tools/pulse/PulseDataExportTest.java  |  6 +-
 .../ConnectToLocatorSSLDUnitTest.java           |  4 +-
 .../internal/cli/NetstatDUnitTest.java          |  4 +-
 .../cli/commands/ExportLogsDUnitTest.java       | 15 ++--
 .../ExportLogsOnServerManagerDUnit.java         |  7 +-
 .../cli/commands/ExportStatsDUnitTest.java      |  4 +-
 .../internal/cli/util/MergeLogsDUnitTest.java   |  9 +-
 .../internal/configuration/ClusterConfig.java   | 28 +++---
 .../ClusterConfigDeployJarDUnitTest.java        | 29 +++---
 .../ClusterConfigDistributionDUnitTest.java     |  9 +-
 .../ClusterConfigImportDUnitTest.java           | 45 +++++-----
 .../ClusterConfigStartMemberDUnitTest.java      | 19 ++--
 .../ClusterConfigWithSecurityDUnitTest.java     | 10 +--
 .../security/CacheServerStartupRule.java        |  6 +-
 .../security/GfshCommandsPostProcessorTest.java |  6 +-
 .../security/GfshCommandsSecurityTest.java      |  5 +-
 .../security/AbstractSecureServerDUnitTest.java |  8 +-
 .../ClusterConfigWithoutSecurityDUnitTest.java  |  2 +-
 .../SecurityClusterConfigDUnitTest.java         |  4 +-
 .../SecurityWithoutClusterConfigDUnitTest.java  |  2 +-
 .../security/StartServerAuthorizationTest.java  |  3 +-
 .../dunit/rules/GfshShellConnectionRule.java    |  4 +-
 .../apache/geode/test/dunit/rules/Locator.java  |  9 +-
 .../dunit/rules/LocatorServerStartupRule.java   | 34 ++++---
 .../test/dunit/rules/LocatorStarterRule.java    | 54 ++++-------
 .../apache/geode/test/dunit/rules/Member.java   | 53 ++---------
 .../test/dunit/rules/MemberStarterRule.java     | 84 +++++++++++++++++
 .../apache/geode/test/dunit/rules/MemberVM.java | 67 ++++++++++++++
 .../apache/geode/test/dunit/rules/Server.java   | 12 +--
 .../test/dunit/rules/ServerStarterRule.java     | 95 ++++++++++----------
 .../LuceneClusterConfigurationDUnitTest.java    | 51 ++++++-----
 33 files changed, 391 insertions(+), 307 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
index 75a3c2c..85fc5be 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityIntegrationTest.java
@@ -58,13 +58,12 @@ public class RestSecurityIntegrationTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
index 933f7b2..82e9b7f 100644
--- a/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/rest/internal/web/RestSecurityPostProcessorTest.java
@@ -65,14 +65,13 @@ public class RestSecurityPostProcessorTest {
   };
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
   private final GeodeRestClient restClient = new GeodeRestClient("localhost", restPort);
 
   @BeforeClass
   public static void before() throws Exception {
-    serverStarter.startServer(properties);
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("customers");
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("customers");
     region.put("1", new Customer(1L, "John", "Doe", "555555555"));
     region.put("2", new Customer(2L, "Richard", "Roe", "222533554"));
     region.put("3", new Customer(3L, "Jane", "Doe", "555223333"));

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
index fa98ce6..b9e90b6 100644
--- a/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/tools/pulse/PulseDataExportTest.java
@@ -23,8 +23,8 @@ import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.ClientRegionShortcut;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.http.Consts;
@@ -64,8 +64,8 @@ public class PulseDataExportTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
 
-  private Locator locator;
-  private org.apache.geode.test.dunit.rules.Server server;
+  private MemberVM locator;
+  private MemberVM server;
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
   private HttpClient httpClient;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
index 101c8f5..1033b6c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/ConnectToLocatorSSLDUnitTest.java
@@ -39,8 +39,8 @@ import static org.apache.geode.util.test.TestUtil.getResourcePath;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.security.SecurableCommunicationChannels;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.serializable.SerializableTemporaryFolder;
 import org.junit.After;
@@ -83,7 +83,7 @@ public class ConnectToLocatorSSLDUnitTest {
   }
 
   private void setUpLocatorAndConnect(Properties securityProps) throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, securityProps);
+    MemberVM locator = lsRule.startLocatorVM(0, securityProps);
 
     // saving the securityProps to a file
     OutputStream out = new FileOutputStream(securityPropsFile);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index 8ac993b..5b2d302 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -18,7 +18,7 @@ package org.apache.geode.management.internal.cli;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.junit.After;
@@ -58,7 +58,7 @@ public class NetstatDUnitTest {
     // start server with jmx Manager as well
     properties.remove("start-locator");
     properties.setProperty("jmx-manager-port", ports[2] + "");
-    Server server = lsRule.startServerVM(1, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
 
     // start server with no jmx Manager
     properties.setProperty("jmx-manager", "false");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index e882cce..bf1d9ea 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -34,10 +34,9 @@ import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.Member;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.FlakyTest;
 import org.apache.logging.log4j.Logger;
@@ -72,11 +71,11 @@ public class ExportLogsDUnitTest {
   @Rule
   public GfshShellConnectionRule gfshConnector = new GfshShellConnectionRule();
 
-  private Locator locator;
-  private Server server1;
-  private Server server2;
+  private MemberVM locator;
+  private MemberVM server1;
+  private MemberVM server2;
 
-  private Map<Member, List<LogLine>> expectedMessages;
+  private Map<MemberVM, List<LogLine>> expectedMessages;
 
   @Before
   public void setup() throws Exception {
@@ -95,7 +94,7 @@ public class ExportLogsDUnitTest {
     expectedMessages.put(server2, listOfLogLines(server2, "info", "error", "debug"));
 
     // log the messages in each of the members
-    for (Member member : expectedMessages.keySet()) {
+    for (MemberVM member : expectedMessages.keySet()) {
       List<LogLine> logLines = expectedMessages.get(member);
 
       member.invoke(() -> {
@@ -241,7 +240,7 @@ public class ExportLogsDUnitTest {
       throws IOException {
 
     String memberName = dirForMember.getName();
-    Member member = expectedMessages.keySet().stream()
+    MemberVM member = expectedMessages.keySet().stream()
         .filter((Member aMember) -> aMember.getName().equals(memberName)).findFirst().get();
 
     assertThat(member).isNotNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index 92ef5f5..c2fde4d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -22,6 +22,7 @@ import com.google.common.collect.Sets;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Rule;
@@ -46,7 +47,7 @@ public class ExportLogsOnServerManagerDUnit {
   @Test
   public void testExportWithOneServer() throws Exception {
     int jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    Server server0 = lsRule.startServerAsJmxManager(0, jmxPort);
+    MemberVM server0 = lsRule.startServerAsJmxManager(0, jmxPort);
     gfshConnector.connect(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
     gfshConnector.executeAndVerifyCommand("export logs");
 
@@ -66,8 +67,8 @@ public class ExportLogsOnServerManagerDUnit {
     int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
     int locatorPort = ports[0];
     int jmxPort = ports[1];
-    Server server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
-    Server server1 = lsRule.startServerVM(1, locatorPort);
+    MemberVM server0 = lsRule.startServerAsEmbededLocator(0, locatorPort, jmxPort);
+    MemberVM server1 = lsRule.startServerVM(1, locatorPort);
     gfshConnector.connect(locatorPort, GfshShellConnectionRule.PortType.locator);
     gfshConnector.executeAndVerifyCommand("export logs");
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
index f1ba7ef..b7f8c2a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportStatsDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.internal.AvailablePortHelper;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -58,7 +58,7 @@ public class ExportStatsDUnitTest {
 
   protected static int jmxPort, httpPort;
   protected static Set<String> expectedZipEntries = new HashSet<>();
-  protected static Locator locator;
+  protected static MemberVM locator;
 
   @BeforeClass
   public static void beforeClass() throws Exception {

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
index 80b9868..9166642 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/MergeLogsDUnitTest.java
@@ -22,9 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.commons.io.FileUtils;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -41,7 +40,7 @@ import java.util.Properties;
 public class MergeLogsDUnitTest {
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private Locator locator;
+  private MemberVM locator;
 
   private static final String MESSAGE_1 = "MergeLogsMessage1";
   private static final String MESSAGE_2 = "MergeLogsMessage2";
@@ -59,8 +58,8 @@ public class MergeLogsDUnitTest {
     properties.setProperty(DistributionConfig.LOCATORS_NAME,
         "localhost[" + locator.getPort() + "]");
 
-    Server server = lsRule.startServerVM(1, properties);
-    Server server2 = lsRule.startServerVM(2, properties);
+    MemberVM server = lsRule.startServerVM(1, properties);
+    MemberVM server2 = lsRule.startServerVM(2, properties);
 
     locator.invoke(() -> LogService.getLogger().info(MESSAGE_1));
     server.invoke(() -> LogService.getLogger().info(MESSAGE_2));

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
index 4ac9886..c3d7f5e 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfig.java
@@ -21,8 +21,8 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.cache.Cache;
-import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.distributed.internal.ClusterConfigurationService;
+import org.apache.geode.distributed.internal.InternalLocator;
 import org.apache.geode.internal.ClassPathLoader;
 import org.apache.geode.internal.JarClassLoader;
 import org.apache.geode.internal.JarDeployer;
@@ -31,7 +31,7 @@ import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Member;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.Server;
 
 import java.io.File;
@@ -77,21 +77,21 @@ public class ClusterConfig implements Serializable {
     return Collections.unmodifiableList(groups);
   }
 
-  public void verify(Locator locator) {
-    verifyLocator(locator);
-  }
 
-  public void verify(Server server) throws ClassNotFoundException {
-    verifyServer(server);
+  public void verify(MemberVM memberVM) throws ClassNotFoundException {
+    if (memberVM.isLocator())
+      verifyLocator(memberVM);
+    else
+      verifyServer(memberVM);
   }
 
-  public void verifyLocator(Member locator) {
+  public void verifyLocator(MemberVM<Locator> locatorVM) {
     Set<String> expectedGroupConfigs =
         this.getGroups().stream().map(ConfigGroup::getName).collect(Collectors.toSet());
 
     // verify info exists in memeory
-    locator.invoke(() -> {
-      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.locator;
+    locatorVM.invoke(() -> {
+      InternalLocator internalLocator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = internalLocator.getSharedConfiguration();
 
       // verify no extra configs exist in memory
@@ -120,7 +120,7 @@ public class ClusterConfig implements Serializable {
 
     });
 
-    File clusterConfigDir = new File(locator.getWorkingDir(), "/cluster_config");
+    File clusterConfigDir = new File(locatorVM.getWorkingDir(), "/cluster_config");
 
     for (ConfigGroup configGroup : this.getGroups()) {
       Set<String> actualFiles =
@@ -131,16 +131,16 @@ public class ClusterConfig implements Serializable {
     }
   }
 
-  public void verifyServer(Member server) throws ClassNotFoundException {
+  public void verifyServer(MemberVM<Server> serverVM) throws ClassNotFoundException {
     // verify files exist in filesystem
     Set<String> expectedJarNames = this.getJarNames().stream().map(ClusterConfig::getServerJarName)
         .collect(Collectors.toSet());
     Set<String> actualJarNames = toSetIgnoringHiddenFiles(
-        server.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
+        serverVM.getWorkingDir().list((dir, filename) -> filename.contains(".jar")));
     assertThat(actualJarNames).isEqualTo(expectedJarNames);
 
     // verify config exists in memory
-    server.invoke(() -> {
+    serverVM.invoke(() -> {
       Cache cache = GemFireCacheImpl.getInstance();
 
       // TODO: set compare to fail if there are extra regions

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index 15e6ea6..7cc84d6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -20,8 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -47,7 +46,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   public void testDeployToNoServer() throws Exception {
     String clusterJarPath = clusterJar;
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -59,18 +58,18 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
     expectedClusterConfig.verify(locator);
 
     // start a server and verify that the server gets the jar
-    Server server1 = lsRule.startServerVM(1, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, locator.getPort());
     expectedClusterConfig.verify(server1);
   }
 
   @Test
   public void testDeployToMultipleLocators() throws Exception {
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator2 = lsRule.startLocatorVM(1, locatorProps);
     locatorProps.setProperty(LOCATORS,
         "localhost[" + locator.getPort() + "],localhost[" + locator2.getPort() + "]");
-    Locator locator3 = lsRule.startLocatorVM(2, locatorProps);
+    MemberVM locator3 = lsRule.startLocatorVM(2, locatorProps);
 
     // has to start a server in order to run deploy command
     lsRule.startServerVM(3, serverProps, locator.getPort());
@@ -92,15 +91,15 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testDeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     // server1 in no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     // server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     // server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     gfshConnector.connect(locator);
     assertThat(gfshConnector.isConnected()).isTrue();
@@ -138,13 +137,13 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testUndeploy() throws Exception {
     // set up the locator/servers
-    Locator locator = lsRule.startLocatorVM(0, locatorProps);
+    MemberVM locator = lsRule.startLocatorVM(0, locatorProps);
     serverProps.setProperty(GROUPS, "group1");
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
 
     ConfigGroup cluster = new ConfigGroup("cluster");
     ConfigGroup group1 = new ConfigGroup("group1");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
index e134c42..abbc5c0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java
@@ -30,9 +30,8 @@ import org.apache.geode.internal.ClassBuilder;
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -51,7 +50,7 @@ public class ClusterConfigDistributionDUnitTest {
   private static final String INDEX2 = "ID2";
   private static final String AsyncEventQueue1 = "Q1";
 
-  private Locator locator;
+  private MemberVM locator;
 
   @Rule
   public LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
@@ -110,10 +109,10 @@ public class ClusterConfigDistributionDUnitTest {
     // Start a new member which receives the shared configuration
     // Verify the config creation on this member
 
-    Server server = lsRule.startServerVM(2, new Properties(), locator.getPort());
+    MemberVM server = lsRule.startServerVM(2, new Properties(), locator.getPort());
 
     server.invoke(() -> {
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       assertNotNull(cache);
       assertTrue(cache.getCopyOnRead());
 

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 72daf0d..696d22c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -25,9 +25,8 @@ import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Rule;
@@ -49,27 +48,27 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   public static final ClusterConfig INITIAL_CONFIG = new ClusterConfig(new ConfigGroup("cluster"));
 
-  private Locator locator;
+  private MemberVM locatorVM;
 
   @Before
   public void before() throws Exception {
     super.before();
-    locator = lsRule.startLocatorVM(0, locatorProps);
-    INITIAL_CONFIG.verify(locator);
+    locatorVM = lsRule.startLocatorVM(0, locatorProps);
+    INITIAL_CONFIG.verify(locatorVM);
 
-    gfshConnector.connect(locator);
+    gfshConnector.connect(locatorVM);
     assertThat(gfshConnector.isConnected()).isTrue();
   }
 
   @Test
   public void testImportWithRunningServerWithRegion() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     // create another server as well
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     String regionName = "regionA";
     server1.invoke(() -> {
       // this region will be created on both servers, but we should only be getting the name once.
-      Cache cache = LocatorServerStartupRule.serverStarter.cache;
+      Cache cache = LocatorServerStartupRule.serverStarter.getCache();
       cache.createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
     });
 
@@ -82,10 +81,10 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
 
   @Test
   public void testImportWithRunningServer() throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
     serverProps.setProperty("groups", "group2");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
 
     // even though we have a region recreated, we can still import since there is no data
     // in the region
@@ -105,39 +104,39 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     // Make sure that a backup of the old clusterConfig was created
-    assertThat(locator.getWorkingDir().listFiles())
+    assertThat(locatorVM.getWorkingDir().listFiles())
         .filteredOn((File file) -> file.getName().contains("cluster_config")).hasSize(2);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
 
     // start server1 with no group
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER).verify(server1);
 
     // start server2 in group1
     serverProps.setProperty(GROUPS, "group1");
-    Server server2 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM server2 = lsRule.startServerVM(2, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1).verify(server2);
 
     // start server3 in group1 and group2
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM server3 = lsRule.startServerVM(3, serverProps, locatorVM.getPort());
     new ClusterConfig(CLUSTER, GROUP1, GROUP2).verify(server3);
   }
 
   @Test
   public void testImportWithMultipleLocators() throws Exception {
-    locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    locatorProps.setProperty(LOCATORS, "localhost[" + locatorVM.getPort() + "]");
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     locatorProps.setProperty(LOCATORS,
-        "localhost[" + locator.getPort() + "],localhost[" + locator1.getPort() + "]");
-    Locator locator2 = lsRule.startLocatorVM(2, locatorProps);
+        "localhost[" + locatorVM.getPort() + "],localhost[" + locator1.getPort() + "]");
+    MemberVM locator2 = lsRule.startLocatorVM(2, locatorProps);
 
     gfshConnector.executeAndVerifyCommand(
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
-    CONFIG_FROM_ZIP.verify(locator);
+    CONFIG_FROM_ZIP.verify(locatorVM);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator1);
     REPLICATED_CONFIG_FROM_ZIP.verify(locator2);
   }
@@ -156,7 +155,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
   }
 
   public void testExportClusterConfig(String zipFilePath) throws Exception {
-    Server server1 = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
 
 
     gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
@@ -164,7 +163,7 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigBaseTest {
     ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");
     ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
     expectedClusterConfig.verify(server1);
-    expectedClusterConfig.verify(locator);
+    expectedClusterConfig.verify(locatorVM);
 
     gfshConnector
         .executeAndVerifyCommand("export cluster-configuration --zip-file-name=" + zipFilePath);

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
index c0d22bf..652ec60 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigStartMemberDUnitTest.java
@@ -23,8 +23,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
-import org.apache.geode.test.dunit.rules.Locator;
-import org.apache.geode.test.dunit.rules.Server;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,7 +34,7 @@ import java.util.Properties;
 
 @Category(DistributedTest.class)
 public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
-  protected Locator locator;
+  protected MemberVM locator;
 
   @Before
   public void before() throws Exception {
@@ -46,7 +45,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
   @Test
   public void testStartLocator() throws Exception {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator.getPort() + "]");
-    Locator secondLocator = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM secondLocator = lsRule.startLocatorVM(1, locatorProps);
 
     REPLICATED_CONFIG_FROM_ZIP.verify(secondLocator);
   }
@@ -57,15 +56,15 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1Config = new ClusterConfig(CLUSTER, GROUP1);
     ClusterConfig expectedGroup2Config = new ClusterConfig(CLUSTER, GROUP2);
 
-    Server serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM serverWithNoGroup = lsRule.startServerVM(1, serverProps, locator.getPort());
     expectedNoGroupConfig.verify(serverWithNoGroup);
 
     serverProps.setProperty(GROUPS, "group1");
-    Server serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
+    MemberVM serverForGroup1 = lsRule.startServerVM(2, serverProps, locator.getPort());
     expectedGroup1Config.verify(serverForGroup1);
 
     serverProps.setProperty(GROUPS, "group2");
-    Server serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
+    MemberVM serverForGroup2 = lsRule.startServerVM(3, serverProps, locator.getPort());
     expectedGroup2Config.verify(serverForGroup2);
   }
 
@@ -74,12 +73,12 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     ClusterConfig expectedGroup1And2Config = new ClusterConfig(CLUSTER, GROUP1, GROUP2);
 
     serverProps.setProperty(GROUPS, "group1,group2");
-    Server server = lsRule.startServerVM(1, serverProps, locator.getPort());
+    MemberVM server = lsRule.startServerVM(1, serverProps, locator.getPort());
 
     expectedGroup1And2Config.verify(server);
   }
 
-  private Locator startLocatorWithLoadCCFromDir() throws Exception {
+  private MemberVM startLocatorWithLoadCCFromDir() throws Exception {
     File locatorDir = lsRule.getTempFolder().newFolder("locator-0");
     File configDir = new File(locatorDir, "cluster_config");
 
@@ -96,7 +95,7 @@ public class ClusterConfigStartMemberDUnitTest extends ClusterConfigBaseTest {
     properties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR, "true");
     properties.setProperty(CLUSTER_CONFIGURATION_DIR, locatorDir.getCanonicalPath());
 
-    Locator locator = lsRule.startLocatorVM(0, properties);
+    MemberVM locator = lsRule.startLocatorVM(0, properties);
     CONFIG_FROM_ZIP.verify(locator);
 
     return locator;

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index 4d67fb0..c551ca9 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -28,8 +28,8 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.security.SimpleTestSecurityManager;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
-import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.junit.Before;
@@ -51,7 +51,7 @@ public class ClusterConfigWithSecurityDUnitTest {
   @Rule
   public GfshShellConnectionRule connector = new GfshShellConnectionRule();
 
-  Locator locator0;
+  MemberVM locator0;
   Properties locatorProps;
 
   @Before
@@ -70,11 +70,11 @@ public class ClusterConfigWithSecurityDUnitTest {
     locatorProps.setProperty(LOCATORS, "localhost[" + locator0.getPort() + "]");
     locatorProps.setProperty("security-username", "cluster");
     locatorProps.setProperty("security-password", "cluster");
-    Locator locator1 = lsRule.startLocatorVM(1, locatorProps);
+    MemberVM locator1 = lsRule.startLocatorVM(1, locatorProps);
 
     // the second locator should inherit the first locator's security props
     locator1.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties clusterConfigProps = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(clusterConfigProps.getProperty(SECURITY_MANAGER))
@@ -92,7 +92,7 @@ public class ClusterConfigWithSecurityDUnitTest {
         "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
 
     locator0.invoke(() -> {
-      InternalLocator locator = LocatorServerStartupRule.locatorStarter.locator;
+      InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
       ClusterConfigurationService sc = locator.getSharedConfiguration();
       Properties properties = sc.getConfiguration("cluster").getGemfireProperties();
       assertThat(properties.getProperty(MCAST_PORT)).isEqualTo("0");

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
index 30e1df8..1107779 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/CacheServerStartupRule.java
@@ -56,7 +56,7 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   public void before() throws Throwable {
     serverStarter.before();
     serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory().create("region1");
+    serverStarter.getCache().createRegionFactory().create("region1");
   }
 
   @After
@@ -65,10 +65,10 @@ public class CacheServerStartupRule extends ExternalResource implements Serializ
   }
 
   public Cache getCache() {
-    return serverStarter.cache;
+    return serverStarter.getCache();
   }
 
   public int getServerPort() {
-    return serverStarter.server.getPort();
+    return serverStarter.getPort();
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index 6468195..62c0b85 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -53,15 +53,15 @@ public class GfshCommandsPostProcessorTest {
 
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
+
   @Rule
   public GfshShellConnectionRule gfshConnection =
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index ef8b7f1..45d437a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -78,12 +78,11 @@ public class GfshCommandsSecurityTest {
       new GfshShellConnectionRule(jmxPort, GfshShellConnectionRule.PortType.jmxManger);
 
   @ClassRule
-  public static ServerStarterRule serverStarter = new ServerStarterRule();
+  public static ServerStarterRule serverStarter = new ServerStarterRule().startServer(properties);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    serverStarter.startServer(properties);
-    serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create("region1");
+    serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create("region1");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
index b6d1080..f8d90db 100644
--- a/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/AbstractSecureServerDUnitTest.java
@@ -53,7 +53,8 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
   protected boolean pdxPersistent = false;
 
   @Rule
-  public transient ServerStarterRule serverStarter = new ServerStarterRule();
+  public transient ServerStarterRule serverStarter =
+      new ServerStarterRule().startServer(getProperties(), 0, pdxPersistent);
 
   // overwrite this in child classes
   public Properties getProperties() {
@@ -77,10 +78,9 @@ public abstract class AbstractSecureServerDUnitTest extends JUnit4DistributedTes
 
   @Before
   public void before() throws Exception {
-    serverStarter.startServer(getProperties(), 0, pdxPersistent);
-    serverPort = serverStarter.server.getPort();
+    serverPort = serverStarter.getServer().getPort();
     Region region =
-        serverStarter.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+        serverStarter.getCache().createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
     for (Entry entry : getData().entrySet()) {
       region.put(entry.getKey(), entry.getValue());
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
index 5d713f6..805d000 100644
--- a/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/ClusterConfigWithoutSecurityDUnitTest.java
@@ -72,7 +72,7 @@ public class ClusterConfigWithoutSecurityDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, the configuration won't chagne
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
index 12c2da3..4f84f7b 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityClusterConfigDUnitTest.java
@@ -75,7 +75,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();
@@ -96,7 +96,7 @@ public class SecurityClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
 
     // after cache is created, we got the security props passed in by cluster config
     Properties secProps = ds.getSecurityProperties();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
index 092e82b..52a4ce4 100644
--- a/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/SecurityWithoutClusterConfigDUnitTest.java
@@ -73,7 +73,7 @@ public class SecurityWithoutClusterConfigDUnitTest {
 
     // initial security properties should only contain initial set of values
     serverStarter.startServer(props, lsRule.getMember(0).getPort());
-    DistributedSystem ds = serverStarter.cache.getDistributedSystem();
+    DistributedSystem ds = serverStarter.getCache().getDistributedSystem();
     assertEquals(3, ds.getSecurityProperties().size());
 
     // after cache is created, we got the security props passed in by cluster config

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
index f5cfff6..ef25ace 100644
--- a/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/StartServerAuthorizationTest.java
@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.geode.test.dunit.rules.Locator;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.dunit.rules.ServerStarterRule;
 import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
@@ -36,7 +37,7 @@ public class StartServerAuthorizationTest {
 
   @ClassRule
   public static LocatorServerStartupRule lsRule = new LocatorServerStartupRule();
-  private static Locator locator = null;
+  private static MemberVM<Locator> locator = null;
 
   @Rule
   public ServerStarterRule serverStarter = new ServerStarterRule();

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index f35e3e9..f367458 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -86,11 +86,11 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
 
   }
 
-  public void connect(Locator locator, String... options) throws Exception {
+  public void connect(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
   }
 
-  public void connectAndVerify(Locator locator, String... options) throws Exception {
+  public void connectAndVerify(MemberVM locator, String... options) throws Exception {
     connect(locator.getPort(), PortType.locator, options);
     assertThat(this.connected).isTrue();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
index b1004b9..59f1506 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Locator.java
@@ -16,11 +16,8 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.distributed.internal.InternalLocator;
 
-public class Locator extends Member {
-
-  public Locator(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
+public interface Locator extends Member {
+  InternalLocator getLocator();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
index d5a4dfb..01e346a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorServerStartupRule.java
@@ -55,7 +55,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       new DistributedRestoreSystemProperties();
 
   private TemporaryFolder temporaryFolder = new SerializableTemporaryFolder();
-  private Member[] members;
+  private MemberVM[] members;
 
   public LocatorServerStartupRule() {
     DUnitLauncher.launchIfNeeded();
@@ -66,7 +66,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     restoreSystemProperties.before();
     temporaryFolder.create();
     Invoke.invokeInEveryVM("Stop each VM", this::cleanupVm);
-    members = new Member[4];
+    members = new MemberVM[4];
   }
 
   @Override
@@ -77,7 +77,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
     temporaryFolder.delete();
   }
 
-  public Locator startLocatorVM(int index) throws IOException {
+  public MemberVM startLocatorVM(int index) throws IOException {
     return startLocatorVM(index, new Properties());
   }
 
@@ -87,7 +87,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    *
    * @return VM locator vm
    */
-  public Locator startLocatorVM(int index, Properties locatorProperties) throws IOException {
+  public MemberVM<Locator> startLocatorVM(int index, Properties locatorProperties)
+      throws IOException {
     String name = "locator-" + index;
     locatorProperties.setProperty(NAME, name);
     File workingDir = createWorkingDirForMember(name);
@@ -97,12 +98,11 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       locatorStarter.before();
       return locatorStarter.startLocator(locatorProperties);
     });
-    locator.setVM(locatorVM);
-    members[index] = locator;
-    return locator;
+    members[index] = new MemberVM(locator, locatorVM);
+    return members[index];
   }
 
-  public Server startServerVM(int index) throws IOException {
+  public MemberVM startServerVM(int index) throws IOException {
     return startServerVM(index, new Properties(), -1);
   }
 
@@ -111,24 +111,21 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
    * 
    * @return VM node vm
    */
-  public Server startServerVM(int index, Properties properties) throws IOException {
+  public MemberVM startServerVM(int index, Properties properties) throws IOException {
     return startServerVM(index, properties, -1);
   }
 
-  /**
-   * start a server that connects to this locatorPort
-   */
-  public Server startServerVM(int index, int locatorPort) throws IOException {
+  public MemberVM startServerVM(int index, int locatorPort) throws IOException {
     return startServerVM(index, new Properties(), locatorPort);
   }
 
-  public Server startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
+  public MemberVM startServerAsJmxManager(int index, int jmxManagerPort) throws IOException {
     Properties properties = new Properties();
     properties.setProperty(JMX_MANAGER_PORT, jmxManagerPort + "");
     return startServerVM(index, properties);
   }
 
-  public Server startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
+  public MemberVM startServerAsEmbededLocator(int index, int locatorPort, int jmxManagerPort)
       throws IOException {
     Properties properties = new Properties();
     properties.setProperty("start-locator", "localhost[" + locatorPort + "]");
@@ -141,7 +138,7 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
   /**
    * Starts a cache server that connect to the locator running at the given port.
    */
-  public Server startServerVM(int index, Properties properties, int locatorPort)
+  public MemberVM startServerVM(int index, Properties properties, int locatorPort)
       throws IOException {
 
     String name = "server-" + index;
@@ -154,9 +151,8 @@ public class LocatorServerStartupRule extends ExternalResource implements Serial
       serverStarter.before();
       return serverStarter.startServer(properties, locatorPort);
     });
-    server.setVM(serverVM);
-    members[index] = server;
-    return server;
+    members[index] = new MemberVM(server, serverVM);
+    return members[index];
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
index 2ec2088..5d6a0be 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/LocatorStarterRule.java
@@ -21,17 +21,14 @@ import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_S
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.Locator.startLocatorAndDS;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.io.FileUtils;
-import org.apache.geode.distributed.Locator;
 import org.apache.geode.distributed.internal.InternalLocator;
 import org.awaitility.Awaitility;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
@@ -47,12 +44,9 @@ import java.util.concurrent.TimeUnit;
  * use {@link LocatorServerStartupRule}.
  */
 
-public class LocatorStarterRule extends ExternalResource implements Serializable {
+public class LocatorStarterRule extends MemberStarterRule implements Locator {
 
-  public InternalLocator locator;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient InternalLocator locator;
 
   public LocatorStarterRule() {}
 
@@ -60,42 +54,29 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
     this.workingDir = workingDir.getAbsoluteFile();
   }
 
-  @Override
-  protected void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("locator").toAbsolutePath().toFile();
-    }
-    System.setProperty("user.dir", workingDir.toString());
+  public InternalLocator getLocator() {
+    return locator;
   }
 
   @Override
-  protected void after() {
+  protected void stopMember() {
     if (locator != null) {
       locator.stop();
     }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
-    }
   }
 
-
-  public org.apache.geode.test.dunit.rules.Locator startLocator() throws Exception {
+  public LocatorStarterRule startLocator() {
     return startLocator(new Properties());
   }
 
-  public org.apache.geode.test.dunit.rules.Locator startLocator(Properties properties)
-      throws Exception {
+  public LocatorStarterRule startLocator(Properties properties) {
     if (properties == null)
       properties = new Properties();
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "locator");
     }
 
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath());
     }
@@ -104,7 +85,7 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
       properties.setProperty(MCAST_PORT, "0");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER)) {
           properties.put(JMX_MANAGER, "true");
@@ -114,15 +95,18 @@ public class LocatorStarterRule extends ExternalResource implements Serializable
         }
       }
     }
-
-    locator = (InternalLocator) Locator.startLocatorAndDS(0, null, properties);
-    int locatorPort = locator.getPort();
-    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(locatorPort);
+    try {
+      locator = (InternalLocator) startLocatorAndDS(0, null, properties);
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start up locator.", e);
+    }
+    memberPort = locator.getPort();
+    locator.resetInternalLocatorFileNamesWithCorrectPortNumber(memberPort);
 
     if (locator.getConfig().getEnableClusterConfiguration()) {
       Awaitility.await().atMost(65, TimeUnit.SECONDS)
           .until(() -> assertTrue(locator.isSharedConfigurationRunning()));
     }
-    return new org.apache.geode.test.dunit.rules.Locator(locatorPort, workingDir, name);
+    return this;
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
index 59215a3..6165c84 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Member.java
@@ -11,62 +11,19 @@
  * 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.test.dunit.rules;
 
-import org.apache.geode.test.dunit.SerializableRunnableIF;
-import org.apache.geode.test.dunit.VM;
-
 import java.io.File;
 import java.io.Serializable;
 
-/**
- * A server or locator inside a DUnit {@link VM}.
- */
-public abstract class Member implements Serializable {
-  private transient VM vm;
-  private int port;
-  private File workingDir;
-  private String name;
-
-  public Member(int port, File workingDir, String name) {
-    this.vm = vm;
-    this.port = port;
-    this.workingDir = workingDir;
-    this.name = name;
-  }
-
-  /**
-   * The VM object is an RMI stub which lets us execute code in the JVM of this member.
-   * 
-   * @return the {@link VM}
-   */
-  public VM getVM() {
-    return vm;
-  }
-
-  public void setVM(VM vm) {
-    this.vm = vm;
-  }
-
-  public int getPort() {
-    return port;
-  }
+public interface Member extends Serializable {
+  File getWorkingDir();
 
-  public File getWorkingDir() {
-    return workingDir;
-  }
+  int getPort();
 
-  public String getName() {
-    return name;
-  }
+  int getJmxPort();
 
-  /**
-   * Invokes {@code runnable.run()} in the {@code VM} of this member.
-   */
-  public void invoke(final SerializableRunnableIF runnable) {
-    this.vm.invoke(runnable);
-  }
+  String getName();
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
new file mode 100644
index 0000000..7591616
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberStarterRule.java
@@ -0,0 +1,84 @@
+/*
+ * 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.test.dunit.rules;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.geode.test.dunit.VM;
+import org.junit.rules.ExternalResource;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+
+/**
+ * A server or locator inside a DUnit {@link VM}.
+ */
+public abstract class MemberStarterRule extends ExternalResource implements Member {
+  protected TemporaryFolder temporaryFolder;
+  protected String oldUserDir;
+
+  protected File workingDir;
+  protected int memberPort = -1;
+  protected int jmxPort = -1;
+  protected String name;
+
+  @Override
+  public void before() throws Exception {
+    oldUserDir = System.getProperty("user.dir");
+    if (workingDir == null) {
+      temporaryFolder = new TemporaryFolder();
+      temporaryFolder.create();
+      workingDir = temporaryFolder.newFolder("locator").getAbsoluteFile();
+    }
+    System.setProperty("user.dir", workingDir.toString());
+  }
+
+  @Override
+  public void after() {
+    stopMember();
+    FileUtils.deleteQuietly(workingDir);
+    if (oldUserDir == null) {
+      System.clearProperty("user.dir");
+    } else {
+      System.setProperty("user.dir", oldUserDir);
+    }
+    if (temporaryFolder != null) {
+      temporaryFolder.delete();
+    }
+  }
+
+  abstract void stopMember();
+
+  @Override
+  public File getWorkingDir() {
+    return workingDir;
+  }
+
+  @Override
+  public int getPort() {
+    return memberPort;
+  }
+
+  @Override
+  public int getJmxPort() {
+    return jmxPort;
+  }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
new file mode 100644
index 0000000..988f5d4
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java
@@ -0,0 +1,67 @@
+/*
+ * 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.test.dunit.rules;
+
+import org.apache.geode.test.dunit.SerializableRunnableIF;
+import org.apache.geode.test.dunit.VM;
+
+import java.io.File;
+
+public class MemberVM<T extends Member> implements Member {
+  private T member;
+  private VM vm;
+
+  public MemberVM(T member, VM vm) {
+    this.member = member;
+    this.vm = vm;
+  }
+
+  public boolean isLocator() {
+    return (member instanceof Locator);
+  }
+
+  public VM getVM() {
+    return vm;
+  }
+
+  public void invoke(final SerializableRunnableIF runnable) {
+    vm.invoke(runnable);
+  }
+
+  public T getMember() {
+    return member;
+  }
+
+  @Override
+  public File getWorkingDir() {
+    return member.getWorkingDir();
+  }
+
+  @Override
+  public int getPort() {
+    return member.getPort();
+  }
+
+  @Override
+  public int getJmxPort() {
+    return member.getJmxPort();
+  }
+
+  @Override
+  public String getName() {
+    return member.getName();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
index 83093c4..fb8630a 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/Server.java
@@ -16,10 +16,12 @@
 
 package org.apache.geode.test.dunit.rules;
 
-import java.io.File;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.server.CacheServer;
+
+public interface Server extends Member {
+  Cache getCache();
+
+  CacheServer getServer();
 
-public class Server extends Member {
-  public Server(int port, File workingDir, String name) {
-    super(port, workingDir, name);
-  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/5ca8dda8/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
index df37579..0454340 100644
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/ServerStarterRule.java
@@ -23,16 +23,13 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
-import org.junit.rules.ExternalResource;
 
 import java.io.File;
-import java.io.Serializable;
-import java.nio.file.Files;
+import java.io.IOException;
 import java.util.Properties;
 
 
@@ -50,61 +47,79 @@ import java.util.Properties;
  * If you need a rule to start a server/locator in different VMs for Distributed tests, You should
  * use {@link LocatorServerStartupRule}.
  */
-public class ServerStarterRule extends ExternalResource implements Serializable {
+public class ServerStarterRule extends MemberStarterRule implements Server {
 
-  public Cache cache;
-  public CacheServer server;
-
-  private File workingDir;
-  private String oldUserDir;
+  private transient Cache cache;
+  private transient CacheServer server;
 
   /**
-   * Default constructor, if used, the rule won't start the server for you, you will need to
-   * manually start it. The rule will handle stop the server for you.
+   * Default constructor, if used, the rule will create a temporary folder as the server's working
+   * dir, and will delete it when the test is done.
    */
   public ServerStarterRule() {}
 
+  /**
+   * if constructed this way, the rule won't be deleting the workingDir after the test is done. It's
+   * up to the caller's responsibility to delete it.
+   * 
+   * @param workingDir: the working dir this server should be writing the artifacts to.
+   */
   public ServerStarterRule(File workingDir) {
     this.workingDir = workingDir;
   }
 
-  public void before() throws Exception {
-    oldUserDir = System.getProperty("user.dir");
-    if (workingDir == null) {
-      workingDir = Files.createTempDirectory("server").toAbsolutePath().toFile();
+  public Cache getCache() {
+    return cache;
+  }
+
+  public CacheServer getServer() {
+    return server;
+  }
+
+  @Override
+  void stopMember() {
+    // make sure this cache is the one currently open. A server cache can be recreated due to
+    // importing a new set of cluster configuration.
+    cache = GemFireCacheImpl.getInstance();
+    if (cache != null) {
+      cache.close();
+      cache = null;
+    }
+    if (server != null) {
+      server.stop();
+      server = null;
     }
-    System.setProperty("user.dir", workingDir.toString());
   }
 
-  public Server startServer() throws Exception {
+  public ServerStarterRule startServer() {
     return startServer(new Properties(), -1, false);
   }
 
-  public Server startServer(int locatorPort) throws Exception {
+  public ServerStarterRule startServer(int locatorPort) {
     return startServer(new Properties(), locatorPort, false);
   }
 
-  public Server startServer(int locatorPort, boolean pdxPersistent) throws Exception {
+  public ServerStarterRule startServer(int locatorPort, boolean pdxPersistent) {
     return startServer(new Properties(), locatorPort, pdxPersistent);
   }
 
-  public Server startServer(Properties properties) throws Exception {
+  public ServerStarterRule startServer(Properties properties) {
     return startServer(properties, -1, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort) throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort) {
     return startServer(properties, locatorPort, false);
   }
 
-  public Server startServer(Properties properties, int locatorPort, boolean pdxPersistent)
-      throws Exception {
+  public ServerStarterRule startServer(Properties properties, int locatorPort,
+      boolean pdxPersistent) {
     if (properties == null) {
       properties = new Properties();
     }
     if (!properties.containsKey(NAME)) {
       properties.setProperty(NAME, "server");
     }
-    String name = properties.getProperty(NAME);
+    name = properties.getProperty(NAME);
     if (!properties.containsKey(LOG_FILE)) {
       properties.setProperty(LOG_FILE, new File(name + ".log").getAbsolutePath().toString());
     }
@@ -120,7 +135,7 @@ public class ServerStarterRule extends ExternalResource implements Serializable
       properties.setProperty(LOCATORS, "");
     }
     if (properties.containsKey(JMX_MANAGER_PORT)) {
-      int jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
+      jmxPort = Integer.parseInt(properties.getProperty(JMX_MANAGER_PORT));
       if (jmxPort > 0) {
         if (!properties.containsKey(JMX_MANAGER))
           properties.put(JMX_MANAGER, "true");
@@ -134,28 +149,12 @@ public class ServerStarterRule extends ExternalResource implements Serializable
     cache = cf.create();
     server = cache.addCacheServer();
     server.setPort(0);
-    server.start();
-    return new Server(server.getPort(), workingDir, name);
-  }
-
-  @Override
-  public void after() {
-    // make sure this cache is the one currently open. A server cache can be recreated due to
-    // importing a new set of cluster configuration.
-    cache = GemFireCacheImpl.getInstance();
-    if (cache != null) {
-      cache.close();
-      cache = null;
-    }
-    if (server != null) {
-      server.stop();
-      server = null;
-    }
-    FileUtils.deleteQuietly(workingDir);
-    if (oldUserDir == null) {
-      System.clearProperty("user.dir");
-    } else {
-      System.setProperty("user.dir", oldUserDir);
+    try {
+      server.start();
+    } catch (IOException e) {
+      throw new RuntimeException("unable to start server", e);
     }
+    memberPort = server.getPort();
+    return this;
   }
 }


Mime
View raw message