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

[01/12] incubator-geode git commit: Fixing tests

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1255 68ddd58be -> cd02af01c


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
index 70f3e70..75c0286 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationUsingDirDUnitTest.java
@@ -16,22 +16,11 @@
  */
 package com.gemstone.gemfire.management.internal.configuration;
 
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalLocator;
-import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import com.gemstone.gemfire.util.test.TestUtil;
-import com.jayway.awaitility.Awaitility;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
+import static java.util.stream.Collectors.*;
+import static org.junit.Assert.*;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -43,9 +32,20 @@ import java.util.Arrays;
 import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
-import static java.util.stream.Collectors.joining;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import com.jayway.awaitility.Awaitility;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.distributed.Locator;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.util.test.TestUtil;
 
 @Category(DistributedTest.class)
 public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
@@ -53,7 +53,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
   @After
   public void teardown() throws Exception {
     for (int i = 0; i < 2; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       vm.invoke("Removing shared configuration", () -> {
         InternalLocator locator = InternalLocator.getLocator();
         if (locator == null) {
@@ -62,7 +62,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
         if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration();
+          sharedConfig.destroySharedConfiguration_forTestsOnly();
         }
       });
     }
@@ -70,18 +70,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
   @Test
   public void basicClusterConfigDirWithOneLocator() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
+    final int[] ports = getRandomAvailableTCPPorts(1);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -92,18 +92,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
   @Test
   public void basicClusterConfigDirWithTwoLocators() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -115,18 +115,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
   @Category(FlakyTest.class) // GEODE-1165: random ports, BindException, time sensitive, awaitility
   @Test
   public void updateClusterConfigDirWithTwoLocatorsNoRollingServerRestart() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -139,24 +139,24 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
     // Unless we start them asynchronously, the older one will want to wait for a new diskstore
     // to become available and will time out.
     for (int i = locatorCount; i > 0; i--) {
-      VM vm = Host.getHost(0).getVM(i - 1);
+      VM vm = getHost(0).getVM(i - 1);
       stopLocator(vm);
     }
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       vm.invoke(() -> disconnectFromDS());
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -167,18 +167,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
   @Test
   public void updateClusterConfigDirWithTwoLocatorsAndRollingServerRestart() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -191,19 +191,19 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
     // Unless we start them asynchronously, the older one will want to wait for a new diskstore
     // to become available and will time out.
     for (int i = locatorCount; i > 0; i--) {
-      VM vm = Host.getHost(0).getVM(i - 1);
+      VM vm = getHost(0).getVM(i - 1);
       stopLocator(vm);
     }
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -214,18 +214,18 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
   @Test
   public void updateClusterConfigDirWithTwoLocatorsRollingRestartAndRollingServerRestart() throws Exception {
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    final int[] ports = getRandomAvailableTCPPorts(2);
     final int locatorCount = ports.length;
 
     for (int i = 0; i < locatorCount; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       copyClusterXml(vm, "cluster-empty.xml");
       startLocator(vm, i, ports);
       waitForSharedConfiguration(vm);
     }
 
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region absence", () -> {
@@ -236,7 +236,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
     // Roll the locators
     for (int i = locatorCount - 1; i >= 0; i--) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       stopLocator(vm);
       copyClusterXml(vm, "cluster-region.xml");
       startLocator(vm, i, ports);
@@ -245,7 +245,7 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
 
     // Roll the servers
     for (int i = 2; i < 4; i++) {
-      VM vm = Host.getHost(0).getVM(i);
+      VM vm = getHost(0).getVM(i);
       restartCache(vm, i, ports);
 
       vm.invoke("Checking for region presence", () -> {
@@ -269,14 +269,14 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
       final String locatorName = "locator" + i;
       final File logFile = new File("locator-" + i + ".log");
       final Properties props = new Properties();
-      props.setProperty(DistributionConfig.NAME_NAME, locatorName);
-      props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-      props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-      props.setProperty(DistributionConfig.LOAD_CLUSTER_CONFIG_FROM_DIR_NAME, "true");
+      props.setProperty(NAME_NAME, locatorName);
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(LOAD_CLUSTER_CONFIG_FROM_DIR_NAME, "true");
 
       if (locatorPorts.length > 1) {
         int otherLocatorPort = locatorPorts[(i + 1) % locatorPorts.length];
-        props.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + otherLocatorPort + "]");
+        props.setProperty(LOCATORS_NAME, "localhost[" + otherLocatorPort + "]");
       }
 
       Locator.startLocatorAndDS(locatorPorts[i], logFile, props);
@@ -306,12 +306,12 @@ public class SharedConfigurationUsingDirDUnitTest extends JUnit4CacheTestCase {
       disconnectFromDS();
 
       final Properties props = new Properties();
-      props.setProperty(DistributionConfig.NAME_NAME, "member" + i);
-      props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-      props.setProperty(DistributionConfig.LOCATORS_NAME, getLocatorStr(locatorPorts));
-      props.setProperty(DistributionConfig.LOG_FILE_NAME, "server-" + i + ".log");
-      props.setProperty(DistributionConfig.USE_CLUSTER_CONFIGURATION_NAME, "true");
-      props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(NAME_NAME, "member" + i);
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, getLocatorStr(locatorPorts));
+      props.setProperty(LOG_FILE_NAME, "server-" + i + ".log");
+      props.setProperty(USE_CLUSTER_CONFIGURATION_NAME, "true");
+      props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
 
       getSystem(props);
       getCache();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
index a9324db..27a9757 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="DEBUG" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
     <Appenders>
         <Console name="STDOUT" target="SYSTEM_OUT">
             <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n %throwable%n"/>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java b/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
index 4ff9a73..07a2ed1 100644
--- a/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
+++ b/geode-wan/src/test/java/com/gemstone/gemfire/management/internal/configuration/ClusterConfigurationDUnitTest.java
@@ -83,6 +83,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
 public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
+
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
   private static final String REPLICATE_REGION = "ReplicateRegion1";
@@ -97,18 +98,16 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
   private static final String JAR3 = "D3.jar";
   private static final String AsyncEventQueue1 = "Q1";
   
-  private transient ClassBuilder classBuilder = new ClassBuilder();
-  
   public static Set<String> serverNames = new HashSet<String>();
   public static Set<String> jarFileNames = new HashSet<String>();
   
   public static String dataMember = "DataMember";
   public static String newMember = "NewMember";
   
-  private static final long serialVersionUID = 1L;
+  private transient ClassBuilder classBuilder = new ClassBuilder();
 
   @Test
-  public void testConfigDistribution() throws IOException {
+  public void testConfigDistribution() throws Exception {
     IgnoredException.addIgnoredException("could not get remote locator");
     try {
       Object[] result = setup();
@@ -213,12 +212,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
           assertTrue(aeq.getBatchSize() == 1000);
           assertTrue(aeq.getMaximumQueueMemory() == 1000);
         
-          //GatewayReviever verification
+          //GatewayReceiver verification
           Set<GatewayReceiver> gatewayReceivers = cache.getGatewayReceivers();
           assertFalse(gatewayReceivers.isEmpty());
           assertTrue(gatewayReceivers.size() == 1);
           
-          //Gateway Sender verfication
+          //Gateway Sender verification
           GatewaySender gs = cache.getGatewaySender(gsId);
           assertNotNull(gs);
           assertTrue(alertThreshold.equals(Integer.toString(gs.getAlertThreshold())));
@@ -246,14 +245,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
   /**
    * Tests for {@link Extension}, {@link Extensible}, {@link XmlParser},
    * {@link XmlGenerator}, {@link XmlEntity} as it applies to Extensions.
-   * Asserts that Mock Entension is created and altered on region and cache.
+   * Asserts that Mock Extension is created and altered on region and cache.
    * 
-   * @throws IOException
    * @since 8.1
    */
   @Test
-  public void testCreateExtensions() throws IOException {
-    
+  public void testCreateExtensions() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -322,12 +319,10 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
    * {@link XmlGenerator}, {@link XmlEntity} as it applies to Extensions.
    * Asserts that Mock Entension is created and destroyed on region and cache.
    * 
-   * @throws IOException
    * @since 8.1
    */
   @Test
-  public void testDestroyExtensions() throws IOException {
-    
+  public void testDestroyExtensions() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -389,7 +384,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
 
   @Ignore("disabled for unknown reason")
   @Test
-  public void testCreateDiskStore () throws IOException {
+  public void testCreateDiskStore () throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -493,12 +488,11 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     } finally {
       shutdownAll();
     }
-   
   }
 
   @Ignore("disabled for unknown reason")
   @Test
-  public void testConfigurePDX() throws IOException {
+  public void testConfigurePDX() throws Exception {
     try {
       Object[] result = setup();
       final int locatorPort = (Integer) result[0];
@@ -527,35 +521,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     }
   }
   
-  private void shutdownAll() throws IOException {
-    VM locatorAndMgr = Host.getHost(0).getVM(3);
-    locatorAndMgr.invoke(new SerializableCallable() {
-      /**
-       * 
-       */
-      private static final long serialVersionUID = 1L;
-
-      @Override
-      public Object call() throws Exception {
-        GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
-        ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1);
-        return null;
-      }
-    });
-    
-    locatorAndMgr.invoke(SharedConfigurationDUnitTest.locatorCleanup);
-    //Clean up the directories
-    if (serverNames != null && !serverNames.isEmpty()) {
-     for (String serverName : serverNames) {
-       final File serverDir = new File(serverName);
-       FileUtils.cleanDirectory(serverDir);
-       FileUtils.deleteDirectory(serverDir);
-     }
-    }
-  }
-
   @Test
-  public void testClusterConfigDir() {
+  public void testClusterConfigDir() throws Exception {
     disconnectAllFromDS();
     final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
@@ -571,8 +538,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         
         try {
           jmxHost = InetAddress.getLocalHost().getHostName();
-        }
-        catch (UnknownHostException ignore) {
+        } catch (UnknownHostException ignore) {
           jmxHost = "localhost";
         }
 
@@ -581,7 +547,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         jmxPort = ports[0];
         httpPort = ports[1];
         
-       
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
@@ -601,25 +566,19 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         
         locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null,
-              locatorProps);
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
-        
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+
         assertTrue(clusterConfigDir.list().length > 0);
 
         final Object[] result = new Object[4];
@@ -632,7 +591,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     });
   }
   
-  public Object[] setup() {
+  private Object[] setup() {
     disconnectAllFromDS();
     final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
@@ -641,15 +600,14 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     
     Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
       @Override
-      public Object call() {
+      public Object call() throws IOException {
         int httpPort;
         int jmxPort;
         String jmxHost;
         
         try {
           jmxHost = InetAddress.getLocalHost().getHostName();
-        }
-        catch (UnknownHostException ignore) {
+        } catch (UnknownHostException ignore) {
           jmxHost = "localhost";
         }
 
@@ -658,7 +616,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         jmxPort = ports[0];
         httpPort = ports[1];
         
-       
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
@@ -672,24 +629,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         locatorProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
         locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null,
-              locatorProps);
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
 
         final Object[] result = new Object[4];
         result[0] = locator1Port;
@@ -708,6 +659,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
     // Create a cache in VM 1
     VM dataMember = Host.getHost(0).getVM(1);
+
     dataMember.invoke(new SerializableCallable() {
       @Override
       public Object call() throws IOException {
@@ -728,14 +680,10 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
         return CliUtil.getAllNormalMembers(cache);
       }
     });
+
     return result;
   }
   
-  
-  /*********************************
-   * Region commands 
-   */
-  
   private void createRegion(String regionName, RegionShortcut regionShortCut, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
@@ -781,32 +729,6 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.toString());
   }
 
-  class CommandBuilder {
-    private CommandStringBuilder csb;
-    
-    public CommandBuilder(String commandName, Map<String, String> options) {
-      csb = new CommandStringBuilder(commandName);
-      
-      Set<Entry<String, String>> entries = options.entrySet();
-      
-      Iterator<Entry<String, String>> iter = entries.iterator();
-      
-      while (iter.hasNext()) {
-        Entry<String, String> entry = iter.next();
-        String option = entry.getKey();
-        
-        if (StringUtils.isBlank(option)) {
-          csb.addOption(option, entry.getValue());
-        }
-      }
-    }
-    
-    public String getCommandString() {
-      return csb.toString();
-    }
-  }
-  
-  
   private void createPersistentRegion(String regionName, RegionShortcut regionShortCut, String group, String diskStoreName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOptionWithValueCheck(CliStrings.CREATE_REGION__REGION, regionName);
@@ -823,15 +745,16 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
   }
   
   private void alterRegion(String regionName,
-      String cloningEnabled, 
-      String aeqId,
-      String cacheListener, 
-      String cacheWriter, 
-      String cacheLoader, 
-      String entryExpIdleTime, 
-      String entryExpIdleTimeAction,
-      String evictionMax,
-      String gsId) {
+                           String cloningEnabled,
+                           String aeqId,
+                           String cacheListener,
+                           String cacheWriter,
+                           String cacheLoader,
+                           String entryExpIdleTime,
+                           String entryExpIdleTimeAction,
+                           String evictionMax,
+                           String gsId) {
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_REGION);
     csb.addOptionWithValueCheck(CliStrings.ALTER_REGION__CLONINGENABLED, "false");
     csb.addOptionWithValueCheck(CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, aeqId);
@@ -846,7 +769,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
 
     executeAndVerifyCommand(csb.getCommandString());
   }
-  protected void executeAndVerifyCommand(String commandString) {
+
+  private void executeAndVerifyCommand(String commandString) {
     CommandResult cmdResult = executeCommand(commandString);
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Command : " + commandString);
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Command Result : " + commandResultToString(cmdResult));
@@ -854,20 +778,15 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     assertFalse(cmdResult.failedToPersist());
   }
   
-  
-  /****************
-   * CREATE/DESTROY INDEX
-   */
-  
-  public void createIndex(String indexName, String expression, String regionName, String group) {
+  private void createIndex(String indexName, String expression, String regionName, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
     csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
     csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, expression);
     csb.addOption(CliStrings.CREATE_INDEX__REGION, regionName);
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  public void destroyIndex(String indexName, String regionName, String group) {
+
+  private void destroyIndex(String indexName, String regionName, String group) {
     if (StringUtils.isBlank(indexName) && StringUtils.isBlank(regionName) && StringUtils.isBlank(group)) {
       return;
     }
@@ -878,20 +797,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.getCommandString());
   }
   
-  /*******
-   * CREATE/DESTROY DISK-STORE 
-   */
-  private void createDiskStore(String diskStoreName, 
-      String diskDirs, 
-      String autoCompact, 
-      String allowForceCompaction, 
-      String compactionThreshold, 
-      String duCritical, 
-      String duWarning,
-      String maxOplogSize,
-      String queueSize,
-      String timeInterval,
-      String writeBufferSize) {
+  private void createDiskStore(String diskStoreName,
+                               String diskDirs,
+                               String autoCompact,
+                               String allowForceCompaction,
+                               String compactionThreshold,
+                               String duCritical,
+                               String duWarning,
+                               String maxOplogSize,
+                               String queueSize,
+                               String timeInterval,
+                               String writeBufferSize) {
+
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
     csb.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreName);
     csb.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, diskDirs);
@@ -914,14 +831,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.toString());
   }
   
-  /*********
-   * 
-   * CREATE GATEWAY-RECEIVER
-   * 
-   */
-  
-  private void createGatewayReceiver(String manualStart, String bindAddress,
-      String startPort, String endPort, String maxTimeBetweenPings, String group) {
+  private void createGatewayReceiver(String manualStart, String bindAddress, String startPort, String endPort, String maxTimeBetweenPings, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYRECEIVER);
     csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MANUALSTART, manualStart);
     csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__STARTPORT, startPort);
@@ -933,18 +843,18 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
   }
   
   private void createGatewaySender(String id, 
-      String batchSize, 
-      String alertThreshold, 
-      String batchTimeInterval, 
-      String dispatcherThreads,
-      String enableConflation, 
-      String manualStart,
-      String maxQueueMemory, 
-      String orderPolicy, 
-      String parallel, 
-      String rmDsId, 
-      String socketBufferSize, 
-      String socketReadTimeout) {
+                                   String batchSize,
+                                   String alertThreshold,
+                                   String batchTimeInterval,
+                                   String dispatcherThreads,
+                                   String enableConflation,
+                                   String manualStart,
+                                   String maxQueueMemory,
+                                   String orderPolicy,
+                                   String parallel,
+                                   String rmDsId,
+                                   String socketBufferSize,
+                                   String socketReadTimeout) {
     
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER);
     csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__ID, id);
@@ -964,12 +874,7 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.getCommandString());
   }
   
-  
-  /*******
-   * CREATE ASYNC-EVENT-QUEUE 
-   */
-  
-  public void createAsyncEventQueue(String id, String persistent , String diskStoreName, String batchSize, String maxQueueMemory, String group) {
+  private void createAsyncEventQueue(String id, String persistent , String diskStoreName, String batchSize, String maxQueueMemory, String group) throws IOException {
     String queueCommandsJarName = "testEndToEndSC-QueueCommands.jar";
     final File jarFile = new File(queueCommandsJarName);
 
@@ -1002,14 +907,12 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
       csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, maxQueueMemory);
       executeAndVerifyCommand(csb.getCommandString());
       
-    } catch (IOException e) {
-      e.printStackTrace();
     } finally {
       FileUtils.deleteQuietly(jarFile);
     }
   }
-  
-  public void configurePDX(String autoSerializerClasses, String ignoreUnreadFields, String persistent, String portableAutoSerializerClasses, String readSerialized) {
+
+  private void configurePDX(String autoSerializerClasses, String ignoreUnreadFields, String persistent, String portableAutoSerializerClasses, String readSerialized) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX);
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, autoSerializerClasses);
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, ignoreUnreadFields);
@@ -1018,25 +921,20 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, readSerialized);
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  //DEPLOY AND UNDEPLOY JAR
-  public void createAndDeployJar(String jarName, String group) {
+
+  private void createAndDeployJar(String jarName, String group) throws IOException {
     File newDeployableJarFile = new File(jarName);
-    try {
-      this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
-      CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
-      csb.addOption(CliStrings.DEPLOY__JAR, jarName);
-      if (!StringUtils.isBlank(group)) {
-        csb.addOption(CliStrings.DEPLOY__GROUP, group);
-      }
-      executeAndVerifyCommand(csb.getCommandString());
-      jarFileNames.add(jarName);
-    } catch (IOException e) {
-      e.printStackTrace();
+    this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
+    csb.addOption(CliStrings.DEPLOY__JAR, jarName);
+    if (!StringUtils.isBlank(group)) {
+      csb.addOption(CliStrings.DEPLOY__GROUP, group);
     }
+    executeAndVerifyCommand(csb.getCommandString());
+    jarFileNames.add(jarName);
   }
-  
-  public void undeployJar(String jarName, String group) {
+
+  private void undeployJar(String jarName, String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.UNDEPLOY);
     if (!StringUtils.isBlank(jarName)) {
       csb.addOption(CliStrings.UNDEPLOY__JAR, jarName);
@@ -1046,8 +944,8 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     }
     executeAndVerifyCommand(csb.getCommandString());
   }
-  
-  public void alterRuntime(String copyOnRead, String lockLease, String lockTimeout, String messageSyncInterval) {
+
+  private void alterRuntime(String copyOnRead, String lockLease, String lockTimeout, String messageSyncInterval) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__COPY__ON__READ, copyOnRead);
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__LOCK__LEASE, lockLease);
@@ -1055,13 +953,56 @@ public class ClusterConfigurationDUnitTest extends CliCommandTestBase {
     csb.addOptionWithValueCheck(CliStrings.ALTER_RUNTIME_CONFIG__MESSAGE__SYNC__INTERVAL, messageSyncInterval);
     executeAndVerifyCommand(csb.toString());
   }
-  public void deleteSavedJarFiles() {
-    try {
-      FileUtil.deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
-      FileUtil.delete(new File("Deploy1.jar"));
-    } catch (IOException ioe) {
-      ioe.printStackTrace();
+
+  private void deleteSavedJarFiles() throws IOException {
+    FileUtil.deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
+    FileUtil.delete(new File("Deploy1.jar"));
+  }
+
+  private void shutdownAll() throws IOException {
+    VM locatorAndMgr = Host.getHost(0).getVM(3);
+    locatorAndMgr.invoke(new SerializableCallable() {
+      @Override
+      public Object call() throws Exception {
+        GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
+        ShutdownAllRequest.send(cache.getDistributedSystem().getDistributionManager(), -1);
+        return null;
+      }
+    });
+
+    locatorAndMgr.invoke(SharedConfigurationTestUtils.cleanupLocator);
+    //Clean up the directories
+    if (serverNames != null && !serverNames.isEmpty()) {
+      for (String serverName : serverNames) {
+        final File serverDir = new File(serverName);
+        FileUtils.cleanDirectory(serverDir);
+        FileUtils.deleteDirectory(serverDir);
+      }
+    }
+  }
+
+  class CommandBuilder {
+    private CommandStringBuilder csb;
+
+    public CommandBuilder(String commandName, Map<String, String> options) {
+      csb = new CommandStringBuilder(commandName);
+
+      Set<Entry<String, String>> entries = options.entrySet();
+
+      Iterator<Entry<String, String>> iter = entries.iterator();
+
+      while (iter.hasNext()) {
+        Entry<String, String> entry = iter.next();
+        String option = entry.getKey();
+
+        if (StringUtils.isBlank(option)) {
+          csb.addOption(option, entry.getValue());
+        }
+      }
+    }
+
+    public String getCommandString() {
+      return csb.toString();
     }
   }
-  
 }



[09/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalJUnitTest.java
deleted file mode 100755
index bfed4d0..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalJUnitTest.java
+++ /dev/null
@@ -1,842 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.lang.management.ManagementFactory;
-import java.net.BindException;
-import java.net.InetAddress;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalLocator;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.DistributionLocator;
-import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Tests usage of LocatorLauncher as a local API in existing JVM.
- *
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class LocatorLauncherLocalJUnitTest extends AbstractLocatorLauncherJUnitTestCase {
-  
-  @Before
-  public final void setUpLocatorLauncherLocalTest() throws Exception {
-    disconnectFromDS();
-    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
-  }
-
-  @After
-  public final void tearDownLocatorLauncherLocalTest() throws Exception {    
-    disconnectFromDS();
-  }
-  
-  protected Status getExpectedStopStatusForNotRunning() {
-    return Status.NOT_RESPONDING;
-  }
-
-  @Test
-  public void testBuilderSetProperties() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    this.launcher = new Builder()
-        .setForce(true)
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0")
-        .build();
-
-    try {
-      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
-      waitForLocatorToStart(this.launcher, true);
-  
-      final InternalLocator locator = this.launcher.getLocator();
-      assertNotNull(locator);
-  
-      final DistributedSystem distributedSystem = locator.getDistributedSystem();
-  
-      assertNotNull(distributedSystem);
-      assertEquals("true", distributedSystem.getProperties().getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME));
-      assertEquals("0", distributedSystem.getProperties().getProperty(DistributionConfig.MCAST_PORT_NAME));
-      assertEquals("config", distributedSystem.getProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME));
-      assertEquals(getUniqueName(), distributedSystem.getProperties().getProperty(DistributionConfig.NAME_NAME));
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      assertNull(this.launcher.getLocator());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertTrue(factory.isAttachAPIFound());
-  }
-  
-  @Test
-  public void testStartCreatesPidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    this.launcher = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .build();
-
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartDeletesStaleControlFiles() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // create existing control files
-    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
-    this.stopRequestFile.createNewFile();
-    assertTrue(this.stopRequestFile.exists());
-
-    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
-    this.statusRequestFile.createNewFile();
-    assertTrue(this.statusRequestFile.exists());
-
-    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
-    this.statusFile.createNewFile();
-    assertTrue(this.statusFile.exists());
-    
-    // build and start the locator
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    this.launcher.start();
-    
-    try {
-      waitForLocatorToStart(this.launcher);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-      
-      // validate stale control files were deleted
-      assertFalse(stopRequestFile.exists());
-      assertFalse(statusRequestFile.exists());
-      assertFalse(statusFile.exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStartOverwritesStalePidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE, Integer.MAX_VALUE == ProcessUtils.identifyPid());
-    writePid(this.pidFile, Integer.MAX_VALUE);
-
-    // build and start the locator
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    this.launcher.start();
-    
-    try {
-      waitForLocatorToStart(this.launcher);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
-  }/*
-    assertTrue(getUniqueName() + " is broken if PID == Integer.MAX_VALUE", ProcessUtils.identifyPid() != Integer.MAX_VALUE);
-    
-    // create existing pid file
-    this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse(realPid == ProcessUtils.identifyPid());
-    writePid(this.pidFile, realPid);
-
-    // build and start the locator
-    final Builder builder = new Builder()
-        .setForce(true)
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertTrue(builder.getForce());
-    this.launcher = builder.build();
-    assertTrue(this.launcher.isForcing());
-    this.launcher.start();
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-      
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(logFileName).exists());
-      
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartUsingForceOverwritesExistingPidFile
-  */
-  
-  @Test
-  public void testStartWithDefaultPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
-    assertTrue(this.socket.isBound());
-    assertFalse(this.socket.isClosed());
-    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
-
-    assertNotNull(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY));
-    assertEquals(this.locatorPort, Integer.valueOf(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY)).intValue());
-    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
-    
-    this.launcher = new Builder()
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .build();
-    
-    assertEquals(this.locatorPort, this.launcher.getPort().intValue());
-    
-    RuntimeException expected = null;
-    try {
-      this.launcher.start();
-     
-      // why did it not fail like it's supposed to?
-      final String property = System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY);
-      assertNotNull(property);
-      assertEquals(this.locatorPort, Integer.valueOf(property).intValue());
-      assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
-      assertEquals(this.locatorPort, this.launcher.getPort().intValue());
-      assertEquals(this.locatorPort, this.socket.getLocalPort());
-      assertTrue(this.socket.isBound());
-      assertFalse(this.socket.isClosed());
-      
-      fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      // BindException text varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof BindException);
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
-      
-      // creation of log file seems to be random -- look into why sometime
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // just in case the launcher started...
-    LocatorState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      waitForFileToDelete(this.pidFile);
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartWithExistingPidFileFails() throws Throwable {
-  }/*
-    // create existing pid file
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
-
-    this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
-    writePid(this.pidFile, realPid);
-    
-    // build and start the locator
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-    RuntimeException expected = null;
-    
-    try {
-      this.launcher.start();
-      fail("LocatorLauncher start should have thrown RuntimeException caused by FileAlreadyExistsException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      assertTrue(expected.getMessage(), expected.getMessage().contains("A PID file already exists and a Locator may be running in"));
-      assertEquals(RuntimeException.class, expected.getClass());
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    // just in case the launcher started...
-    LocatorState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof FileAlreadyExistsException);
-      assertTrue(cause.getMessage().contains("Pid file already exists: "));
-      assertTrue(cause.getMessage().contains("vf.gf.locator.pid for process " + realPid));
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    try {
-      delete(this.pidFile);
-      final Status theStatus = status.getStatus();
-      assertFalse(theStatus == Status.STARTING);
-      assertFalse(theStatus == Status.ONLINE);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartWithExistingPidFileFails
-  */
-  
-  @Test
-  public void testStartUsingPort() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // generate one free port and then use it instead of default
-    final int freeTCPPort = AvailablePortHelper.getRandomAvailableTCPPort();
-    assertTrue(AvailablePort.isPortAvailable(freeTCPPort, AvailablePort.SOCKET));
-    
-    this.launcher = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(freeTCPPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .build();
-
-    int pid = 0;
-    try {
-      // if start succeeds without throwing exception then #47778 is fixed
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(pidFile.exists());
-      pid = readPid(pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      // verify locator did not use default port
-      assertTrue(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
-      
-      final LocatorState status = this.launcher.status();
-      final String portString = status.getPort();
-      assertEquals("Port should be \"" + freeTCPPort + "\" instead of " + portString, String.valueOf(freeTCPPort), portString);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStartUsingPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // generate one free port and then use it instead of default
-    final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
-    
-    this.launcher = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(freeTCPPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .build();
-    
-    RuntimeException expected = null;
-    try {
-      this.launcher.start();
-      fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof BindException);
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
-      
-      // creation of log file seems to be random -- look into why sometime
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // just in case the launcher started...
-    LocatorState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      waitForFileToDelete(this.pidFile);
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStatusUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    // build and start the locator
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-    
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    
-    LocatorLauncher pidLauncher = null;
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-      
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-  
-      pidLauncher = new Builder().setPid(pid).build();
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      final LocatorState actualStatus = pidLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    if (pidLauncher == null) {
-      try {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-      
-    } else {
-      try {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-    }
-  }
-  
-  @Test
-  public void testStatusUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-    
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    
-    LocatorLauncher dirLauncher = null;
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-      
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-  
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-
-      final LocatorState actualStatus = dirLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    if (dirLauncher == null) {
-      try {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-      
-    } else {
-      try {
-        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-    }
-  }
-  
-  @Test
-  public void testStopUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    LocatorLauncher pidLauncher = null;
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-
-      pidLauncher = new Builder().setPid(pid).build();
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-      
-      // stop the locator
-      final LocatorState locatorState = pidLauncher.stop();
-      assertNotNull(locatorState);
-      assertEquals(Status.STOPPED, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.launcher.stop();
-    } catch (Throwable e) {
-      // ignore
-    }
-
-    try {
-      // verify the PID file was deleted
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStopUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    LocatorLauncher dirLauncher = null;
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-    
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-      
-      // stop the locator
-      final LocatorState locatorState = dirLauncher.stop();
-      assertNotNull(locatorState);
-      assertEquals(Status.STOPPED, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.launcher.stop();
-    } catch (Throwable e) {
-      // ignore
-    }
-
-    try {
-      // verify the PID file was deleted
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileIntegrationTest.java
new file mode 100755
index 0000000..63f7312
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileIntegrationTest.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.lang.AttachAPINotFoundException;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Subclass of LocatorLauncherRemoteDUnitTest which forces the code to not find 
+ * the Attach API which is in the JDK tools.jar.  As a result LocatorLauncher
+ * ends up using the FileProcessController implementation.
+ * 
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherRemoteFileIntegrationTest extends LocatorLauncherRemoteIntegrationTest {
+  
+  @Before
+  public final void setUpLocatorLauncherRemoteFileIntegrationTest() throws Exception {
+    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
+  }
+  
+  @After
+  public final void tearDownLocatorLauncherRemoteFileIntegrationTest() throws Exception {
+  }
+  
+  /**
+   * Override and assert Attach API is NOT found
+   */
+  @Override
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertFalse(factory.isAttachAPIFound());
+  }
+  
+  /**
+   * Override because FileProcessController cannot request status with PID
+   */
+  @Override
+  @Test
+  public void testStatusUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    LocatorLauncher pidLauncher = null; 
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      final File pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(pidFile.exists());
+      pid = readPid(pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // status with pid only should throw AttachAPINotFoundException
+      try {
+        pidLauncher.status();
+        fail("FileProcessController should have thrown AttachAPINotFoundException");
+      } catch (AttachAPINotFoundException e) {
+        // passed
+      }
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      waitForPidToStop(pid, true);
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  /**
+   * Override because FileProcessController cannot request stop with PID
+   */
+  @Override
+  @Test
+  public void testStopUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    File pidFile = null;
+    LocatorLauncher pidLauncher = null; 
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(pidFile.exists());
+      pid = readPid(pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // stop with pid only should throw AttachAPINotFoundException
+      try {
+        pidLauncher.stop();
+        fail("FileProcessController should have thrown AttachAPINotFoundException");
+      } catch (AttachAPINotFoundException e) {
+        // passed
+      }
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      // stop the locator
+      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      waitForPidToStop(pid);
+      waitForFileToDelete(pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileJUnitTest.java
deleted file mode 100755
index d3edcae..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteFileJUnitTest.java
+++ /dev/null
@@ -1,218 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessStreamReader;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.lang.AttachAPINotFoundException;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Subclass of LocatorLauncherRemoteDUnitTest which forces the code to not find 
- * the Attach API which is in the JDK tools.jar.  As a result LocatorLauncher
- * ends up using the FileProcessController implementation.
- * 
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class LocatorLauncherRemoteFileJUnitTest extends LocatorLauncherRemoteJUnitTest {
-  
-  @Before
-  public final void setUpLocatorLauncherRemoteFileTest() throws Exception {
-    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
-  }
-  
-  @After
-  public final void tearDownLocatorLauncherRemoteFileTest() throws Exception {   
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override and assert Attach API is NOT found
-   */
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertFalse(factory.isAttachAPIFound());
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override because FileProcessController cannot request status with PID
-   */
-  public void testStatusUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    LocatorLauncher pidLauncher = null; 
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      final File pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(pidFile.exists());
-      pid = readPid(pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // status with pid only should throw AttachAPINotFoundException
-      try {
-        pidLauncher.status();
-        fail("FileProcessController should have thrown AttachAPINotFoundException");
-      } catch (AttachAPINotFoundException e) {
-        // passed
-      }
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      waitForPidToStop(pid, true);
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override because FileProcessController cannot request stop with PID
-   */
-  public void testStopUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    File pidFile = null;
-    LocatorLauncher pidLauncher = null; 
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(pidFile.exists());
-      pid = readPid(pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // stop with pid only should throw AttachAPINotFoundException
-      try {
-        pidLauncher.stop();
-        fail("FileProcessController should have thrown AttachAPINotFoundException");
-      } catch (AttachAPINotFoundException e) {
-        // passed
-      }
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      // stop the locator
-      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      waitForPidToStop(pid);
-      waitForFileToDelete(pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-}


[10/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
new file mode 100755
index 0000000..4c0c878
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanIntegrationTest.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.Query;
+import javax.management.QueryExp;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.management.MemberMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Tests querying of MemberMXBean which is used by MBeanProcessController to
+ * control GemFire ControllableProcesses.
+ * 
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class LauncherMemberMXBeanIntegrationTest extends AbstractLauncherIntegrationTestCase {
+
+  @Before
+  public final void setUpLauncherMemberMXBeanIntegrationTest() throws Exception {
+  }
+
+  @After
+  public final void tearDownLauncherMemberMXBeanIntegrationTest() throws Exception {
+    InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance();
+    if (ids != null) {
+      ids.disconnect();
+    }
+  }
+
+  @Test
+  public void testQueryForMemberMXBean() throws Exception {
+    final Properties props = new Properties();
+    props.setProperty("mcast-port", "0");
+    props.setProperty("locators", "");
+    props.setProperty("name", getUniqueName());
+    new CacheFactory(props).create();
+    
+    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
+
+    waitForMemberMXBean(mbeanServer, pattern);
+    
+    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
+    assertFalse(mbeanNames.isEmpty());
+    assertEquals("mbeanNames=" + mbeanNames, 1, mbeanNames.size());
+    
+    final ObjectName objectName = mbeanNames.iterator().next();
+    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
+      MemberMXBean.class, false);
+
+    assertNotNull(mbean);
+    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
+    assertEquals(getUniqueName(), mbean.getName());
+    assertEquals(getUniqueName(), mbean.getMember());
+  }
+  
+  @Test
+  public void testQueryForMemberMXBeanWithProcessId() throws Exception {
+    final Properties props = new Properties();
+    props.setProperty("mcast-port", "0");
+    props.setProperty("locators", "");
+    props.setProperty("name", getUniqueName());
+    new CacheFactory(props).create();
+    
+    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
+    final QueryExp constraint = Query.eq(Query.attr("ProcessId"),Query.value(ProcessUtils.identifyPid()));
+    
+    waitForMemberMXBean(mbeanServer, pattern);
+    
+    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
+    assertFalse(mbeanNames.isEmpty());
+    assertEquals(1, mbeanNames.size());
+    
+    final ObjectName objectName = mbeanNames.iterator().next();
+    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
+
+    assertNotNull(mbean);
+    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
+    assertEquals(getUniqueName(), mbean.getName());
+    assertEquals(getUniqueName(), mbean.getMember());
+  }
+  
+  @Test
+  public void testQueryForMemberMXBeanWithMemberName() throws Exception {
+    final Properties props = new Properties();
+    props.setProperty("mcast-port", "0");
+    props.setProperty("locators", "");
+    props.setProperty("name", getUniqueName());
+    new CacheFactory(props).create();
+    
+    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
+    final QueryExp constraint = Query.eq(Query.attr("Name"), Query.value(getUniqueName()));
+    
+    waitForMemberMXBean(mbeanServer, pattern);
+    
+    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
+    assertFalse(mbeanNames.isEmpty());
+    assertEquals(1, mbeanNames.size());
+    
+    final ObjectName objectName = mbeanNames.iterator().next();
+    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
+
+    assertNotNull(mbean);
+    assertEquals(getUniqueName(), mbean.getMember());
+  }
+  
+  private void waitForMemberMXBean(final MBeanServer mbeanServer, final ObjectName pattern) throws Exception {
+    assertEventuallyTrue("waiting for MemberMXBean to be registered", new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
+        return !mbeanNames.isEmpty();
+      }
+    }, WAIT_FOR_MBEAN_TIMEOUT, INTERVAL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanJUnitTest.java
deleted file mode 100755
index 30e21e1..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherMemberMXBeanJUnitTest.java
+++ /dev/null
@@ -1,152 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.lang.management.ManagementFactory;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.management.MemberMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Tests querying of MemberMXBean which is used by MBeanProcessController to
- * control GemFire ControllableProcesses.
- * 
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class LauncherMemberMXBeanJUnitTest extends AbstractLauncherJUnitTestCase {
-
-  @Before
-  public final void setUpLauncherMemberMXBeanTest() throws Exception {
-  }
-
-  @After
-  public final void tearDownLauncherMemberMXBeanTest() throws Exception {
-    InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance();
-    if (ids != null) {
-      ids.disconnect();
-    }
-  }
-
-  @Test
-  public void testQueryForMemberMXBean() throws Exception {
-    final Properties props = new Properties();
-    props.setProperty("mcast-port", "0");
-    props.setProperty("locators", "");
-    props.setProperty("name", getUniqueName());
-    new CacheFactory(props).create();
-    
-    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
-    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
-
-    waitForMemberMXBean(mbeanServer, pattern);
-    
-    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
-    assertFalse(mbeanNames.isEmpty());
-    assertEquals("mbeanNames=" + mbeanNames, 1, mbeanNames.size());
-    
-    final ObjectName objectName = mbeanNames.iterator().next();
-    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName,
-      MemberMXBean.class, false);
-
-    assertNotNull(mbean);
-    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
-    assertEquals(getUniqueName(), mbean.getName());
-    assertEquals(getUniqueName(), mbean.getMember());
-  }
-  
-  @Test
-  public void testQueryForMemberMXBeanWithProcessId() throws Exception {
-    final Properties props = new Properties();
-    props.setProperty("mcast-port", "0");
-    props.setProperty("locators", "");
-    props.setProperty("name", getUniqueName());
-    new CacheFactory(props).create();
-    
-    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
-    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
-    final QueryExp constraint = Query.eq(Query.attr("ProcessId"),Query.value(ProcessUtils.identifyPid()));
-    
-    waitForMemberMXBean(mbeanServer, pattern);
-    
-    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
-    assertFalse(mbeanNames.isEmpty());
-    assertEquals(1, mbeanNames.size());
-    
-    final ObjectName objectName = mbeanNames.iterator().next();
-    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
-
-    assertNotNull(mbean);
-    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
-    assertEquals(getUniqueName(), mbean.getName());
-    assertEquals(getUniqueName(), mbean.getMember());
-  }
-  
-  @Test
-  public void testQueryForMemberMXBeanWithMemberName() throws Exception {
-    final Properties props = new Properties();
-    props.setProperty("mcast-port", "0");
-    props.setProperty("locators", "");
-    props.setProperty("name", getUniqueName());
-    new CacheFactory(props).create();
-    
-    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
-    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
-    final QueryExp constraint = Query.eq(Query.attr("Name"), Query.value(getUniqueName()));
-    
-    waitForMemberMXBean(mbeanServer, pattern);
-    
-    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
-    assertFalse(mbeanNames.isEmpty());
-    assertEquals(1, mbeanNames.size());
-    
-    final ObjectName objectName = mbeanNames.iterator().next();
-    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
-
-    assertNotNull(mbean);
-    assertEquals(getUniqueName(), mbean.getMember());
-  }
-  
-  private void waitForMemberMXBean(final MBeanServer mbeanServer, final ObjectName pattern) throws Exception {
-    assertEventuallyTrue("waiting for MemberMXBean to be registered", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
-        return !mbeanNames.isEmpty();
-      }
-    }, WAIT_FOR_MBEAN_TIMEOUT, INTERVAL);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherTestSuite.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherTestSuite.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherTestSuite.java
deleted file mode 100644
index b5e787a..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LauncherTestSuite.java
+++ /dev/null
@@ -1,47 +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 com.gemstone.gemfire.distributed;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-   AbstractLauncherJUnitTest.class,
-   AbstractLauncherServiceStatusJUnitTest.class,
-   
-   LauncherMemberMXBeanJUnitTest.class,
-
-   LocatorLauncherJUnitTest.class,
-   LocatorLauncherLocalJUnitTest.class,
-   LocatorLauncherLocalFileJUnitTest.class,
-   LocatorLauncherRemoteJUnitTest.class,
-   LocatorLauncherRemoteFileJUnitTest.class,
-
-   ServerLauncherJUnitTest.class,
-   ServerLauncherLocalJUnitTest.class,
-   ServerLauncherLocalFileJUnitTest.class,
-   ServerLauncherRemoteJUnitTest.class,
-   ServerLauncherRemoteFileJUnitTest.class,
-   ServerLauncherWithProviderJUnitTest.class,
-})
-/**
- * Suite of tests for the Launcher classes.
- * 
- */
-public class LauncherTestSuite {
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
deleted file mode 100755
index 3b56554..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
+++ /dev/null
@@ -1,248 +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 com.gemstone.gemfire.distributed;
-
-import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static org.assertj.core.api.BDDAssertions.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests for LocatorLauncher. These tests require file system I/O.
- */
-@Category(IntegrationTest.class)
-public class LocatorLauncherIntegrationJUnitTest {
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Rule
-  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  @Test
-  public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
-    // given: a new builder and working directory
-    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: parsing many arguments
-    builder.parseArguments(
-        "start", 
-        "memberOne", 
-        "--bind-address", InetAddress.getLocalHost().getHostAddress(),
-        "--dir", expectedWorkingDirectory, 
-        "--hostname-for-clients", "Tucows", 
-        "--pid", "1234", 
-        "--port", "11235",
-        "--redirect-output", 
-        "--force", 
-        "--debug");
-
-    // then: the getters should return properly parsed values
-    assertThat(builder.getCommand()).isEqualTo(Command.START);
-    assertThat(builder.getBindAddress()).isEqualTo(InetAddress.getLocalHost());
-    assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
-    assertThat(builder.getHostnameForClients()).isEqualTo("Tucows");
-    assertThat(builder.getPid().intValue()).isEqualTo(1234);
-    assertThat(builder.getPort().intValue()).isEqualTo(11235);
-    assertThat(builder.getRedirectOutput()).isTrue();
-    assertThat(builder.getForce()).isTrue();
-    assertThat(builder.getDebug()).isTrue();
-  }
-
-  @Test
-  public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
-    // given: a new builder and a directory
-    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: parsing arguments with values separated by equals
-    builder.parseArguments(
-        "start", 
-        "--dir=" + expectedWorkingDirectory, 
-        "--port=" + "12345", 
-        "memberOne");
-
-    // then: the getters should return properly parsed values
-    assertThat(builder.getCommand()).isEqualTo(Command.START);
-    assertThat(builder.getDebug()).isFalse();
-    assertThat(builder.getForce()).isFalse();
-    assertThat(builder.getHelp()).isFalse();
-    assertThat(builder.getBindAddress()).isNull();
-    assertThat(builder.getHostnameForClients()).isNull();
-    assertThat(builder.getMemberName()).isEqualTo("memberOne");
-    assertThat(builder.getPid()).isNull();
-    assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
-    assertThat(builder.getPort().intValue()).isEqualTo(12345);
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
-    // given: gemfire.properties with a name
-    Properties gemfireProperties = new Properties();
-    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "locator123");
-    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
-    
-    // when: starting with null MemberName
-    LocatorLauncher launcher = new Builder()
-        .setCommand(Command.START)
-        .setMemberName(null)
-        .build();
-
-    // then: name in gemfire.properties file should be used for MemberName
-    assertThat(launcher).isNotNull();
-    assertThat(launcher.getCommand()).isEqualTo(Command.START);
-    assertThat(launcher.getMemberName()).isNull();
-  }
-
-  @Test
-  public void testBuildWithNoMemberNameOnStart() throws Exception {
-    // given: gemfire.properties with no name
-    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
-
-    // when: no MemberName is specified
-    when(new Builder()
-        .setCommand(Command.START))
-        .build();
-    
-    // then: throw IllegalStateException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalStateException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"));
-  }
-
-  @Test
-  public void testBuilderSetAndGetWorkingDirectory() throws Exception {
-    // given: a new builder and a directory
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: not setting WorkingDirectory
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-    
-    // when: setting WorkingDirectory to null
-    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to empty string
-    assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to white space
-    assertThat(builder.setWorkingDirectory("  ")).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to a directory
-    assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
-    // then: getWorkingDirectory returns that directory
-    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
-
-    // when: setting WorkingDirectory to null (again)
-    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-  }
-
-  @Test
-  public void testBuilderSetWorkingDirectoryToFile() throws IOException {
-    // given: a file instead of a directory
-    File tmpFile = this.temporaryFolder.newFile();
-
-    // when: setting WorkingDirectory to that file
-    when(new Builder())
-        .setWorkingDirectory(tmpFile.getCanonicalPath());
-
-    // then: throw IllegalArgumentException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalArgumentException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
-        .hasCause(new FileNotFoundException(tmpFile.getCanonicalPath()));
-  }
-
-  @Test
-  public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
-    // given: using LocatorLauncher in-process
-    
-    // when: setting WorkingDirectory to non-current directory
-    when(new Builder()
-        .setCommand(Command.START)
-        .setMemberName("memberOne")
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
-        .build();
-    
-    // then: throw IllegalStateException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalStateException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Locator"));
-  }
-  
-  @Test
-  public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
-    // when: setting WorkingDirectory to non-existing directory
-    when(new Builder())
-        .setWorkingDirectory("/path/to/non_existing/directory");
-    
-    // then: throw IllegalArgumentException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalArgumentException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
-        .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
-  }
-
-  /**
-   * Creates a gemfire properties file in temporaryFolder:
-   * <ol>
-   * <li>creates <code>fileName</code> in <code>temporaryFolder</code></li>
-   * <li>sets "gemfirePropertyFile" system property</li>
-   * <li>writes <code>gemfireProperties</code> to the file</li>
-   * </ol>
-   */
-  private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
-    File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
-    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
-    
-    gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-    assertThat(propertiesFile.isFile()).isTrue();
-    assertThat(propertiesFile.exists()).isTrue();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationTest.java
new file mode 100755
index 0000000..b463e84
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationTest.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.assertj.core.api.BDDAssertions.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.Properties;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for LocatorLauncher. These tests require file system I/O.
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherIntegrationTest {
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+  
+  @Rule
+  public final TestName testName = new TestName();
+  
+  @Test
+  public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
+    // given: a new builder and working directory
+    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: parsing many arguments
+    builder.parseArguments(
+        "start", 
+        "memberOne", 
+        "--bind-address", InetAddress.getLocalHost().getHostAddress(),
+        "--dir", expectedWorkingDirectory, 
+        "--hostname-for-clients", "Tucows", 
+        "--pid", "1234", 
+        "--port", "11235",
+        "--redirect-output", 
+        "--force", 
+        "--debug");
+
+    // then: the getters should return properly parsed values
+    assertThat(builder.getCommand()).isEqualTo(Command.START);
+    assertThat(builder.getBindAddress()).isEqualTo(InetAddress.getLocalHost());
+    assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
+    assertThat(builder.getHostnameForClients()).isEqualTo("Tucows");
+    assertThat(builder.getPid().intValue()).isEqualTo(1234);
+    assertThat(builder.getPort().intValue()).isEqualTo(11235);
+    assertThat(builder.getRedirectOutput()).isTrue();
+    assertThat(builder.getForce()).isTrue();
+    assertThat(builder.getDebug()).isTrue();
+  }
+
+  @Test
+  public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
+    // given: a new builder and a directory
+    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: parsing arguments with values separated by equals
+    builder.parseArguments(
+        "start", 
+        "--dir=" + expectedWorkingDirectory, 
+        "--port=" + "12345", 
+        "memberOne");
+
+    // then: the getters should return properly parsed values
+    assertThat(builder.getCommand()).isEqualTo(Command.START);
+    assertThat(builder.getDebug()).isFalse();
+    assertThat(builder.getForce()).isFalse();
+    assertThat(builder.getHelp()).isFalse();
+    assertThat(builder.getBindAddress()).isNull();
+    assertThat(builder.getHostnameForClients()).isNull();
+    assertThat(builder.getMemberName()).isEqualTo("memberOne");
+    assertThat(builder.getPid()).isNull();
+    assertThat(builder.getWorkingDirectory()).isEqualTo(expectedWorkingDirectory);
+    assertThat(builder.getPort().intValue()).isEqualTo(12345);
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
+    // given: gemfire.properties with a name
+    Properties gemfireProperties = new Properties();
+    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "locator123");
+    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
+    
+    // when: starting with null MemberName
+    LocatorLauncher launcher = new Builder()
+        .setCommand(Command.START)
+        .setMemberName(null)
+        .build();
+
+    // then: name in gemfire.properties file should be used for MemberName
+    assertThat(launcher).isNotNull();
+    assertThat(launcher.getCommand()).isEqualTo(Command.START);
+    assertThat(launcher.getMemberName()).isNull();
+  }
+
+  @Test
+  public void testBuildWithNoMemberNameOnStart() throws Exception {
+    // given: gemfire.properties with no name
+    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
+
+    // when: no MemberName is specified
+    when(new Builder()
+        .setCommand(Command.START))
+        .build();
+    
+    // then: throw IllegalStateException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalStateException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"));
+  }
+
+  @Test
+  public void testBuilderSetAndGetWorkingDirectory() throws Exception {
+    // given: a new builder and a directory
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: not setting WorkingDirectory
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+    
+    // when: setting WorkingDirectory to null
+    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to empty string
+    assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to white space
+    assertThat(builder.setWorkingDirectory("  ")).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to a directory
+    assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
+    // then: getWorkingDirectory returns that directory
+    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+
+    // when: setting WorkingDirectory to null (again)
+    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+  }
+
+  @Test
+  public void testBuilderSetWorkingDirectoryToFile() throws IOException {
+    // given: a file instead of a directory
+    File tmpFile = this.temporaryFolder.newFile();
+
+    // when: setting WorkingDirectory to that file
+    when(new Builder())
+        .setWorkingDirectory(tmpFile.getCanonicalPath());
+
+    // then: throw IllegalArgumentException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalArgumentException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
+        .hasCause(new FileNotFoundException(tmpFile.getCanonicalPath()));
+  }
+
+  @Test
+  public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
+    // given: using LocatorLauncher in-process
+    
+    // when: setting WorkingDirectory to non-current directory
+    when(new Builder()
+        .setCommand(Command.START)
+        .setMemberName("memberOne")
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
+        .build();
+    
+    // then: throw IllegalStateException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalStateException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Locator"));
+  }
+  
+  @Test
+  public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
+    // when: setting WorkingDirectory to non-existing directory
+    when(new Builder())
+        .setWorkingDirectory("/path/to/non_existing/directory");
+    
+    // then: throw IllegalArgumentException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalArgumentException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Locator"))
+        .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
+  }
+
+  /**
+   * Creates a gemfire properties file in temporaryFolder:
+   * <ol>
+   * <li>creates <code>fileName</code> in <code>temporaryFolder</code></li>
+   * <li>sets "gemfirePropertyFile" system property</li>
+   * <li>writes <code>gemfireProperties</code> to the file</li>
+   * </ol>
+   */
+  private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+    File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    
+    gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+    assertThat(propertiesFile.isFile()).isTrue();
+    assertThat(propertiesFile.exists()).isTrue();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
deleted file mode 100644
index a8ddd6a..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
+++ /dev/null
@@ -1,341 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import joptsimple.OptionException;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-/**
- * The LocatorLauncherJUnitTest class is a test suite of test cases for testing the contract and functionality of
- * launching a GemFire Locator.
- *
- * @see com.gemstone.gemfire.distributed.LocatorLauncher
- * @see com.gemstone.gemfire.distributed.LocatorLauncher.Builder
- * @see com.gemstone.gemfire.distributed.LocatorLauncher.Command
- * @see org.junit.Assert
- * @see org.junit.Test
- * @since 7.0
- */
-@Category(UnitTest.class)
-public class LocatorLauncherJUnitTest {
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Rule
-  public final TestName testName = new TestName();
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testBuilderParseArgumentsWithNonNumericPort() {
-    try {
-      new Builder().parseArguments("start", "locator1", "--port", "oneTwoThree");
-    }
-    catch (IllegalArgumentException expected) {
-      assertTrue(expected.getCause() instanceof OptionException);
-      assertTrue(expected.getMessage(), expected.getMessage().contains(
-        LocalizedStrings.Launcher_Builder_PARSE_COMMAND_LINE_ARGUMENT_ERROR_MESSAGE.toLocalizedString(
-          "Locator", expected.getCause().getMessage())));
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testForceDefaultsToFalse() {
-    assertFalse(new Builder().getForce());
-  }
-
-  @Test
-  public void testForceSetToTrue() {
-    Builder builder = new Builder();
-
-    builder.parseArguments("start", "--force");
-
-    assertTrue(Boolean.TRUE.equals(builder.getForce()));
-  }
-
-  @Test
-  public void testSetAndGetCommand() {
-    final Builder builder = new Builder();
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-    assertSame(builder, builder.setCommand(Command.START));
-    assertEquals(Command.START, builder.getCommand());
-    assertSame(builder, builder.setCommand(Command.STATUS));
-    assertEquals(Command.STATUS, builder.getCommand());
-    assertSame(builder, builder.setCommand(Command.STOP));
-    assertEquals(Command.STOP, builder.getCommand());
-    assertSame(builder, builder.setCommand(null));
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-  }
-
-  @Test
-  public void testSetAndGetBindAddress() throws UnknownHostException {
-    final Builder builder = new Builder();
-
-    assertNull(builder.getBindAddress());
-    assertSame(builder, builder.setBindAddress(null));
-    assertNull(builder.getBindAddress());
-    assertSame(builder, builder.setBindAddress(""));
-    assertNull(builder.getBindAddress());
-    assertSame(builder, builder.setBindAddress("  "));
-    assertNull(builder.getBindAddress());
-    assertSame(builder, builder.setBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
-    assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetBindAddressToUnknownHost() {
-    try {
-      new Builder().setBindAddress("badhostname.badcompany.bad");
-    }
-    catch (IllegalArgumentException expected) {
-      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Locator");
-      final String expectedMessage2 = "badhostname.badcompany.bad is not an address for this machine.";
-      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
-      if (expected.getMessage().equals(expectedMessage1)) {
-        assertTrue(expected.getCause() instanceof UnknownHostException);
-      }
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetBindAddressToNonLocalHost() {
-    try {
-      new Builder().setBindAddress("yahoo.com");
-    }
-    catch (IllegalArgumentException expected) {
-      final String expectedMessage = "yahoo.com is not an address for this machine.";
-      assertEquals(expectedMessage, expected.getMessage());
-      throw expected;
-    }
-  }
-  
-  @Test
-  public void testSetBindAddressToLocalHost() throws Exception {        
-    String host = InetAddress.getLocalHost().getHostName();            
-    new Builder().setBindAddress(host);
-  }
-  
-  @Test
-  public void testSetAndGetHostnameForClients() {
-    final Builder builder = new Builder();
-
-    assertNull(builder.getHostnameForClients());
-    assertSame(builder, builder.setHostnameForClients("Pegasus"));
-    assertEquals("Pegasus", builder.getHostnameForClients());
-    assertSame(builder, builder.setHostnameForClients(null));
-    assertNull(builder.getHostnameForClients());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetHostnameForClientsWithBlankString() {
-    try {
-      new Builder().setHostnameForClients(" ");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
-        .toLocalizedString(), expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetHostnameForClientsWithEmptyString() {
-    try {
-      new Builder().setHostnameForClients("");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
-        .toLocalizedString(), expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetMemberName() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMemberName());
-    assertSame(builder, builder.setMemberName("locatorOne"));
-    assertEquals("locatorOne", builder.getMemberName());
-    assertSame(builder, builder.setMemberName(null));
-    assertNull(builder.getMemberName());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMemberNameWithBlankString() {
-    try {
-      new Builder().setMemberName("  ");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Locator"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMemberNameWithEmptyString() {
-    try {
-      new Builder().setMemberName("");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Locator"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetPid() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getPid());
-    assertSame(builder, builder.setPid(0));
-    assertEquals(0, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(1));
-    assertEquals(1, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(1024));
-    assertEquals(1024, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(12345));
-    assertEquals(12345, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(null));
-    assertNull(builder.getPid());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetPidToInvalidValue() {
-    try {
-      new Builder().setPid(-1);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_PID_ERROR_MESSAGE.toLocalizedString(), expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @SuppressWarnings("deprecation")
-  @Test
-  public void testSetAndGetPort() {
-    Builder builder = new Builder();
-
-    assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
-    assertSame(builder, builder.setPort(65535));
-    assertEquals(65535, builder.getPort().intValue());
-    assertSame(builder, builder.setPort(1024));
-    assertEquals(1024, builder.getPort().intValue());
-    assertSame(builder, builder.setPort(80));
-    assertEquals(80, builder.getPort().intValue());
-    assertSame(builder, builder.setPort(1));
-    assertEquals(1, builder.getPort().intValue());
-    assertSame(builder, builder.setPort(0));
-    assertEquals(0, builder.getPort().intValue());
-    assertSame(builder, builder.setPort(null));
-    assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetPortToOverflow() {
-    try {
-      new Builder().setPort(65536);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Locator"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetPortToUnderflow() {
-    try {
-      new Builder().setPort(-1);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Locator"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testBuild() throws Exception {
-    Builder builder = new Builder();
-
-    LocatorLauncher launcher = builder.setCommand(Command.START)
-      .setDebug(true)
-      .setHostnameForClients("beanstock.vmware.com")
-      .setMemberName("Beanstock")
-      .setPort(8192)
-      .build();
-
-    assertNotNull(launcher);
-    assertEquals(builder.getCommand(), launcher.getCommand());
-    assertTrue(launcher.isDebugging());
-    assertEquals(builder.getHostnameForClients(), launcher.getHostnameForClients());
-    assertEquals(builder.getMemberName(), launcher.getMemberName());
-    assertEquals(builder.getPort(), launcher.getPort());
-    assertEquals(builder.getWorkingDirectory(), launcher.getWorkingDirectory());
-    assertFalse(launcher.isHelping());
-    assertFalse(launcher.isRunning());
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
-    LocatorLauncher launcher = new Builder()
-      .setCommand(LocatorLauncher.Command.START)
-      .setMemberName(null)
-      .set(DistributionConfig.NAME_NAME, "locatorABC")
-      .build();
-
-    assertNotNull(launcher);
-    assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
-    assertNull(launcher.getMemberName());
-    assertEquals("locatorABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
-    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "locatorXYZ");
-
-    LocatorLauncher launcher = new Builder()
-      .setCommand(LocatorLauncher.Command.START)
-      .setMemberName(null)
-      .build();
-
-    assertNotNull(launcher);
-    assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
-    assertNull(launcher.getMemberName());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileIntegrationTest.java
new file mode 100755
index 0000000..c695b07
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileIntegrationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Subclass of LocatorLauncherLocalDUnitTest which forces the code to not find 
+ * the Attach API which is in the JDK tools.jar. As a result LocatorLauncher
+ * ends up using the FileProcessController implementation.
+ *
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherLocalFileIntegrationTest extends LocatorLauncherLocalIntegrationTest {
+
+  @Before
+  public final void setUpLocatorLauncherLocalFileIntegrationTest() throws Exception {
+    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
+  }
+  
+  @After
+  public final void tearDownLocatorLauncherLocalFileIntegrationTest() throws Exception {
+  }
+  
+  @Override
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertFalse(factory.isAttachAPIFound());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileJUnitTest.java
deleted file mode 100755
index 7dc5452..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalFileJUnitTest.java
+++ /dev/null
@@ -1,51 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-
-/**
- * Subclass of LocatorLauncherLocalDUnitTest which forces the code to not find 
- * the Attach API which is in the JDK tools.jar. As a result LocatorLauncher
- * ends up using the FileProcessController implementation.
- *
- * @since 8.0
- */
-public class LocatorLauncherLocalFileJUnitTest extends LocatorLauncherLocalJUnitTest {
-
-  @Before
-  public final void setUpLocatorLauncherLocalFileTest() throws Exception {
-    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
-  }
-  
-  @After
-  public final void tearDownLocatorLauncherLocalFileTest() throws Exception {   
-  }
-  
-  @Override
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertFalse(factory.isAttachAPIFound());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
new file mode 100755
index 0000000..bb18a22
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherLocalIntegrationTest.java
@@ -0,0 +1,842 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.lang.management.ManagementFactory;
+import java.net.BindException;
+import java.net.InetAddress;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalLocator;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.DistributionLocator;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Tests usage of LocatorLauncher as a local API in existing JVM.
+ *
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherLocalIntegrationTest extends AbstractLocatorLauncherIntegrationTestCase {
+  
+  @Before
+  public final void setUpLocatorLauncherLocalIntegrationTest() throws Exception {
+    disconnectFromDS();
+    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
+  }
+
+  @After
+  public final void tearDownLocatorLauncherLocalIntegrationTest() throws Exception {
+    disconnectFromDS();
+  }
+
+  protected Status getExpectedStopStatusForNotRunning() {
+    return Status.NOT_RESPONDING;
+  }
+
+  @Test
+  public void testBuilderSetProperties() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    this.launcher = new Builder()
+        .setForce(true)
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0")
+        .build();
+
+    try {
+      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
+      waitForLocatorToStart(this.launcher, true);
+  
+      final InternalLocator locator = this.launcher.getLocator();
+      assertNotNull(locator);
+  
+      final DistributedSystem distributedSystem = locator.getDistributedSystem();
+  
+      assertNotNull(distributedSystem);
+      assertEquals("true", distributedSystem.getProperties().getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME));
+      assertEquals("0", distributedSystem.getProperties().getProperty(DistributionConfig.MCAST_PORT_NAME));
+      assertEquals("config", distributedSystem.getProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME));
+      assertEquals(getUniqueName(), distributedSystem.getProperties().getProperty(DistributionConfig.NAME_NAME));
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      assertNull(this.launcher.getLocator());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertTrue(factory.isAttachAPIFound());
+  }
+  
+  @Test
+  public void testStartCreatesPidFile() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    this.launcher = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .build();
+
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartDeletesStaleControlFiles() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // create existing control files
+    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
+    this.stopRequestFile.createNewFile();
+    assertTrue(this.stopRequestFile.exists());
+
+    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
+    this.statusRequestFile.createNewFile();
+    assertTrue(this.statusRequestFile.exists());
+
+    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
+    this.statusFile.createNewFile();
+    assertTrue(this.statusFile.exists());
+    
+    // build and start the locator
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    this.launcher.start();
+    
+    try {
+      waitForLocatorToStart(this.launcher);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+      
+      // validate stale control files were deleted
+      assertFalse(stopRequestFile.exists());
+      assertFalse(statusRequestFile.exists());
+      assertFalse(statusFile.exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStartOverwritesStalePidFile() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE, Integer.MAX_VALUE == ProcessUtils.identifyPid());
+    writePid(this.pidFile, Integer.MAX_VALUE);
+
+    // build and start the locator
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    this.launcher.start();
+    
+    try {
+      waitForLocatorToStart(this.launcher);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
+  }/*
+    assertTrue(getUniqueName() + " is broken if PID == Integer.MAX_VALUE", ProcessUtils.identifyPid() != Integer.MAX_VALUE);
+    
+    // create existing pid file
+    this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse(realPid == ProcessUtils.identifyPid());
+    writePid(this.pidFile, realPid);
+
+    // build and start the locator
+    final Builder builder = new Builder()
+        .setForce(true)
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertTrue(builder.getForce());
+    this.launcher = builder.build();
+    assertTrue(this.launcher.isForcing());
+    this.launcher.start();
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+      
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(logFileName).exists());
+      
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartUsingForceOverwritesExistingPidFile
+  */
+  
+  @Test
+  public void testStartWithDefaultPortInUseFails() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    assertTrue(this.socket.isBound());
+    assertFalse(this.socket.isClosed());
+    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+
+    assertNotNull(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY));
+    assertEquals(this.locatorPort, Integer.valueOf(System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY)).intValue());
+    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+    
+    this.launcher = new Builder()
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .build();
+    
+    assertEquals(this.locatorPort, this.launcher.getPort().intValue());
+    
+    RuntimeException expected = null;
+    try {
+      this.launcher.start();
+     
+      // why did it not fail like it's supposed to?
+      final String property = System.getProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY);
+      assertNotNull(property);
+      assertEquals(this.locatorPort, Integer.valueOf(property).intValue());
+      assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+      assertEquals(this.locatorPort, this.launcher.getPort().intValue());
+      assertEquals(this.locatorPort, this.socket.getLocalPort());
+      assertTrue(this.socket.isBound());
+      assertFalse(this.socket.isClosed());
+      
+      fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      // BindException text varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof BindException);
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+      
+      // creation of log file seems to be random -- look into why sometime
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // just in case the launcher started...
+    LocatorState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      waitForFileToDelete(this.pidFile);
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartWithExistingPidFileFails() throws Throwable {
+  }/*
+    // create existing pid file
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
+
+    this.pidFile = new File(ProcessType.LOCATOR.getPidFileName());
+    writePid(this.pidFile, realPid);
+    
+    // build and start the locator
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+    RuntimeException expected = null;
+    
+    try {
+      this.launcher.start();
+      fail("LocatorLauncher start should have thrown RuntimeException caused by FileAlreadyExistsException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      assertTrue(expected.getMessage(), expected.getMessage().contains("A PID file already exists and a Locator may be running in"));
+      assertEquals(RuntimeException.class, expected.getClass());
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    // just in case the launcher started...
+    LocatorState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof FileAlreadyExistsException);
+      assertTrue(cause.getMessage().contains("Pid file already exists: "));
+      assertTrue(cause.getMessage().contains("vf.gf.locator.pid for process " + realPid));
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    try {
+      delete(this.pidFile);
+      final Status theStatus = status.getStatus();
+      assertFalse(theStatus == Status.STARTING);
+      assertFalse(theStatus == Status.ONLINE);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartWithExistingPidFileFails
+  */
+  
+  @Test
+  public void testStartUsingPort() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // generate one free port and then use it instead of default
+    final int freeTCPPort = AvailablePortHelper.getRandomAvailableTCPPort();
+    assertTrue(AvailablePort.isPortAvailable(freeTCPPort, AvailablePort.SOCKET));
+    
+    this.launcher = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(freeTCPPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .build();
+
+    int pid = 0;
+    try {
+      // if start succeeds without throwing exception then #47778 is fixed
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(pidFile.exists());
+      pid = readPid(pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      // verify locator did not use default port
+      assertTrue(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+      
+      final LocatorState status = this.launcher.status();
+      final String portString = status.getPort();
+      assertEquals("Port should be \"" + freeTCPPort + "\" instead of " + portString, String.valueOf(freeTCPPort), portString);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStartUsingPortInUseFails() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // generate one free port and then use it instead of default
+    final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
+    
+    this.launcher = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(freeTCPPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .build();
+    
+    RuntimeException expected = null;
+    try {
+      this.launcher.start();
+      fail("LocatorLauncher start should have thrown RuntimeException caused by BindException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof BindException);
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.pidFile = new File (this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+      
+      // creation of log file seems to be random -- look into why sometime
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // just in case the launcher started...
+    LocatorState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      waitForFileToDelete(this.pidFile);
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStatusUsingPid() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    // build and start the locator
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+    
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    
+    LocatorLauncher pidLauncher = null;
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+      
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+  
+      pidLauncher = new Builder().setPid(pid).build();
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      final LocatorState actualStatus = pidLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    if (pidLauncher == null) {
+      try {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+      
+    } else {
+      try {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+    }
+  }
+  
+  @Test
+  public void testStatusUsingWorkingDirectory() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+    
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    
+    LocatorLauncher dirLauncher = null;
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+      
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+  
+      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+
+      final LocatorState actualStatus = dirLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator in this process (to move logFile and pidFile into temp dir)
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(rootFolder + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    if (dirLauncher == null) {
+      try {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+      
+    } else {
+      try {
+        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+    }
+  }
+  
+  @Test
+  public void testStopUsingPid() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    LocatorLauncher pidLauncher = null;
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+
+      pidLauncher = new Builder().setPid(pid).build();
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+      
+      // stop the locator
+      final LocatorState locatorState = pidLauncher.stop();
+      assertNotNull(locatorState);
+      assertEquals(Status.STOPPED, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.launcher.stop();
+    } catch (Throwable e) {
+      // ignore
+    }
+
+    try {
+      // verify the PID file was deleted
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStopUsingWorkingDirectory() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    LocatorLauncher dirLauncher = null;
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+    
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+
+      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+      
+      // stop the locator
+      final LocatorState locatorState = dirLauncher.stop();
+      assertNotNull(locatorState);
+      assertEquals(Status.STOPPED, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.launcher.stop();
+    } catch (Throwable e) {
+      // ignore
+    }
+
+    try {
+      // verify the PID file was deleted
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+}



[06/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
deleted file mode 100755
index b61f89d..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
+++ /dev/null
@@ -1,312 +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 com.gemstone.gemfire.distributed;
-
-import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
-import static com.googlecode.catchexception.apis.BDDCatchException.when;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.BDDAssertions.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.net.InetAddress;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.distributed.ServerLauncher.Command;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests for ServerLauncher class. These tests may require file system and/or network I/O.
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherIntegrationJUnitTest {
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Rule
-  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  @Test
-  public void testBuildWithManyArguments() throws Exception {
-    // given
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    // when
-    ServerLauncher launcher = new Builder()
-        .setCommand(Command.STOP)
-        .setAssignBuckets(true)
-        .setForce(true)
-        .setMemberName("serverOne")
-        .setRebalance(true)
-        .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
-        .setServerPort(11235)
-        .setWorkingDirectory(rootFolder)
-        .setCriticalHeapPercentage(90.0f)
-        .setEvictionHeapPercentage(75.0f)
-        .setMaxConnections(100)
-        .setMaxMessageCount(512)
-        .setMaxThreads(8)
-        .setMessageTimeToLive(120000)
-        .setSocketBufferSize(32768)
-        .build();
-
-    // then
-    assertThat(launcher).isNotNull();
-    assertThat(launcher.isAssignBuckets()).isTrue();
-    assertThat(launcher.isDebugging()).isFalse();
-    assertThat(launcher.isDisableDefaultServer()).isFalse();
-    assertThat(launcher.isForcing()).isTrue();
-    assertThat(launcher.isHelping()).isFalse();
-    assertThat(launcher.isRebalancing()).isTrue();
-    assertThat(launcher.isRunning()).isFalse();
-    assertThat(launcher.getCommand()).isEqualTo(Command.STOP);
-    assertThat(launcher.getMemberName()).isEqualTo("serverOne");
-    assertThat(launcher.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
-    assertThat(launcher.getServerPort().intValue()).isEqualTo(11235);
-    assertThat(launcher.getWorkingDirectory()).isEqualTo(rootFolder);
-    assertThat(launcher.getCriticalHeapPercentage().floatValue()).isEqualTo(90.0f);
-    assertThat(launcher.getEvictionHeapPercentage().floatValue()).isEqualTo(75.0f);
-    assertThat(launcher.getMaxConnections().intValue()).isEqualTo(100);
-    assertThat(launcher.getMaxMessageCount().intValue()).isEqualTo(512);
-    assertThat(launcher.getMaxThreads().intValue()).isEqualTo(8);
-    assertThat(launcher.getMessageTimeToLive().intValue()).isEqualTo(120000);
-    assertThat(launcher.getSocketBufferSize().intValue()).isEqualTo(32768);
-  }
-
-  @Test
-  public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
-    // given a new builder and a directory
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: parsing many arguments
-    builder.parseArguments(
-        "start", 
-        "serverOne", 
-        "--assign-buckets", 
-        "--disable-default-server", 
-        "--debug", 
-        "--force",
-        "--rebalance", 
-        "--redirect-output", 
-        "--dir", rootFolder, 
-        "--pid", "1234",
-        "--server-bind-address", InetAddress.getLocalHost().getHostAddress(), 
-        "--server-port", "11235", 
-        "--hostname-for-clients", "192.168.99.100");
-
-    // then: the getters should return properly parsed values
-    assertThat(builder.getCommand()).isEqualTo(Command.START);
-    assertThat(builder.getMemberName()).isEqualTo("serverOne");
-    assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
-    assertThat(builder.getAssignBuckets()).isTrue();
-    assertThat(builder.getDisableDefaultServer()).isTrue();
-    assertThat(builder.getDebug()).isTrue();
-    assertThat(builder.getForce()).isTrue();
-    assertThat(builder.getHelp()).isFalse();
-    assertThat(builder.getRebalance()).isTrue();
-    assertThat(builder.getRedirectOutput()).isTrue();
-    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
-    assertThat(builder.getPid().intValue()).isEqualTo(1234);
-    assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
-    assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
-  }
-
-  @Test
-  public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
-    // given a new builder and a directory
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: parsing many arguments
-    builder.parseArguments(
-        "start", 
-        "serverOne", 
-        "--assign-buckets", 
-        "--disable-default-server", 
-        "--debug", 
-        "--force",
-        "--rebalance", 
-        "--redirect-output", 
-        "--dir=" + rootFolder, 
-        "--pid=1234",
-        "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(), 
-        "--server-port=11235", 
-        "--hostname-for-clients=192.168.99.100");
-
-    // then: the getters should return properly parsed values
-    assertThat(builder.getCommand()).isEqualTo(Command.START);
-    assertThat(builder.getMemberName()).isEqualTo("serverOne");
-    assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
-    assertThat(builder.getAssignBuckets()).isTrue();
-    assertThat(builder.getDisableDefaultServer()).isTrue();
-    assertThat(builder.getDebug()).isTrue();
-    assertThat(builder.getForce()).isTrue();
-    assertThat(builder.getHelp()).isFalse();
-    assertThat(builder.getRebalance()).isTrue();
-    assertThat(builder.getRedirectOutput()).isTrue();
-    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
-    assertThat(builder.getPid().intValue()).isEqualTo(1234);
-    assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
-    assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
-    // given: gemfire.properties with a name
-    Properties gemfireProperties = new Properties();
-    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
-    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
-
-    // when: starting with null MemberName
-    ServerLauncher launcher = new Builder()
-        .setCommand(Command.START)
-        .setMemberName(null)
-        .build();
-
-    // then: name in gemfire.properties file should be used for MemberName
-    assertThat(launcher).isNotNull();
-    assertThat(launcher.getCommand()).isEqualTo(Command.START);
-    assertThat(launcher.getMemberName()).isNull();
-  }
-  
-  @Test
-  public void testBuildWithNoMemberNameOnStart() throws Exception {
-    // given: gemfire.properties with no name
-    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
-
-    // when: no MemberName is specified
-    when(new Builder()
-        .setCommand(Command.START))
-        .build();
-    
-    // then: throw IllegalStateException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalStateException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"));
-  }
-
-  @Test
-  public void testBuilderSetAndGetWorkingDirectory() throws Exception {
-    // given: a new builder and a directory
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    Builder builder = new Builder();
-
-    // when: not setting WorkingDirectory
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(ServerLauncher.DEFAULT_WORKING_DIRECTORY);
-    
-    // when: setting WorkingDirectory to null
-    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to empty string
-    assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to white space
-    assertThat(builder.setWorkingDirectory("  ")).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-
-    // when: setting WorkingDirectory to a directory
-    assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
-    // then: getWorkingDirectory returns that directory
-    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
-
-    // when: setting WorkingDirectory to null (again)
-    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
-    // then: getWorkingDirectory returns default
-    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
-  }
-
-  @Test
-  public void testBuilderSetWorkingDirectoryToFile() throws Exception {
-    // given: a file instead of a directory
-    File tmpFile = this.temporaryFolder.newFile();
-
-    // when: setting WorkingDirectory to that file
-    when(new Builder())
-        .setWorkingDirectory(tmpFile.getAbsolutePath());
-    
-    // then: throw IllegalArgumentException
-    then(caughtException())
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
-        .hasCause(new FileNotFoundException(tmpFile.getAbsolutePath()));
-  }
-
-  @Test
-  public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
-    // given: using ServerLauncher in-process
-
-    // when: setting WorkingDirectory to non-current directory
-    when(new Builder()
-        .setCommand(Command.START)
-        .setMemberName("serverOne")
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
-        .build();
-    
-    // then: throw IllegalStateException
-    then(caughtException())
-        .isExactlyInstanceOf(IllegalStateException.class)
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Server"));
-  }
-
-  @Test
-  public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
-    // when: setting WorkingDirectory to non-existing directory
-    when(new Builder())
-        .setWorkingDirectory("/path/to/non_existing/directory");
-    
-    // then: throw IllegalArgumentException
-    then(caughtException())
-        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
-        .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
-  }
-
-  /**
-   * Creates a gemfire properties file in temporaryFolder:
-   * <li>creates <code>fileName</code> in <code>temporaryFolder</code>
-   * <li>sets "gemfirePropertyFile" system property
-   * <li>writes <code>gemfireProperties</code> to the file
-   */
-  private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
-    File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
-    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
-    
-    gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
-    assertThat(propertiesFile.isFile()).isTrue();
-    assertThat(propertiesFile.exists()).isTrue();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationTest.java
new file mode 100755
index 0000000..98c8ce6
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationTest.java
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static com.googlecode.catchexception.apis.BDDCatchException.caughtException;
+import static com.googlecode.catchexception.apis.BDDCatchException.when;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.BDDAssertions.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.net.InetAddress;
+import java.util.Properties;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.ServerLauncher.Command;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for ServerLauncher class. These tests may require file system and/or network I/O.
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherIntegrationTest {
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+  
+  @Rule
+  public final TestName testName = new TestName();
+  
+  @Test
+  public void testBuildWithManyArguments() throws Exception {
+    // given
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    // when
+    ServerLauncher launcher = new Builder()
+        .setCommand(Command.STOP)
+        .setAssignBuckets(true)
+        .setForce(true)
+        .setMemberName("serverOne")
+        .setRebalance(true)
+        .setServerBindAddress(InetAddress.getLocalHost().getHostAddress())
+        .setServerPort(11235)
+        .setWorkingDirectory(rootFolder)
+        .setCriticalHeapPercentage(90.0f)
+        .setEvictionHeapPercentage(75.0f)
+        .setMaxConnections(100)
+        .setMaxMessageCount(512)
+        .setMaxThreads(8)
+        .setMessageTimeToLive(120000)
+        .setSocketBufferSize(32768)
+        .build();
+
+    // then
+    assertThat(launcher).isNotNull();
+    assertThat(launcher.isAssignBuckets()).isTrue();
+    assertThat(launcher.isDebugging()).isFalse();
+    assertThat(launcher.isDisableDefaultServer()).isFalse();
+    assertThat(launcher.isForcing()).isTrue();
+    assertThat(launcher.isHelping()).isFalse();
+    assertThat(launcher.isRebalancing()).isTrue();
+    assertThat(launcher.isRunning()).isFalse();
+    assertThat(launcher.getCommand()).isEqualTo(Command.STOP);
+    assertThat(launcher.getMemberName()).isEqualTo("serverOne");
+    assertThat(launcher.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+    assertThat(launcher.getServerPort().intValue()).isEqualTo(11235);
+    assertThat(launcher.getWorkingDirectory()).isEqualTo(rootFolder);
+    assertThat(launcher.getCriticalHeapPercentage().floatValue()).isEqualTo(90.0f);
+    assertThat(launcher.getEvictionHeapPercentage().floatValue()).isEqualTo(75.0f);
+    assertThat(launcher.getMaxConnections().intValue()).isEqualTo(100);
+    assertThat(launcher.getMaxMessageCount().intValue()).isEqualTo(512);
+    assertThat(launcher.getMaxThreads().intValue()).isEqualTo(8);
+    assertThat(launcher.getMessageTimeToLive().intValue()).isEqualTo(120000);
+    assertThat(launcher.getSocketBufferSize().intValue()).isEqualTo(32768);
+  }
+
+  @Test
+  public void testBuilderParseArgumentsWithValuesSeparatedWithCommas() throws Exception {
+    // given a new builder and a directory
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: parsing many arguments
+    builder.parseArguments(
+        "start", 
+        "serverOne", 
+        "--assign-buckets", 
+        "--disable-default-server", 
+        "--debug", 
+        "--force",
+        "--rebalance", 
+        "--redirect-output", 
+        "--dir", rootFolder, 
+        "--pid", "1234",
+        "--server-bind-address", InetAddress.getLocalHost().getHostAddress(), 
+        "--server-port", "11235", 
+        "--hostname-for-clients", "192.168.99.100");
+
+    // then: the getters should return properly parsed values
+    assertThat(builder.getCommand()).isEqualTo(Command.START);
+    assertThat(builder.getMemberName()).isEqualTo("serverOne");
+    assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+    assertThat(builder.getAssignBuckets()).isTrue();
+    assertThat(builder.getDisableDefaultServer()).isTrue();
+    assertThat(builder.getDebug()).isTrue();
+    assertThat(builder.getForce()).isTrue();
+    assertThat(builder.getHelp()).isFalse();
+    assertThat(builder.getRebalance()).isTrue();
+    assertThat(builder.getRedirectOutput()).isTrue();
+    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+    assertThat(builder.getPid().intValue()).isEqualTo(1234);
+    assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+    assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
+  }
+
+  @Test
+  public void testBuilderParseArgumentsWithValuesSeparatedWithEquals() throws Exception {
+    // given a new builder and a directory
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: parsing many arguments
+    builder.parseArguments(
+        "start", 
+        "serverOne", 
+        "--assign-buckets", 
+        "--disable-default-server", 
+        "--debug", 
+        "--force",
+        "--rebalance", 
+        "--redirect-output", 
+        "--dir=" + rootFolder, 
+        "--pid=1234",
+        "--server-bind-address=" + InetAddress.getLocalHost().getHostAddress(), 
+        "--server-port=11235", 
+        "--hostname-for-clients=192.168.99.100");
+
+    // then: the getters should return properly parsed values
+    assertThat(builder.getCommand()).isEqualTo(Command.START);
+    assertThat(builder.getMemberName()).isEqualTo("serverOne");
+    assertThat(builder.getHostNameForClients()).isEqualTo("192.168.99.100");
+    assertThat(builder.getAssignBuckets()).isTrue();
+    assertThat(builder.getDisableDefaultServer()).isTrue();
+    assertThat(builder.getDebug()).isTrue();
+    assertThat(builder.getForce()).isTrue();
+    assertThat(builder.getHelp()).isFalse();
+    assertThat(builder.getRebalance()).isTrue();
+    assertThat(builder.getRedirectOutput()).isTrue();
+    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+    assertThat(builder.getPid().intValue()).isEqualTo(1234);
+    assertThat(builder.getServerBindAddress()).isEqualTo(InetAddress.getLocalHost());
+    assertThat(builder.getServerPort().intValue()).isEqualTo(11235);
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() throws Exception {
+    // given: gemfire.properties with a name
+    Properties gemfireProperties = new Properties();
+    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
+    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", gemfireProperties);
+
+    // when: starting with null MemberName
+    ServerLauncher launcher = new Builder()
+        .setCommand(Command.START)
+        .setMemberName(null)
+        .build();
+
+    // then: name in gemfire.properties file should be used for MemberName
+    assertThat(launcher).isNotNull();
+    assertThat(launcher.getCommand()).isEqualTo(Command.START);
+    assertThat(launcher.getMemberName()).isNull();
+  }
+  
+  @Test
+  public void testBuildWithNoMemberNameOnStart() throws Exception {
+    // given: gemfire.properties with no name
+    useGemFirePropertiesFileInTemporaryFolder("gemfire.properties", new Properties());
+
+    // when: no MemberName is specified
+    when(new Builder()
+        .setCommand(Command.START))
+        .build();
+    
+    // then: throw IllegalStateException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalStateException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"));
+  }
+
+  @Test
+  public void testBuilderSetAndGetWorkingDirectory() throws Exception {
+    // given: a new builder and a directory
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    Builder builder = new Builder();
+
+    // when: not setting WorkingDirectory
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(ServerLauncher.DEFAULT_WORKING_DIRECTORY);
+    
+    // when: setting WorkingDirectory to null
+    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to empty string
+    assertThat(builder.setWorkingDirectory("")).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to white space
+    assertThat(builder.setWorkingDirectory("  ")).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+
+    // when: setting WorkingDirectory to a directory
+    assertThat(builder.setWorkingDirectory(rootFolder)).isSameAs(builder);
+    // then: getWorkingDirectory returns that directory
+    assertThat(builder.getWorkingDirectory()).isEqualTo(rootFolder);
+
+    // when: setting WorkingDirectory to null (again)
+    assertThat(builder.setWorkingDirectory(null)).isSameAs(builder);
+    // then: getWorkingDirectory returns default
+    assertThat(builder.getWorkingDirectory()).isEqualTo(AbstractLauncher.DEFAULT_WORKING_DIRECTORY);
+  }
+
+  @Test
+  public void testBuilderSetWorkingDirectoryToFile() throws Exception {
+    // given: a file instead of a directory
+    File tmpFile = this.temporaryFolder.newFile();
+
+    // when: setting WorkingDirectory to that file
+    when(new Builder())
+        .setWorkingDirectory(tmpFile.getAbsolutePath());
+    
+    // then: throw IllegalArgumentException
+    then(caughtException())
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+        .hasCause(new FileNotFoundException(tmpFile.getAbsolutePath()));
+  }
+
+  @Test
+  public void testBuildSetWorkingDirectoryToNonCurrentDirectoryOnStart() throws Exception {
+    // given: using ServerLauncher in-process
+
+    // when: setting WorkingDirectory to non-current directory
+    when(new Builder()
+        .setCommand(Command.START)
+        .setMemberName("serverOne")
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()))
+        .build();
+    
+    // then: throw IllegalStateException
+    then(caughtException())
+        .isExactlyInstanceOf(IllegalStateException.class)
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE.toLocalizedString("Server"));
+  }
+
+  @Test
+  public void testBuilderSetWorkingDirectoryToNonExistingDirectory() {
+    // when: setting WorkingDirectory to non-existing directory
+    when(new Builder())
+        .setWorkingDirectory("/path/to/non_existing/directory");
+    
+    // then: throw IllegalArgumentException
+    then(caughtException())
+        .hasMessage(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE.toLocalizedString("Server"))
+        .hasCause(new FileNotFoundException("/path/to/non_existing/directory"));
+  }
+
+  /**
+   * Creates a gemfire properties file in temporaryFolder:
+   * <li>creates <code>fileName</code> in <code>temporaryFolder</code>
+   * <li>sets "gemfirePropertyFile" system property
+   * <li>writes <code>gemfireProperties</code> to the file
+   */
+  private void useGemFirePropertiesFileInTemporaryFolder(final String fileName, final Properties gemfireProperties) throws Exception {
+    File propertiesFile = new File(this.temporaryFolder.getRoot().getCanonicalPath(), fileName);
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    
+    gemfireProperties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+    assertThat(propertiesFile.isFile()).isTrue();
+    assertThat(propertiesFile.exists()).isTrue();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
deleted file mode 100755
index 395a9e6..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
+++ /dev/null
@@ -1,903 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Collections;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.distributed.ServerLauncher.Command;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.support.DistributedSystemAdapter;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import edu.umd.cs.mtc.MultithreadedTestCase;
-import edu.umd.cs.mtc.TestFramework;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.lib.concurrent.Synchroniser;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-/**
- * The ServerLauncherJUnitTest class is a test suite of unit tests testing the contract, functionality and invariants
- * of the ServerLauncher class.
- *
- * @see com.gemstone.gemfire.distributed.ServerLauncher
- * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
- * @see com.gemstone.gemfire.distributed.ServerLauncher.Command
- * @see org.junit.Assert
- * @see org.junit.Test
- * @since 7.0
- */
-@SuppressWarnings({"deprecation", "unused"})
-@Category(UnitTest.class)
-public class ServerLauncherJUnitTest {
-
-  private Mockery mockContext;
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  @Before
-  public void setup() {
-    mockContext = new Mockery() {{
-      setImposteriser(ClassImposteriser.INSTANCE);
-      setThreadingPolicy(new Synchroniser());
-    }};
-  }
-
-  @After
-  public void tearDown() {
-    mockContext.assertIsSatisfied();
-    mockContext = null;
-  }
-
-  @Test
-  public void testParseCommand() {
-    Builder builder = new Builder();
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-
-    builder.parseCommand((String[]) null);
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-
-    builder.parseCommand(); // empty String array
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-
-    builder.parseCommand(Command.START.getName());
-
-    assertEquals(Command.START, builder.getCommand());
-
-    builder.parseCommand("Status");
-
-    assertEquals(Command.STATUS, builder.getCommand());
-
-    builder.parseCommand("sToP");
-
-    assertEquals(Command.STOP, builder.getCommand());
-
-    builder.parseCommand("--opt", "START", "-o", Command.STATUS.getName());
-
-    assertEquals(Command.START, builder.getCommand());
-
-    builder.setCommand(null);
-    builder.parseCommand("badCommandName", "--start", "stat");
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-  }
-
-  @Test
-  public void testParseMemberName() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMemberName());
-
-    builder.parseMemberName((String[]) null);
-
-    assertNull(builder.getMemberName());
-
-    builder.parseMemberName(); // empty String array
-
-    assertNull(builder.getMemberName());
-
-    builder.parseMemberName(Command.START.getName(), "--opt", "-o");
-
-    assertNull(builder.getMemberName());
-
-    builder.parseMemberName("memberOne");
-
-    assertEquals("memberOne", builder.getMemberName());
-  }
-
-  @Test
-  public void testSetAndGetCommand() {
-    Builder builder = new Builder();
-
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-    assertSame(builder, builder.setCommand(Command.STATUS));
-    assertEquals(Command.STATUS, builder.getCommand());
-    assertSame(builder, builder.setCommand(null));
-    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
-  }
-
-  @Test
-  public void testSetAndGetMemberName() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMemberName());
-    assertSame(builder, builder.setMemberName("serverOne"));
-    assertEquals("serverOne", builder.getMemberName());
-    assertSame(builder, builder.setMemberName(null));
-    assertNull(builder.getMemberName());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMemberNameToBlankString() {
-    try {
-      new Builder().setMemberName("  ");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Server"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMemberNameToEmptyString() {
-    try {
-      new Builder().setMemberName("");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Server"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetPid() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getPid());
-    assertSame(builder, builder.setPid(0));
-    assertEquals(0, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(1));
-    assertEquals(1, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(1024));
-    assertEquals(1024, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(12345));
-    assertEquals(12345, builder.getPid().intValue());
-    assertSame(builder, builder.setPid(null));
-    assertNull(builder.getPid());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetPidToInvalidValue() {
-    try {
-      new Builder().setPid(-1);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_PID_ERROR_MESSAGE.toLocalizedString(), expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetServerBindAddress() throws Exception {
-    Builder builder = new Builder();
-
-    assertNull(builder.getServerBindAddress());
-    assertSame(builder, builder.setServerBindAddress(null));
-    assertNull(builder.getServerBindAddress());
-    assertSame(builder, builder.setServerBindAddress(""));
-    assertNull(builder.getServerBindAddress());
-    assertSame(builder, builder.setServerBindAddress("  "));
-    assertNull(builder.getServerBindAddress());
-    assertSame(builder, builder.setServerBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
-    assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetServerBindAddressToUnknownHost() {
-    try {
-      new Builder().setServerBindAddress("badHostName.badCompany.com");
-    }
-    catch (IllegalArgumentException expected) {
-      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Server");
-      final String expectedMessage2 = "badHostName.badCompany.com is not an address for this machine.";
-      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
-      if (expected.getMessage().equals(expectedMessage1)) {
-        assertTrue(expected.getCause() instanceof UnknownHostException);
-      }
-      throw expected;
-    }
-  }
-  
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetServerBindAddressToNonLocalHost() {
-    try {
-      new Builder().setServerBindAddress("yahoo.com");
-    }
-    catch (IllegalArgumentException expected) {
-      final String expectedMessage = "yahoo.com is not an address for this machine.";
-      assertEquals(expectedMessage, expected.getMessage());
-      throw expected;
-    }
-  }
-  
-  @Test
-  public void testSetServerBindAddressToLocalHost() throws Exception {
-    String host = InetAddress.getLocalHost().getHostName();            
-    new Builder().setServerBindAddress(host);
-  }
-
-  @Test
-  public void testSetAndGetHostnameForClients() {
-    final Builder builder = new Builder();
-
-    assertNull(builder.getHostNameForClients());
-    assertSame(builder, builder.setHostNameForClients("Pegasus"));
-    assertEquals("Pegasus", builder.getHostNameForClients());
-    assertSame(builder, builder.setHostNameForClients(null));
-    assertNull(builder.getHostNameForClients());
-  }
-
-  @Test
-  public void testSetAndGetServerPort() {
-    Builder builder = new Builder();
-
-    assertEquals(ServerLauncher.DEFAULT_SERVER_PORT, builder.getServerPort());
-    assertSame(builder, builder.setServerPort(0));
-    assertEquals(0, builder.getServerPort().intValue());
-    assertSame(builder, builder.setServerPort(1));
-    assertEquals(1, builder.getServerPort().intValue());
-    assertSame(builder, builder.setServerPort(80));
-    assertEquals(80, builder.getServerPort().intValue());
-    assertSame(builder, builder.setServerPort(1024));
-    assertEquals(1024, builder.getServerPort().intValue());
-    assertSame(builder, builder.setServerPort(65535));
-    assertEquals(65535, builder.getServerPort().intValue());
-    assertSame(builder, builder.setServerPort(null));
-    assertEquals(ServerLauncher.DEFAULT_SERVER_PORT, builder.getServerPort());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetServerPortToOverflow() {
-    try {
-      new Builder().setServerPort(65536);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Server"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetServerPortToUnderflow() {
-    try {
-      new Builder().setServerPort(-1);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Server"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetCriticalHeapPercentage() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getCriticalHeapPercentage());
-    assertSame(builder, builder.setCriticalHeapPercentage(55.5f));
-    assertEquals(55.5f, builder.getCriticalHeapPercentage().floatValue(), 0.0f);
-    assertSame(builder, builder.setCriticalHeapPercentage(null));
-    assertNull(builder.getCriticalHeapPercentage());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetCriticalHeapPercentageToOverflow() {
-    try {
-      new Builder().setCriticalHeapPercentage(100.01f);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Critical heap percentage (100.01) must be between 0 and 100!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetCriticalHeapPercentageToUnderflow() {
-    try {
-      new Builder().setCriticalHeapPercentage(-0.01f);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Critical heap percentage (-0.01) must be between 0 and 100!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetEvictionHeapPercentage() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getEvictionHeapPercentage());
-    assertSame(builder, builder.setEvictionHeapPercentage(55.55f));
-    assertEquals(55.55f, builder.getEvictionHeapPercentage().floatValue(), 0.0f);
-    assertSame(builder, builder.setEvictionHeapPercentage(null));
-    assertNull(builder.getEvictionHeapPercentage());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetEvictionHeapPercentageToOverflow() {
-    try {
-      new Builder().setEvictionHeapPercentage(101.0f);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Eviction heap percentage (101.0) must be between 0 and 100!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetEvictionHeapPercentageToUnderflow() {
-    try {
-      new Builder().setEvictionHeapPercentage(-10.0f);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Eviction heap percentage (-10.0) must be between 0 and 100!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetMaxConnections() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMaxConnections());
-    assertSame(builder, builder.setMaxConnections(1000));
-    assertEquals(1000, builder.getMaxConnections().intValue());
-    assertSame(builder, builder.setMaxConnections(null));
-    assertNull(builder.getMaxConnections());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMaxConnectionsWithIllegalValue() {
-    try {
-      new Builder().setMaxConnections(-10);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Max Connections (-10) must be greater than 0!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetMaxMessageCount() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMaxMessageCount());
-    assertSame(builder, builder.setMaxMessageCount(50));
-    assertEquals(50, builder.getMaxMessageCount().intValue());
-    assertSame(builder, builder.setMaxMessageCount(null));
-    assertNull(builder.getMaxMessageCount());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMaxMessageCountWithIllegalValue() {
-    try {
-      new Builder().setMaxMessageCount(0);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Max Message Count (0) must be greater than 0!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetMaxThreads() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMaxThreads());
-    assertSame(builder, builder.setMaxThreads(16));
-    assertEquals(16, builder.getMaxThreads().intValue());
-    assertSame(builder, builder.setMaxThreads(null));
-    assertNull(builder.getMaxThreads());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMaxThreadsWithIllegalValue() {
-    try {
-      new Builder().setMaxThreads(-4);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Max Threads (-4) must be greater than 0!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetMessageTimeToLive() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getMessageTimeToLive());
-    assertSame(builder, builder.setMessageTimeToLive(30000));
-    assertEquals(30000, builder.getMessageTimeToLive().intValue());
-    assertSame(builder, builder.setMessageTimeToLive(null));
-    assertNull(builder.getMessageTimeToLive());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetMessageTimeToLiveWithIllegalValue() {
-    try {
-      new Builder().setMessageTimeToLive(0);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("Message Time To Live (0) must be greater than 0!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testSetAndGetSocketBufferSize() {
-    Builder builder = new Builder();
-
-    assertNull(builder.getSocketBufferSize());
-    assertSame(builder, builder.setSocketBufferSize(32768));
-    assertEquals(32768, builder.getSocketBufferSize().intValue());
-    assertSame(builder, builder.setSocketBufferSize(null));
-    assertNull(builder.getSocketBufferSize());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetSocketBufferSizeWithIllegalValue() {
-    try {
-      new Builder().setSocketBufferSize(-8192);
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals("The Server's Socket Buffer Size (-8192) must be greater than 0!", expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
-    ServerLauncher launcher = new Builder()
-      .setCommand(ServerLauncher.Command.START)
-      .setMemberName(null)
-      .set(DistributionConfig.NAME_NAME, "serverABC")
-      .build();
-
-    assertNotNull(launcher);
-    assertEquals(ServerLauncher.Command.START, launcher.getCommand());
-    assertNull(launcher.getMemberName());
-    assertEquals("serverABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
-  }
-
-  @Test
-  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
-    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "serverXYZ");
-
-    ServerLauncher launcher = new Builder()
-      .setCommand(ServerLauncher.Command.START)
-      .setMemberName(null)
-      .build();
-
-    assertNotNull(launcher);
-    assertEquals(ServerLauncher.Command.START, launcher.getCommand());
-    assertNull(launcher.getMemberName());
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void testBuildNoMemberNameOnStart() {
-    try {
-      new Builder().setCommand(Command.START).build();
-    }
-    catch (IllegalStateException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
-  public void testIsServing() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.singletonList(mockCacheServer)));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertTrue(serverLauncher.isServing(mockCache));
-  }
-
-  @Test
-  public void testIsServingWhenNoCacheServersExist() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertFalse(serverLauncher.isServing(mockCache));
-  }
-
-  @Test
-  public void reconnectedCacheIsDiscovered() throws Exception {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final Cache mockReconnectedCache = mockContext.mock(Cache.class, "ReconnectedCache");
-
-    mockContext.checking(new Expectations() {{
-      exactly(2).of(mockCache).isReconnecting();
-      will(returnValue(Boolean.FALSE));
-
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-
-      oneOf(mockCache).isReconnecting();
-      will(returnValue(Boolean.TRUE));
-
-      oneOf(mockCache).getReconnectedCache();
-      will(returnValue(mockReconnectedCache));
-
-      oneOf(mockReconnectedCache).close();
-
-    }});
-
-    final ServerLauncher serverLauncher =
-            new Builder()
-                    .setMemberName("serverOne")
-                    .setCache(mockCache)
-                    .build();
-
-    assertNotNull(serverLauncher);
-    serverLauncher.waitOnServer();
-  }
-
-  @Test
-  public void reconnectingDistributedSystemIsDisconnectedOnStop() throws Exception {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
-    final Cache mockReconnectedCache = mockContext.mock(Cache.class, "ReconnectedCache");
-
-    mockContext.checking(new Expectations() {{
-      exactly(1).of(mockCache).isReconnecting();
-      will(returnValue(Boolean.TRUE));
-
-      exactly(1).of(mockCache).getReconnectedCache();
-      will(returnValue(mockReconnectedCache));
-
-      exactly(2).of(mockReconnectedCache).isReconnecting();
-      will(returnValue(Boolean.TRUE));
-
-      exactly(1).of(mockReconnectedCache).getReconnectedCache();
-      will(returnValue(null));
-
-      oneOf(mockReconnectedCache).getDistributedSystem();
-      will(returnValue(mockDistributedSystem));
-
-      oneOf(mockDistributedSystem).stopReconnecting();
-
-      oneOf(mockReconnectedCache).close();
-    }});
-
-    final ServerLauncher serverLauncher =
-            new Builder()
-                    .setMemberName("serverOne")
-                    .setCache(mockCache)
-                    .build();
-
-    assertNotNull(serverLauncher);
-    serverLauncher.setIsRunningForTest();
-    serverLauncher.stop();
-  }
-
-  @Test
-  public void testIsWaiting() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getDistributedSystem();
-      will(returnValue(mockDistributedSystem));
-      oneOf(mockDistributedSystem).isConnected();
-      will(returnValue(true));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-
-    serverLauncher.running.set(true);
-
-    assertTrue(serverLauncher.isRunning());
-    assertTrue(serverLauncher.isWaiting(mockCache));
-  }
-
-  @Test
-  public void testIsWaitingWhenNotConnected() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getDistributedSystem();
-      will(returnValue(mockDistributedSystem));
-      oneOf(mockDistributedSystem).isConnected();
-      will(returnValue(false));
-      oneOf(mockCache).isReconnecting();
-      will(returnValue(Boolean.FALSE));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-
-    serverLauncher.running.set(true);
-
-    assertTrue(serverLauncher.isRunning());
-    assertFalse(serverLauncher.isWaiting(mockCache));
-  }
-
-  @Test
-  public void testIsWaitingWhenNotRunning() {
-    ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-
-    serverLauncher.running.set(false);
-
-    assertFalse(serverLauncher.isRunning());
-    assertFalse(serverLauncher.isWaiting(null));
-  }
-
-  @Test
-  public void testWaitOnServer() throws Throwable {
-    TestFramework.runOnce(new ServerWaitMultiThreadedTestCase());
-  }
-
-  @Test
-  public void testIsDefaultServerEnabled() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-    }});
-
-    ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertFalse(serverLauncher.isDisableDefaultServer());
-    assertTrue(serverLauncher.isDefaultServerEnabled(mockCache));
-  }
-
-  @Test
-  public void testIsDefaultServerEnabledWhenCacheServersExist() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.singletonList(mockCacheServer)));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertFalse(serverLauncher.isDisableDefaultServer());
-    assertFalse(serverLauncher.isDefaultServerEnabled(mockCache));
-  }
-  @Test
-  public void testIsDefaultServerEnabledWhenNoCacheServersExistAndDefaultServerDisabled() {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(true).build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertTrue(serverLauncher.isDisableDefaultServer());
-    assertFalse(serverLauncher.isDefaultServerEnabled(mockCache));
-  }
-
-  @Test
-  public void testStartCacheServer() throws IOException {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-      oneOf(mockCache).addCacheServer();
-      will(returnValue(mockCacheServer));
-      oneOf(mockCacheServer).setBindAddress(with(aNull(String.class)));
-      oneOf(mockCacheServer).setPort(with(equal(11235)));
-      oneOf(mockCacheServer).start();
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne")
-      .setServerBindAddress(null)
-      .setServerPort(11235)
-      .setDisableDefaultServer(false)
-      .build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertFalse(serverLauncher.isDisableDefaultServer());
-
-    serverLauncher.startCacheServer(mockCache);
-  }
-
-  @Test
-  public void testStartCacheServerWhenDefaultServerDisabled() throws IOException {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.emptyList()));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(true).build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertTrue(serverLauncher.isDisableDefaultServer());
-
-    serverLauncher.startCacheServer(mockCache);
-  }
-
-  @Test
-  public void testStartCacheServerWithExistingCacheServer() throws IOException {
-    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
-
-    mockContext.checking(new Expectations() {{
-      oneOf(mockCache).getCacheServers();
-      will(returnValue(Collections.singletonList(mockCacheServer)));
-    }});
-
-    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
-
-    assertNotNull(serverLauncher);
-    assertEquals("serverOne", serverLauncher.getMemberName());
-    assertFalse(serverLauncher.isDisableDefaultServer());
-
-    serverLauncher.startCacheServer(mockCache);
-  }
-  
-  public static void main(final String... args) {
-    System.err.printf("Thread (%1$s) is daemon (%2$s)%n", Thread.currentThread().getName(),
-      Thread.currentThread().isDaemon());
-    new Builder(args).setCommand(Command.START).build().run();
-  }
-
-  private final class ServerWaitMultiThreadedTestCase extends MultithreadedTestCase {
-
-    private final AtomicBoolean connectionStateHolder = new AtomicBoolean(true);
-
-    private ServerLauncher serverLauncher;
-
-    @Override
-    public void initialize() {
-      super.initialize();
-
-      final Cache mockCache = mockContext.mock(Cache.class, "Cache");
-
-      final DistributedSystem mockDistributedSystem = new DistributedSystemAdapter() {
-        @Override public boolean isConnected() {
-          return connectionStateHolder.get();
-        }
-      };
-
-      mockContext.checking(new Expectations() {{
-        allowing(mockCache).getDistributedSystem();
-        will(returnValue(mockDistributedSystem));
-        allowing(mockCache).isReconnecting();
-        will(returnValue(Boolean.FALSE));
-        allowing(mockCache).getCacheServers();
-        will(returnValue(Collections.emptyList()));
-        oneOf(mockCache).close();
-      }});
-
-      this.serverLauncher = new Builder().setMemberName("dataMember").setDisableDefaultServer(true)
-        .setCache(mockCache).build();
-
-      assertNotNull(this.serverLauncher);
-      assertEquals("dataMember", this.serverLauncher.getMemberName());
-      assertTrue(this.serverLauncher.isDisableDefaultServer());
-      assertTrue(connectionStateHolder.get());
-    }
-
-    public void thread1() {
-      assertTick(0);
-
-      Thread.currentThread().setName("GemFire Data Member 'main' Thread");
-      this.serverLauncher.running.set(true);
-
-      assertTrue(this.serverLauncher.isRunning());
-      assertFalse(this.serverLauncher.isServing(this.serverLauncher.getCache()));
-      assertTrue(this.serverLauncher.isWaiting(this.serverLauncher.getCache()));
-
-      this.serverLauncher.waitOnServer();
-
-      assertTick(1); // NOTE the tick does not advance when the other Thread terminates
-    }
-
-    public void thread2() {
-      waitForTick(1);
-
-      Thread.currentThread().setName("GemFire 'shutdown' Thread");
-
-      assertTrue(this.serverLauncher.isRunning());
-
-      this.connectionStateHolder.set(false);
-    }
-
-    @Override
-    public void finish() {
-      super.finish();
-      assertFalse(this.serverLauncher.isRunning());
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileIntegrationTest.java
new file mode 100755
index 0000000..5a457a7
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileIntegrationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Subclass of ServerLauncherLocalDUnitTest which forces the code to not find 
+ * the Attach API which is in the JDK tools.jar.  As a result ServerLauncher
+ * ends up using the FileProcessController implementation.
+ *
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherLocalFileIntegrationTest extends ServerLauncherLocalIntegrationTest {
+
+  @Before
+  public final void setUpServerLauncherLocalFileTest() throws Exception {
+    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
+  }
+  
+  @After
+  public final void tearDownServerLauncherLocalFileTest() throws Exception {   
+  }
+  
+  @Override
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertFalse(factory.isAttachAPIFound());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileJUnitTest.java
deleted file mode 100755
index bda05c4..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalFileJUnitTest.java
+++ /dev/null
@@ -1,54 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Subclass of ServerLauncherLocalDUnitTest which forces the code to not find 
- * the Attach API which is in the JDK tools.jar.  As a result ServerLauncher
- * ends up using the FileProcessController implementation.
- *
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherLocalFileJUnitTest extends ServerLauncherLocalJUnitTest {
-
-  @Before
-  public final void setUpServerLauncherLocalFileTest() throws Exception {
-    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
-  }
-  
-  @After
-  public final void tearDownServerLauncherLocalFileTest() throws Exception {   
-  }
-  
-  @Override
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertFalse(factory.isAttachAPIFound());
-  }
-}


[05/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
new file mode 100755
index 0000000..03672b6
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalIntegrationTest.java
@@ -0,0 +1,1073 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.net.BindException;
+import java.net.InetAddress;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
+import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Integration tests for ServerLauncher as a local API in the local JVM.
+ *
+ * @see com.gemstone.gemfire.distributed.AbstractLauncher
+ * @see com.gemstone.gemfire.distributed.ServerLauncher
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.ServerState
+ * @see com.gemstone.gemfire.internal.AvailablePortHelper
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherLocalIntegrationTest extends AbstractServerLauncherIntegrationTestCase {
+  
+  @Before
+  public final void setUpServerLauncherLocalTest() throws Exception {
+    disconnectFromDS();
+    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
+  }
+
+  @After
+  public final void tearDownServerLauncherLocalTest() throws Exception {    
+    disconnectFromDS();
+  }
+  
+  protected Status getExpectedStopStatusForNotRunning() {
+    return Status.NOT_RESPONDING;
+  }
+
+  @Test
+  public void testBuilderSetProperties() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    this.launcher = new Builder()
+        .setDisableDefaultServer(true)
+        .setForce(true)
+        .setMemberName(getUniqueName())
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0")
+        .build();
+
+    assertNotNull(this.launcher);
+    
+    try {
+      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
+      waitForServerToStart(this.launcher);
+  
+      final Cache cache = this.launcher.getCache();
+  
+      assertNotNull(cache);
+  
+      final DistributedSystem distributedSystem = cache.getDistributedSystem();
+  
+      assertNotNull(distributedSystem);
+      assertEquals("true", distributedSystem.getProperties().getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME));
+      assertEquals("config", distributedSystem.getProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME));
+      assertEquals("0", distributedSystem.getProperties().getProperty(DistributionConfig.MCAST_PORT_NAME));
+      assertEquals(getUniqueName(), distributedSystem.getProperties().getProperty(DistributionConfig.NAME_NAME));
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      assertNull(this.launcher.getCache());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertTrue(factory.isAttachAPIFound());
+  }
+  
+  @Test
+  public void testStartCreatesPidFile() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // build and start the Server locally
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+    assertNotNull(this.launcher);
+
+    try {
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartDeletesStaleControlFiles() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // create existing control files
+    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStopRequestFileName());
+    this.stopRequestFile.createNewFile();
+    assertTrue(this.stopRequestFile.exists());
+
+    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusRequestFileName());
+    this.statusRequestFile.createNewFile();
+    assertTrue(this.statusRequestFile.exists());
+
+    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusFileName());
+    this.statusFile.createNewFile();
+    assertTrue(this.statusFile.exists());
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    this.launcher.start();
+    
+    try {
+      waitForServerToStart(this.launcher);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+      
+      // validate stale control files were deleted
+      assertFalse(this.stopRequestFile.exists());
+      assertFalse(this.statusRequestFile.exists());
+      assertFalse(this.statusFile.exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStartOverwritesStalePidFile() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE, Integer.MAX_VALUE == ProcessUtils.identifyPid());
+    writePid(this.pidFile, Integer.MAX_VALUE);
+
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    this.launcher.start();
+    
+    try {
+      waitForServerToStart(this.launcher);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  /**
+   * Confirms fix for #47778.
+   */
+  @Test
+  public void testStartUsingDisableDefaultServerLeavesPortFree() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // build and start the server
+    assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+    
+    this.launcher = builder.build();
+
+    // wait for server to start
+    try {
+      // if start succeeds without throwing exception then #47778 is fixed
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      // verify server did not a port
+      assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+      
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      assertEquals("Port should be \"\" instead of " + portString, "", portString);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  /**
+   * Confirms fix for #47778.
+   */
+  @Test
+  public void testStartUsingDisableDefaultServerSkipsPortCheck() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+
+    // wait for server to start
+    try {
+      // if start succeeds without throwing exception then #47778 is fixed
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      assertEquals("Port should be \"\" instead of " + portString, "", portString);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  
+    // verify port is still in use
+    this.errorCollector.checkThat(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET), is(equalTo(false)));
+  }
+
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
+  }/*
+    assertTrue(getUniqueName() + " is broken if PID == Integer.MAX_VALUE", ProcessUtils.identifyPid() != Integer.MAX_VALUE);
+    
+    // create existing pid file
+    this.pidFile = new File(ProcessType.SERVER.getPidFileName());
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse(realPid == ProcessUtils.identifyPid());
+    writePid(this.pidFile, realPid);
+
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setForce(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertTrue(builder.getForce());
+    this.launcher = builder.build();
+    assertTrue(this.launcher.isForcing());
+    this.launcher.start();
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+
+    try {
+      waitForServerToStart(this.launcher);
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+      
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(logFileName).exists());
+      
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartUsingForceOverwritesExistingPidFile
+  */
+
+  /**
+   * Confirms part of fix for #47664
+   */
+  @Test
+  public void testStartUsingServerPortOverridesCacheXml() throws Throwable {
+    // verifies part of the fix for #47664
+    
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    // generate two free ports
+    final int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
+    assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
+    
+    // write out cache.xml with one port
+    final CacheCreation creation = new CacheCreation();
+    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
+    attrs.setScope(Scope.DISTRIBUTED_ACK);
+    attrs.setDataPolicy(DataPolicy.REPLICATE);
+    creation.createRegion(getUniqueName(), attrs);
+    creation.addCacheServer().setPort(freeTCPPorts[0]);
+    
+    File cacheXmlFile = this.temporaryFolder.newFile(getUniqueName() + ".xml");
+    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
+    CacheXmlGenerator.generate(creation, pw);
+    pw.close();
+    
+    System.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, cacheXmlFile.getCanonicalPath());
+    
+    // start server
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setServerPort(freeTCPPorts[1])
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+    this.launcher.start();
+  
+    // wait for server to start up
+    try {
+      waitForServerToStart(this.launcher);
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      // verify server used --server-port instead of default or port in cache.xml
+      assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
+      assertFalse(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
+      
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      final int port = Integer.valueOf(portString);
+      assertEquals("Port should be " + freeTCPPorts[1] + " instead of " + port, freeTCPPorts[1], port);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+      assertFalse("PID file still exists!", pidFile.exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  /**
+   * Confirms part of fix for #47664
+   */
+  @Test
+  public void testStartUsingServerPortUsedInsteadOfDefaultCacheXml() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // write out cache.xml with one port
+    final CacheCreation creation = new CacheCreation();
+    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
+    attrs.setScope(Scope.DISTRIBUTED_ACK);
+    attrs.setDataPolicy(DataPolicy.REPLICATE);
+    creation.createRegion(getUniqueName(), attrs);
+    creation.addCacheServer();
+    
+    File cacheXmlFile = this.temporaryFolder.newFile(getUniqueName() + ".xml");
+    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
+    CacheXmlGenerator.generate(creation, pw);
+    pw.close();
+    
+    System.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, cacheXmlFile.getCanonicalPath());
+      
+    // start server
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setServerPort(this.serverPort)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+    this.launcher.start();
+  
+    // wait for server to start up
+    try {
+      waitForServerToStart(this.launcher);
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertEquals(getPid(), pid);
+
+      // verify server used --server-port instead of default
+      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+      
+      final int port = Integer.valueOf( this.launcher.status().getPort());
+      assertEquals("Port should be " + this.serverPort + " instead of " + port, this.serverPort, port);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartWithDefaultPortInUseFails() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+    
+    RuntimeException expected = null;
+    try {
+      this.launcher.start();
+     
+      // why did it not fail like it's supposed to?
+      final String property = System.getProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY);
+      assertNotNull(property);
+      assertEquals(this.serverPort, Integer.valueOf(property).intValue());
+      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+      
+      fail("Server port is " + this.launcher.getCache().getCacheServers().get(0).getPort());
+      fail("ServerLauncher start should have thrown RuntimeException caused by BindException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      // BindException text varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof BindException);
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+      
+      // creation of log file seems to be random -- look into why sometime
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      waitForFileToDelete(this.pidFile);
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartWithExistingPidFileFails() throws Throwable {
+  }/*
+    // create existing pid file
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
+
+    this.pidFile = new File(ProcessType.SERVER.getPidFileName());
+    writePid(this.pidFile, realPid);
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+    RuntimeException expected = null;
+    
+    try {
+      this.launcher.start();
+      fail("ServerLauncher start should have thrown RuntimeException caused by FileAlreadyExistsException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      assertTrue(expected.getMessage().contains("A PID file already exists and a Server may be running in"));
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof FileAlreadyExistsException);
+      assertTrue(cause.getMessage().contains("Pid file already exists: "));
+      assertTrue(cause.getMessage().contains("vf.gf.server.pid for process " + realPid));
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    try {
+      delete(this.pidFile);
+      final Status theStatus = status.getStatus();
+      assertFalse(theStatus == Status.STARTING);
+      assertFalse(theStatus == Status.ONLINE);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartWithExistingPidFileFails
+  */
+  
+  /**
+   * Confirms fix for #47665.
+   */
+  @Test
+  public void testStartUsingServerPortInUseFails() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
+    final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setServerPort(freeTCPPort)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    this.launcher = builder.build();
+    
+    RuntimeException expected = null;
+    try {
+      this.launcher.start();
+      fail("ServerLauncher start should have thrown RuntimeException caused by BindException");
+    } catch (RuntimeException e) {
+      expected = e;
+      assertNotNull(expected.getMessage());
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    try {
+      assertNotNull(expected);
+      final Throwable cause = expected.getCause();
+      assertNotNull(cause);
+      assertTrue(cause instanceof BindException);
+      // BindException string varies by platform
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = this.launcher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      waitForFileToDelete(this.pidFile);
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStatusUsingPid() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+    
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    
+    ServerLauncher pidLauncher = null;
+    try {
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+      
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+  
+      pidLauncher = new Builder().setPid(pid).build();
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      final ServerState actualStatus = pidLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Server in this process (to move logFile and pidFile into temp dir)
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    if (pidLauncher == null) {
+      try {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+      
+    } else {
+      try {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+    }
+  }
+  
+  @Test
+  public void testStatusUsingWorkingDirectory() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+    
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+    
+    ServerLauncher dirLauncher = null;
+    try {
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+      
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+  
+      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+
+      final ServerState actualStatus = dirLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Server in this process (to move logFile and pidFile into temp dir)
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    if (dirLauncher == null) {
+      try {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+      
+    } else {
+      try {
+        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+        waitForFileToDelete(this.pidFile);
+      } catch (Throwable e) {
+        this.errorCollector.addError(e);
+      }
+    }
+  }
+  
+  @Test
+  public void testStopUsingPid() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    ServerLauncher pidLauncher = null;
+    
+    try {
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+
+      pidLauncher = new Builder().setPid(pid).build();
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+      
+      // stop the server
+      final ServerState serverState = pidLauncher.stop();
+      assertNotNull(serverState);
+      assertEquals(Status.STOPPED, serverState.getStatus());
+    
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.launcher.stop();
+    } catch (Throwable e) {
+      // ignore
+    }
+
+    try {
+      // verify the PID file was deleted
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStopUsingWorkingDirectory() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    // build and start the server
+    final Builder builder = new Builder()
+        .setDisableDefaultServer(true)
+        .setMemberName(getUniqueName())
+        .setRedirectOutput(true)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.MCAST_PORT_NAME, "0");
+
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    ServerLauncher dirLauncher = null;
+    try {
+      this.launcher.start();
+      waitForServerToStart(this.launcher);
+    
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+
+      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+      
+      // stop the server
+      final ServerState serverState = dirLauncher.stop();
+      assertNotNull(serverState);
+      assertEquals(Status.STOPPED, serverState.getStatus());
+    
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      this.launcher.stop();
+    } catch (Throwable e) {
+      // ignore
+    }
+
+    try {
+      // verify the PID file was deleted
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalJUnitTest.java
deleted file mode 100755
index fd7d806..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherLocalJUnitTest.java
+++ /dev/null
@@ -1,1073 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.net.BindException;
-import java.net.InetAddress;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
-import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
-import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * Integration tests for ServerLauncher as a local API in the local JVM.
- *
- * @see com.gemstone.gemfire.distributed.AbstractLauncher
- * @see com.gemstone.gemfire.distributed.ServerLauncher
- * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
- * @see com.gemstone.gemfire.distributed.ServerLauncher.ServerState
- * @see com.gemstone.gemfire.internal.AvailablePortHelper
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherLocalJUnitTest extends AbstractServerLauncherJUnitTestCase {
-  
-  @Before
-  public final void setUpServerLauncherLocalTest() throws Exception {
-    disconnectFromDS();
-    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
-  }
-
-  @After
-  public final void tearDownServerLauncherLocalTest() throws Exception {    
-    disconnectFromDS();
-  }
-  
-  protected Status getExpectedStopStatusForNotRunning() {
-    return Status.NOT_RESPONDING;
-  }
-
-  @Test
-  public void testBuilderSetProperties() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    this.launcher = new Builder()
-        .setDisableDefaultServer(true)
-        .setForce(true)
-        .setMemberName(getUniqueName())
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME, "true")
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0")
-        .build();
-
-    assertNotNull(this.launcher);
-    
-    try {
-      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
-      waitForServerToStart(this.launcher);
-  
-      final Cache cache = this.launcher.getCache();
-  
-      assertNotNull(cache);
-  
-      final DistributedSystem distributedSystem = cache.getDistributedSystem();
-  
-      assertNotNull(distributedSystem);
-      assertEquals("true", distributedSystem.getProperties().getProperty(DistributionConfig.DISABLE_AUTO_RECONNECT_NAME));
-      assertEquals("config", distributedSystem.getProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME));
-      assertEquals("0", distributedSystem.getProperties().getProperty(DistributionConfig.MCAST_PORT_NAME));
-      assertEquals(getUniqueName(), distributedSystem.getProperties().getProperty(DistributionConfig.NAME_NAME));
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      assertNull(this.launcher.getCache());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertTrue(factory.isAttachAPIFound());
-  }
-  
-  @Test
-  public void testStartCreatesPidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // build and start the Server locally
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-    assertNotNull(this.launcher);
-
-    try {
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      assertEquals(Status.ONLINE, this.launcher.status().getStatus());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartDeletesStaleControlFiles() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // create existing control files
-    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStopRequestFileName());
-    this.stopRequestFile.createNewFile();
-    assertTrue(this.stopRequestFile.exists());
-
-    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusRequestFileName());
-    this.statusRequestFile.createNewFile();
-    assertTrue(this.statusRequestFile.exists());
-
-    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusFileName());
-    this.statusFile.createNewFile();
-    assertTrue(this.statusFile.exists());
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    this.launcher.start();
-    
-    try {
-      waitForServerToStart(this.launcher);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-      
-      // validate stale control files were deleted
-      assertFalse(this.stopRequestFile.exists());
-      assertFalse(this.statusRequestFile.exists());
-      assertFalse(this.statusFile.exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStartOverwritesStalePidFile() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    assertFalse("Integer.MAX_VALUE shouldn't be the same as local pid " + Integer.MAX_VALUE, Integer.MAX_VALUE == ProcessUtils.identifyPid());
-    writePid(this.pidFile, Integer.MAX_VALUE);
-
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    this.launcher.start();
-    
-    try {
-      waitForServerToStart(this.launcher);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  /**
-   * Confirms fix for #47778.
-   */
-  @Test
-  public void testStartUsingDisableDefaultServerLeavesPortFree() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // build and start the server
-    assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-    
-    this.launcher = builder.build();
-
-    // wait for server to start
-    try {
-      // if start succeeds without throwing exception then #47778 is fixed
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      // verify server did not a port
-      assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-      
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      assertEquals("Port should be \"\" instead of " + portString, "", portString);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  /**
-   * Confirms fix for #47778.
-   */
-  @Test
-  public void testStartUsingDisableDefaultServerSkipsPortCheck() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
-    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-
-    // wait for server to start
-    try {
-      // if start succeeds without throwing exception then #47778 is fixed
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      assertEquals("Port should be \"\" instead of " + portString, "", portString);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  
-    // verify port is still in use
-    this.errorCollector.checkThat(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET), is(equalTo(false)));
-  }
-
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
-  }/*
-    assertTrue(getUniqueName() + " is broken if PID == Integer.MAX_VALUE", ProcessUtils.identifyPid() != Integer.MAX_VALUE);
-    
-    // create existing pid file
-    this.pidFile = new File(ProcessType.SERVER.getPidFileName());
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse(realPid == ProcessUtils.identifyPid());
-    writePid(this.pidFile, realPid);
-
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setForce(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertTrue(builder.getForce());
-    this.launcher = builder.build();
-    assertTrue(this.launcher.isForcing());
-    this.launcher.start();
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-
-    try {
-      waitForServerToStart(this.launcher);
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-      
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(logFileName).exists());
-      
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartUsingForceOverwritesExistingPidFile
-  */
-
-  /**
-   * Confirms part of fix for #47664
-   */
-  @Test
-  public void testStartUsingServerPortOverridesCacheXml() throws Throwable {
-    // verifies part of the fix for #47664
-    
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    // generate two free ports
-    final int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
-    assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
-    
-    // write out cache.xml with one port
-    final CacheCreation creation = new CacheCreation();
-    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
-    attrs.setScope(Scope.DISTRIBUTED_ACK);
-    attrs.setDataPolicy(DataPolicy.REPLICATE);
-    creation.createRegion(getUniqueName(), attrs);
-    creation.addCacheServer().setPort(freeTCPPorts[0]);
-    
-    File cacheXmlFile = this.temporaryFolder.newFile(getUniqueName() + ".xml");
-    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
-    CacheXmlGenerator.generate(creation, pw);
-    pw.close();
-    
-    System.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, cacheXmlFile.getCanonicalPath());
-    
-    // start server
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setServerPort(freeTCPPorts[1])
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-    this.launcher.start();
-  
-    // wait for server to start up
-    try {
-      waitForServerToStart(this.launcher);
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      // verify server used --server-port instead of default or port in cache.xml
-      assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
-      assertFalse(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
-      
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      final int port = Integer.valueOf(portString);
-      assertEquals("Port should be " + freeTCPPorts[1] + " instead of " + port, freeTCPPorts[1], port);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-      assertFalse("PID file still exists!", pidFile.exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  /**
-   * Confirms part of fix for #47664
-   */
-  @Test
-  public void testStartUsingServerPortUsedInsteadOfDefaultCacheXml() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // write out cache.xml with one port
-    final CacheCreation creation = new CacheCreation();
-    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
-    attrs.setScope(Scope.DISTRIBUTED_ACK);
-    attrs.setDataPolicy(DataPolicy.REPLICATE);
-    creation.createRegion(getUniqueName(), attrs);
-    creation.addCacheServer();
-    
-    File cacheXmlFile = this.temporaryFolder.newFile(getUniqueName() + ".xml");
-    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
-    CacheXmlGenerator.generate(creation, pw);
-    pw.close();
-    
-    System.setProperty(DistributionConfig.CACHE_XML_FILE_NAME, cacheXmlFile.getCanonicalPath());
-      
-    // start server
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setServerPort(this.serverPort)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-    this.launcher.start();
-  
-    // wait for server to start up
-    try {
-      waitForServerToStart(this.launcher);
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertEquals(getPid(), pid);
-
-      // verify server used --server-port instead of default
-      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-      
-      final int port = Integer.valueOf( this.launcher.status().getPort());
-      assertEquals("Port should be " + this.serverPort + " instead of " + port, this.serverPort, port);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartWithDefaultPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
-    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-    
-    RuntimeException expected = null;
-    try {
-      this.launcher.start();
-     
-      // why did it not fail like it's supposed to?
-      final String property = System.getProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY);
-      assertNotNull(property);
-      assertEquals(this.serverPort, Integer.valueOf(property).intValue());
-      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-      
-      fail("Server port is " + this.launcher.getCache().getCacheServers().get(0).getPort());
-      fail("ServerLauncher start should have thrown RuntimeException caused by BindException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      // BindException text varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof BindException);
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
-      
-      // creation of log file seems to be random -- look into why sometime
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      waitForFileToDelete(this.pidFile);
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartWithExistingPidFileFails() throws Throwable {
-  }/*
-    // create existing pid file
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
-
-    this.pidFile = new File(ProcessType.SERVER.getPidFileName());
-    writePid(this.pidFile, realPid);
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-    RuntimeException expected = null;
-    
-    try {
-      this.launcher.start();
-      fail("ServerLauncher start should have thrown RuntimeException caused by FileAlreadyExistsException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      assertTrue(expected.getMessage().contains("A PID file already exists and a Server may be running in"));
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof FileAlreadyExistsException);
-      assertTrue(cause.getMessage().contains("Pid file already exists: "));
-      assertTrue(cause.getMessage().contains("vf.gf.server.pid for process " + realPid));
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    try {
-      delete(this.pidFile);
-      final Status theStatus = status.getStatus();
-      assertFalse(theStatus == Status.STARTING);
-      assertFalse(theStatus == Status.ONLINE);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartWithExistingPidFileFails
-  */
-  
-  /**
-   * Confirms fix for #47665.
-   */
-  @Test
-  public void testStartUsingServerPortInUseFails() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // generate one free port and then use TEST_OVERRIDE_DEFAULT_PORT_PROPERTY
-    final int freeTCPPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(freeTCPPort, 50, null, -1);
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setServerPort(freeTCPPort)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    this.launcher = builder.build();
-    
-    RuntimeException expected = null;
-    try {
-      this.launcher.start();
-      fail("ServerLauncher start should have thrown RuntimeException caused by BindException");
-    } catch (RuntimeException e) {
-      expected = e;
-      assertNotNull(expected.getMessage());
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    try {
-      assertNotNull(expected);
-      final Throwable cause = expected.getCause();
-      assertNotNull(cause);
-      assertTrue(cause instanceof BindException);
-      // BindException string varies by platform
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertFalse("Pid file should not exist: " + this.pidFile, this.pidFile.exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = this.launcher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      waitForFileToDelete(this.pidFile);
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStatusUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-    
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    
-    ServerLauncher pidLauncher = null;
-    try {
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-      
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-  
-      pidLauncher = new Builder().setPid(pid).build();
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      final ServerState actualStatus = pidLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Server in this process (to move logFile and pidFile into temp dir)
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    if (pidLauncher == null) {
-      try {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-      
-    } else {
-      try {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-    }
-  }
-  
-  @Test
-  public void testStatusUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-    
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-    
-    ServerLauncher dirLauncher = null;
-    try {
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-      
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-  
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-
-      final ServerState actualStatus = dirLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      // getWorkingDirectory returns user.dir instead of rootFolder because test is starting Server in this process (to move logFile and pidFile into temp dir)
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    if (dirLauncher == null) {
-      try {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-      
-    } else {
-      try {
-        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-        waitForFileToDelete(this.pidFile);
-      } catch (Throwable e) {
-        this.errorCollector.addError(e);
-      }
-    }
-  }
-  
-  @Test
-  public void testStopUsingPid() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    ServerLauncher pidLauncher = null;
-    
-    try {
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-
-      pidLauncher = new Builder().setPid(pid).build();
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-      
-      // stop the server
-      final ServerState serverState = pidLauncher.stop();
-      assertNotNull(serverState);
-      assertEquals(Status.STOPPED, serverState.getStatus());
-    
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.launcher.stop();
-    } catch (Throwable e) {
-      // ignore
-    }
-
-    try {
-      // verify the PID file was deleted
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStopUsingWorkingDirectory() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    // build and start the server
-    final Builder builder = new Builder()
-        .setDisableDefaultServer(true)
-        .setMemberName(getUniqueName())
-        .setRedirectOutput(true)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.MCAST_PORT_NAME, "0");
-
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    ServerLauncher dirLauncher = null;
-    try {
-      this.launcher.start();
-      waitForServerToStart(this.launcher);
-    
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-
-      dirLauncher = new Builder().setWorkingDirectory(rootFolder).build();
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-      
-      // stop the server
-      final ServerState serverState = dirLauncher.stop();
-      assertNotNull(serverState);
-      assertEquals(Status.STOPPED, serverState.getStatus());
-    
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      this.launcher.stop();
-    } catch (Throwable e) {
-      // ignore
-    }
-
-    try {
-      // verify the PID file was deleted
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileIntegrationTest.java
new file mode 100755
index 0000000..3b5884c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileIntegrationTest.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.lang.AttachAPINotFoundException;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Subclass of ServerLauncherRemoteDUnitTest which forces the code to not find 
+ * the Attach API which is in the JDK tools.jar.  As a result ServerLauncher
+ * ends up using the FileProcessController implementation.
+ * 
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherRemoteFileIntegrationTest extends ServerLauncherRemoteIntegrationTest {
+  
+  @Before
+  public void setUpServerLauncherRemoteFileTest() throws Exception {
+    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
+  }
+  
+  @After
+  public void tearDownServerLauncherRemoteFileTest() throws Exception {   
+  }
+  
+  @Override
+  @Test
+  /**
+   * Override and assert Attach API is NOT found
+   */
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertFalse(factory.isAttachAPIFound());
+  }
+  
+  @Override
+  @Test
+  /**
+   * Override because FileProcessController cannot request status with PID
+   */
+  public void testStatusUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    ServerLauncher pidLauncher = null; 
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // status with pid only should throw AttachAPINotFoundException
+      try {
+        pidLauncher.status();
+        fail("FileProcessController should have thrown AttachAPINotFoundException");
+      } catch (AttachAPINotFoundException e) {
+        // passed
+      }
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid, true);
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    } finally {
+      new File(ProcessType.SERVER.getStatusRequestFileName()).delete(); // TODO: delete
+    }
+  }
+  
+  @Override
+  @Test
+  /**
+   * Override because FileProcessController cannot request stop with PID
+   */
+  public void testStopUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    ServerLauncher pidLauncher = null; 
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // stop with pid only should throw AttachAPINotFoundException
+      try {
+        pidLauncher.stop();
+        fail("FileProcessController should have thrown AttachAPINotFoundException");
+      } catch (AttachAPINotFoundException e) {
+        // passed
+      }
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      // stop the server
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+      waitForFileToDelete(this.pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    } finally {
+      new File(ProcessType.SERVER.getStopRequestFileName()).delete(); // TODO: delete
+    }
+  }
+}



[12/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
Fixing tests


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

Branch: refs/heads/feature/GEODE-1255
Commit: cd02af01ce9d7c54275a526e5d0ecb3a9eae87d9
Parents: 68ddd58
Author: Kirk Lund <kl...@apache.org>
Authored: Mon May 2 09:58:20 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon May 2 09:58:20 2016 -0700

----------------------------------------------------------------------
 .../LocatorLauncherAssemblyIntegrationTest.java |  155 ++
 .../LocatorLauncherAssemblyJUnitTest.java       |  156 --
 .../SharedConfigurationEndToEndDUnitTest.java   |  250 ++-
 .../internal/SharedConfiguration.java           |  532 +++----
 geode-core/src/main/resources/log4j2.xml        |    2 +-
 .../AbstractLauncherIntegrationJUnitTest.java   |   71 -
 .../AbstractLauncherIntegrationTest.java        |   71 +
 .../AbstractLauncherIntegrationTestCase.java    |  254 ++++
 .../distributed/AbstractLauncherJUnitTest.java  |  298 ----
 .../AbstractLauncherJUnitTestCase.java          |  254 ----
 .../AbstractLauncherServiceStatusJUnitTest.java |  264 ----
 .../AbstractLauncherServiceStatusTest.java      |  264 ++++
 .../distributed/AbstractLauncherTest.java       |  298 ++++
 ...tractLocatorLauncherIntegrationTestCase.java |  105 ++
 .../AbstractLocatorLauncherJUnitTestCase.java   |  105 --
 ...stractServerLauncherIntegrationTestCase.java |   93 ++
 .../AbstractServerLauncherJUnitTestCase.java    |   93 --
 .../distributed/DistributedTestSuite.java       |   35 -
 .../distributed/HostedLocatorsDUnitTest.java    |    2 +-
 .../LauncherMemberMXBeanIntegrationTest.java    |  152 ++
 .../LauncherMemberMXBeanJUnitTest.java          |  152 --
 .../gemfire/distributed/LauncherTestSuite.java  |   47 -
 .../LocatorLauncherIntegrationJUnitTest.java    |  248 ---
 .../LocatorLauncherIntegrationTest.java         |  248 +++
 .../distributed/LocatorLauncherJUnitTest.java   |  341 -----
 ...LocatorLauncherLocalFileIntegrationTest.java |   54 +
 .../LocatorLauncherLocalFileJUnitTest.java      |   51 -
 .../LocatorLauncherLocalIntegrationTest.java    |  842 +++++++++++
 .../LocatorLauncherLocalJUnitTest.java          |  842 -----------
 ...ocatorLauncherRemoteFileIntegrationTest.java |  218 +++
 .../LocatorLauncherRemoteFileJUnitTest.java     |  218 ---
 .../LocatorLauncherRemoteIntegrationTest.java   |  979 ++++++++++++
 .../LocatorLauncherRemoteJUnitTest.java         | 1152 --------------
 .../distributed/LocatorLauncherTest.java        |  341 +++++
 .../distributed/LocatorStateJUnitTest.java      |  208 ---
 .../gemfire/distributed/LocatorStateTest.java   |  208 +++
 .../ServerLauncherIntegrationJUnitTest.java     |  312 ----
 .../ServerLauncherIntegrationTest.java          |  312 ++++
 .../distributed/ServerLauncherJUnitTest.java    |  903 -----------
 .../ServerLauncherLocalFileIntegrationTest.java |   54 +
 .../ServerLauncherLocalFileJUnitTest.java       |   54 -
 .../ServerLauncherLocalIntegrationTest.java     | 1073 +++++++++++++
 .../ServerLauncherLocalJUnitTest.java           | 1073 -------------
 ...ServerLauncherRemoteFileIntegrationTest.java |  222 +++
 .../ServerLauncherRemoteFileJUnitTest.java      |  222 ---
 .../ServerLauncherRemoteIntegrationTest.java    | 1430 ++++++++++++++++++
 .../ServerLauncherRemoteJUnitTest.java          | 1430 ------------------
 .../gemfire/distributed/ServerLauncherTest.java |  903 +++++++++++
 ...rverLauncherWithProviderIntegrationTest.java |   89 ++
 .../ServerLauncherWithProviderJUnitTest.java    |   90 --
 ...leProcessControllerIntegrationJUnitTest.java |    1 -
 .../SharedConfigurationCommandsDUnitTest.java   |  175 +--
 .../SharedConfigurationDUnitTest.java           |  186 +--
 .../SharedConfigurationUsingDirDUnitTest.java   |  112 +-
 .../internal/logging/log4j/custom/log4j2.xml    |    2 +-
 .../ClusterConfigurationDUnitTest.java          |  355 ++---
 56 files changed, 9091 insertions(+), 9510 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyIntegrationTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyIntegrationTest.java
new file mode 100644
index 0000000..332cbf4
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyIntegrationTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.management.ManagementService;
+import com.gemstone.gemfire.management.ManagerMXBean;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+import static org.junit.Assert.*;
+
+/**
+ * These tests are part of assembly as they require the REST war file to be present.
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherAssemblyIntegrationTest extends AbstractLocatorLauncherIntegrationTestCase {
+
+  @Before
+  public final void setUpLocatorLauncherLocalTest() throws Exception {
+    disconnectFromDS();
+    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName() + "-");
+  }
+
+  @After
+  public final void tearDownLocatorLauncherLocalTest() throws Exception {
+    disconnectFromDS();
+  }
+
+  /*
+   * This test addresses GEODE-528
+   */
+  @Test
+  public void testLocatorStopsWhenJmxPortIsZero() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+
+    final Builder builder = new Builder()
+        .setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(false)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false")
+        .set(DistributionConfig.JMX_MANAGER_NAME, "true")
+        .set(DistributionConfig.JMX_MANAGER_START_NAME, "true")
+        .set(DistributionConfig.JMX_MANAGER_PORT_NAME, "0");
+
+    performTest(builder);
+  }
+
+  /*
+   * This test addresses GEODE-528
+   */
+  @Test
+  public void testLocatorStopsWhenJmxPortIsNonZero() throws Throwable {
+    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
+    final int jmxPort = AvailablePortHelper.getRandomAvailableTCPPorts(1)[0];
+
+    final Builder builder = new Builder().setMemberName(getUniqueName())
+        .setPort(this.locatorPort)
+        .setRedirectOutput(false)
+        .setWorkingDirectory(rootFolder)
+        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
+        .set(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false")
+        .set(DistributionConfig.JMX_MANAGER_NAME, "true")
+        .set(DistributionConfig.JMX_MANAGER_START_NAME, "true")
+        .set(DistributionConfig.JMX_MANAGER_PORT_NAME, Integer.toString(jmxPort));
+
+    performTest(builder);
+  }
+
+  private void performTest(Builder builder) {
+    assertFalse(builder.getForce());
+    this.launcher = builder.build();
+    assertFalse(this.launcher.isForcing());
+
+    LocatorLauncher dirLauncher = null;
+    int initialThreadCount = Thread.activeCount();
+
+    try {
+      this.launcher.start();
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
+      final int pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertEquals(ProcessUtils.identifyPid(), pid);
+
+      dirLauncher = new Builder().setWorkingDirectory(builder.getWorkingDirectory()).build();
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+
+      // Stop the manager
+      Cache cache = CacheFactory.getAnyInstance();
+      ManagerMXBean managerBean = ManagementService.getManagementService(cache).getManagerMXBean();
+      managerBean.stop();
+
+      // stop the locator
+      final LocatorLauncher.LocatorState locatorState = dirLauncher.stop();
+      assertNotNull(locatorState);
+      assertEquals(Status.STOPPED, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      // verify the PID file was deleted
+      waitForFileToDelete(this.pidFile);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    int finalThreadCount = Integer.MAX_VALUE;
+
+    // Spin for up to 5 seconds waiting for threads to finish
+    for (int i = 0; i < 50 && finalThreadCount > initialThreadCount; i++) {
+      try {
+        Thread.sleep(100);
+      } catch (InterruptedException ex) {
+        // ignored
+      }
+      finalThreadCount = Thread.activeCount();
+    }
+
+    assertEquals(initialThreadCount, finalThreadCount);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyJUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyJUnitTest.java
deleted file mode 100644
index 0984508..0000000
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherAssemblyJUnitTest.java
+++ /dev/null
@@ -1,156 +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 com.gemstone.gemfire.distributed;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.management.ManagementService;
-import com.gemstone.gemfire.management.ManagerMXBean;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-
-import static org.junit.Assert.*;
-
-/**
- * These tests are part of assembly as they require the REST war file to be present.
- *
- */
-@Category(IntegrationTest.class)
-public class LocatorLauncherAssemblyJUnitTest extends AbstractLocatorLauncherJUnitTestCase {
-
-  @Before
-  public final void setUpLocatorLauncherLocalTest() throws Exception {
-    disconnectFromDS();
-    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName() + "-");
-  }
-
-  @After
-  public final void tearDownLocatorLauncherLocalTest() throws Exception {
-    disconnectFromDS();
-  }
-
-  /*
-   * This test addresses GEODE-528
-   */
-  @Test
-  public void testLocatorStopsWhenJmxPortIsZero() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-
-    final Builder builder = new Builder()
-        .setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(false)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false")
-        .set(DistributionConfig.JMX_MANAGER_NAME, "true")
-        .set(DistributionConfig.JMX_MANAGER_START_NAME, "true")
-        .set(DistributionConfig.JMX_MANAGER_PORT_NAME, "0");
-
-    performTest(builder);
-  }
-
-  /*
-   * This test addresses GEODE-528
-   */
-  @Test
-  public void testLocatorStopsWhenJmxPortIsNonZero() throws Throwable {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath();
-    final int jmxPort = AvailablePortHelper.getRandomAvailableTCPPorts(1)[0];
-
-    final Builder builder = new Builder().setMemberName(getUniqueName())
-        .setPort(this.locatorPort)
-        .setRedirectOutput(false)
-        .setWorkingDirectory(rootFolder)
-        .set(DistributionConfig.LOG_LEVEL_NAME, "config")
-        .set(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false")
-        .set(DistributionConfig.JMX_MANAGER_NAME, "true")
-        .set(DistributionConfig.JMX_MANAGER_START_NAME, "true")
-        .set(DistributionConfig.JMX_MANAGER_PORT_NAME, Integer.toString(jmxPort));
-
-    performTest(builder);
-  }
-
-  private void performTest(Builder builder) {
-    assertFalse(builder.getForce());
-    this.launcher = builder.build();
-    assertFalse(this.launcher.isForcing());
-
-    LocatorLauncher dirLauncher = null;
-    int initialThreadCount = Thread.activeCount();
-
-    try {
-      this.launcher.start();
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
-      final int pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertEquals(ProcessUtils.identifyPid(), pid);
-
-      dirLauncher = new Builder().setWorkingDirectory(builder.getWorkingDirectory()).build();
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-
-      // Stop the manager
-      Cache cache = CacheFactory.getAnyInstance();
-      ManagerMXBean managerBean = ManagementService.getManagementService(cache).getManagerMXBean();
-      managerBean.stop();
-
-      // stop the locator
-      final LocatorLauncher.LocatorState locatorState = dirLauncher.stop();
-      assertNotNull(locatorState);
-      assertEquals(Status.STOPPED, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      // verify the PID file was deleted
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    int finalThreadCount = Integer.MAX_VALUE;
-
-    // Spin for up to 5 seconds waiting for threads to finish
-    for (int i = 0; i < 50 && finalThreadCount > initialThreadCount; i++) {
-      try {
-        Thread.sleep(100);
-      } catch (InterruptedException ex) {
-        // ignored
-      }
-      finalThreadCount = Thread.activeCount();
-    }
-
-    assertEquals(initialThreadCount, finalThreadCount);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
index e1093a2..9e2e94a 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
@@ -16,84 +16,69 @@
  */
 package com.gemstone.gemfire.management.internal.configuration;
 
+import static com.gemstone.gemfire.cache.RegionShortcut.*;
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
+import static com.gemstone.gemfire.internal.FileUtil.*;
+import static com.gemstone.gemfire.internal.lang.StringUtils.*;
+import static com.gemstone.gemfire.management.internal.cli.CliUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
-
 import com.gemstone.gemfire.cache.wan.GatewaySender.OrderPolicy;
 import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.ClassBuilder;
-import com.gemstone.gemfire.internal.FileUtil;
 import com.gemstone.gemfire.internal.JarDeployer;
 import com.gemstone.gemfire.internal.admin.remote.ShutdownAllRequest;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.lang.StringUtils;
 import com.gemstone.gemfire.management.cli.Result.Status;
-import com.gemstone.gemfire.management.internal.cli.CliUtil;
 import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
 import com.gemstone.gemfire.management.internal.cli.commands.CliCommandTestBase;
 import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
 import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
 @Category(DistributedTest.class)
 public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
+
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
   private static final String REGION1 = "R1";
   private static final String REGION2 = "R2";
   private static final String INDEX1 = "ID1";
-  private transient ClassBuilder classBuilder = new ClassBuilder();
-  public static Set<String> serverNames = new HashSet<String>();
-  public static Set<String> jarFileNames = new HashSet<String>();
 
-  private static final long serialVersionUID = -2276690105585944041L;
+  private static Set<String> serverNames = new HashSet<>();
+  private static Set<String> jarFileNames = new HashSet<>();
 
-  public Set<String> startServers(HeadlessGfsh gfsh, String locatorString, int numServers, String serverNamePrefix, int startNum) throws ClassNotFoundException, IOException {
-    Set<String> serverNames = new HashSet<String>();
+  private transient ClassBuilder classBuilder = new ClassBuilder();
 
-    final int[] serverPorts = AvailablePortHelper.getRandomAvailableTCPPorts(numServers);
-    for (int i=0; i<numServers; i++) {
-      int port = serverPorts[i];
-      String serverName = serverNamePrefix+ Integer.toString(i+startNum) + "-" + port;
-      CommandStringBuilder csb = new CommandStringBuilder(CliStrings.START_SERVER);
-      csb.addOption(CliStrings.START_SERVER__NAME, serverName);
-      csb.addOption(CliStrings.START_SERVER__LOCATORS, locatorString);
-      csb.addOption(CliStrings.START_SERVER__SERVER_PORT, Integer.toString(port));
-      CommandResult cmdResult = executeCommand(gfsh, csb.getCommandString());
-      assertEquals(Status.OK, cmdResult.getStatus());
-    }
-    return serverNames;
-  }
+  // TODO: move setup and teardown to @Before and @After
 
   @Test
-  public void testStartServerAndExecuteCommands() throws InterruptedException, ClassNotFoundException, IOException, ExecutionException {
+  public void testStartServerAndExecuteCommands() throws Exception {
     IgnoredException.addIgnoredException("EntryDestroyedException");
     Object[] result = setup();
     final int locatorPort = (Integer) result[0];
@@ -113,8 +98,6 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     verifyRegionCreateOnAllMembers(REGION2);
     verifyIndexCreationOnAllMembers(INDEX1);
     verifyAsyncEventQueueCreation();
-   
-
 
     //shutdown everything
     getLogWriter().info("Shutting down all the members");
@@ -122,10 +105,26 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     deleteSavedJarFiles();
   }
 
+  private Set<String> startServers(final HeadlessGfsh gfsh, final String locatorString, final int numServers, final String serverNamePrefix, final int startNum) throws ClassNotFoundException, IOException {
+    Set<String> serverNames = new HashSet<>();
+
+    final int[] serverPorts = getRandomAvailableTCPPorts(numServers);
+    for (int i=0; i<numServers; i++) {
+      int port = serverPorts[i];
+      String serverName = serverNamePrefix+ Integer.toString(i+startNum) + "-" + port;
+      CommandStringBuilder csb = new CommandStringBuilder(CliStrings.START_SERVER);
+      csb.addOption(CliStrings.START_SERVER__NAME, serverName);
+      csb.addOption(CliStrings.START_SERVER__LOCATORS, locatorString);
+      csb.addOption(CliStrings.START_SERVER__SERVER_PORT, Integer.toString(port));
+      CommandResult cmdResult = executeCommand(gfsh, csb.getCommandString());
+      assertEquals(Status.OK, cmdResult.getStatus());
+    }
+    return serverNames;
+  }
 
-  private void doCreateCommands() {
-    createRegion(REGION1, RegionShortcut.REPLICATE, null);
-    createRegion(REGION2, RegionShortcut.PARTITION, null);
+  private void doCreateCommands() throws IOException {
+    createRegion(REGION1, REPLICATE, null);
+    createRegion(REGION2, PARTITION, null);
     createIndex(INDEX1 , "AAPL", REGION1, null);
     createAndDeployJar("Deploy1.jar");
     createAsyncEventQueue("q1");
@@ -144,34 +143,33 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     createDiskStore(diskStoreName, diskDirs, autoCompact, allowForceCompaction, compactionThreshold, duCritical, duWarning, maxOplogSize, queueSize, timeInterval, writeBufferSize);
   }
 
-
-  protected void executeAndVerifyCommand(String commandString) {
+  private void executeAndVerifyCommand(final String commandString) {
     CommandResult cmdResult = executeCommand(commandString);
     getLogWriter().info("Command Result : \n" + commandResultToString(cmdResult));
     assertEquals(Status.OK, cmdResult.getStatus());
     assertFalse(cmdResult.failedToPersist());
   }
 
-  private void createRegion(String regionName, RegionShortcut regionShortCut, String group) {
+  private void createRegion(final String regionName, final RegionShortcut regionShortCut, final String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_REGION);
     csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
     csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
     executeAndVerifyCommand(csb.getCommandString());
   }
 
-  private void destroyRegion(String regionName) {
+  private void destroyRegion(final String regionName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_REGION);
     csb.addOption(CliStrings.DESTROY_REGION__REGION, regionName);
     executeAndVerifyCommand(csb.getCommandString());
   }
 
-  private void stopServer(String serverName) {
+  private void stopServer(final String serverName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.STOP_SERVER);
     csb.addOption(CliStrings.STOP_SERVER__MEMBER, serverName);
     executeAndVerifyCommand(csb.getCommandString());
   }
 
-  public void createAsyncEventQueue(String queueName) {
+  private void createAsyncEventQueue(final String queueName) throws IOException {
     String queueCommandsJarName = "testEndToEndSC-QueueCommands.jar";
     final File jarFile = new File(queueCommandsJarName);
 
@@ -209,23 +207,22 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
       
       executeAndVerifyCommand(csb.getCommandString());
 
-    } catch (IOException e) {
-      e.printStackTrace();
     } finally {
       FileUtils.deleteQuietly(jarFile);
     }
   }
-  private void createDiskStore(String diskStoreName, 
-      String diskDirs, 
-      String autoCompact, 
-      String allowForceCompaction, 
-      String compactionThreshold, 
-      String duCritical, 
-      String duWarning,
-      String maxOplogSize,
-      String queueSize,
-      String timeInterval,
-      String writeBufferSize) {
+
+  private void createDiskStore(final String diskStoreName,
+                               final String diskDirs,
+                               final String autoCompact,
+                               final String allowForceCompaction,
+                               final String compactionThreshold,
+                               final String duCritical,
+                               final String duWarning,
+                               final String maxOplogSize,
+                               final String queueSize,
+                               final String timeInterval,
+                               final String writeBufferSize) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
     csb.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreName);
     csb.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, diskDirs);
@@ -241,13 +238,14 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.getCommandString());
   }
   
-  private void destroyDiskStore(String diskStoreName, String group) {
+  private void destroyDiskStore(final String diskStoreName, final String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_DISK_STORE);
     csb.addOption(CliStrings.DESTROY_DISK_STORE__NAME, diskStoreName);
     csb.addOptionWithValueCheck(CliStrings.DESTROY_DISK_STORE__GROUP, group);
     executeAndVerifyCommand(csb.toString());
   }
-  public void createIndex(String indexName, String expression, String regionName, String group) {
+
+  private void createIndex(final String indexName, final String expression, final String regionName, final String group) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_INDEX);
     csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
     csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, expression);
@@ -255,57 +253,49 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     executeAndVerifyCommand(csb.getCommandString());
   }
 
-  public void destoyIndex(String indexName, String regionName, String group) {
-    if (StringUtils.isBlank(indexName) && StringUtils.isBlank(regionName) && StringUtils.isBlank(group)) {
+  private void destroyIndex(final String indexName, final String regionName, final String group) {
+    if (isBlank(indexName) && isBlank(regionName) && isBlank(group)) {
       return;
     }
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
-    if (!StringUtils.isBlank(indexName)) {
+    if (!isBlank(indexName)) {
       csb.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
     }
 
-    if (!StringUtils.isBlank(regionName)) {
+    if (!isBlank(regionName)) {
       csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
     }
 
-    if (!StringUtils.isBlank(group)) {
+    if (!isBlank(group)) {
       csb.addOption(CliStrings.DESTROY_INDEX__GROUP, group);
     }
     executeAndVerifyCommand(csb.getCommandString());
   }
 
-  public void createAndDeployJar(String jarName) {
+  private void createAndDeployJar(final String jarName) throws IOException {
     File newDeployableJarFile = new File(jarName);
-    try {
-      this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
-      CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
-      csb.addOption(CliStrings.DEPLOY__JAR, jarName);
-      executeAndVerifyCommand(csb.getCommandString());
-      jarFileNames.add(jarName);
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
+    this.classBuilder.writeJarFromName("ShareConfigClass", newDeployableJarFile);
+    CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
+    csb.addOption(CliStrings.DEPLOY__JAR, jarName);
+    executeAndVerifyCommand(csb.getCommandString());
+    jarFileNames.add(jarName);
   }
 
-  public void deleteSavedJarFiles() {
-    try {
-      FileUtil.deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
-      FileUtil.delete(new File("Deploy1.jar"));
-    } catch (IOException ioe) {
-      ioe.printStackTrace();
-    }
+  private void deleteSavedJarFiles() throws IOException {
+    deleteMatching(new File("."), "^" + JarDeployer.JAR_PREFIX + "Deploy1.*#\\d++$");
+    delete(new File("Deploy1.jar"));
   }
 
-  public Object[] setup() {
+  private Object[] setup() {
     disconnectAllFromDS();
-    final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    final int [] ports = getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
     final String locator1Name = "locator1-" + locator1Port;
-    VM locatorAndMgr = Host.getHost(0).getVM(3);
+    VM locatorAndMgr = getHost(0).getVM(3);
 
     Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
       @Override
-      public Object call() {
+      public Object call() throws IOException {
         int httpPort;
         int jmxPort;
         String jmxHost;
@@ -317,7 +307,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
           jmxHost = "localhost";
         }
 
-        final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+        final int[] ports = getRandomAvailableTCPPorts(2);
 
         jmxPort = ports[0];
         httpPort = ports[1];
@@ -325,34 +315,29 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, locator1Name);
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "config");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
-        locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
-
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null,
-              locatorProps);
-          WaitCriterion wc = new WaitCriterion() {
-            @Override
-            public boolean done() {
-              return locator.isSharedConfigurationRunning();
-            }
-
-            @Override
-            public String description() {
-              return "Waiting for shared configuration to be started";
-            }
-          };
-          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
-        }
+        locatorProps.setProperty(NAME_NAME, locator1Name);
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "config");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_START_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
+        locatorProps.setProperty(JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
+        locatorProps.setProperty(HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
+
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
+        WaitCriterion wc = new WaitCriterion() {
+          @Override
+          public boolean done() {
+            return locator.isSharedConfigurationRunning();
+          }
+
+          @Override
+          public String description() {
+            return "Waiting for shared configuration to be started";
+          }
+        };
+        waitForCriterion(wc, TIMEOUT, INTERVAL, true);
 
         final Object[] result = new Object[4];
         result[0] = locator1Port;
@@ -370,31 +355,26 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
 
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
     // Create a cache in VM 1
-    VM dataMember = Host.getHost(0).getVM(1);
+    VM dataMember = getHost(0).getVM(1);
     dataMember.invoke(new SerializableCallable() {
       @Override
       public Object call() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
-        localProps.setProperty(DistributionConfig.NAME_NAME, "DataMember");
+        localProps.setProperty(MCAST_PORT_NAME, "0");
+        localProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
+        localProps.setProperty(NAME_NAME, "DataMember");
         getSystem(localProps);
         Cache cache = getCache();
         assertNotNull(cache);
-        return CliUtil.getAllNormalMembers(cache);
+        return getAllNormalMembers(cache);
       }
     });
     return result;
   }
 
   private void shutdownAll() throws IOException {
-    VM locatorAndMgr = Host.getHost(0).getVM(3);
+    VM locatorAndMgr = getHost(0).getVM(3);
     locatorAndMgr.invoke(new SerializableCallable() {
-      /**
-       * 
-       */
-      private static final long serialVersionUID = 1L;
-
       @Override
       public Object call() throws Exception {
         GemFireCacheImpl cache = (GemFireCacheImpl)CacheFactory.getAnyInstance();
@@ -403,7 +383,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
       }
     });
 
-    locatorAndMgr.invoke(SharedConfigurationDUnitTest.locatorCleanup);
+    locatorAndMgr.invoke(SharedConfigurationTestUtils.cleanupLocator);
     //Clean up the directories
     if (!serverNames.isEmpty()) {
       for (String serverName : serverNames) {
@@ -416,7 +396,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     serverNames = null;
   }
 
-  private void verifyRegionCreateOnAllMembers(String regionName) {
+  private void verifyRegionCreateOnAllMembers(final String regionName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESCRIBE_REGION);
     csb.addOption(CliStrings.DESCRIBE_REGION__NAME, regionName);
     CommandResult cmdResult = executeCommand(csb.getCommandString());
@@ -427,7 +407,7 @@ public class SharedConfigurationEndToEndDUnitTest extends CliCommandTestBase {
     }
   }     
 
-  private void verifyIndexCreationOnAllMembers(String indexName) {
+  private void verifyIndexCreationOnAllMembers(final String indexName) {
     CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
     CommandResult cmdResult = executeCommand(csb.getCommandString());
     String resultAsString = commandResultToString(cmdResult);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
index 8f190eb..87ab10a 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/SharedConfiguration.java
@@ -83,50 +83,38 @@ import com.gemstone.gemfire.management.internal.configuration.messages.SharedCon
 import com.gemstone.gemfire.management.internal.configuration.utils.XmlUtils;
 import com.gemstone.gemfire.management.internal.configuration.utils.ZipUtils;
 
-/*********
- * 
- *
- */
-@SuppressWarnings("deprecation")
+@SuppressWarnings({ "deprecation", "unchecked" })
 public class SharedConfiguration {
 
   private static final Logger logger = LogService.getLogger();
   
-  static class JarFileFilter implements FilenameFilter {
-    @Override
-    public boolean accept(File dir, String name) {
-      return name.endsWith(".jar");
-    }
-  }
-  /****
+  /**
    * Name of the directory where the shared configuration artifacts are stored
    */
   public static final String CLUSTER_CONFIG_ARTIFACTS_DIR_NAME = "cluster_config";
-  public static final String CLUSTER_CONFIG_DISK_STORE_NAME = "cluster_config";
-  public static String CONFIG_DIR_PATH;//FilenameUtils.concat(System.getProperty("user.dir"), CONFIG_ARTIFACTS_DIR_NAME);
+  private static final String CLUSTER_CONFIG_DISK_STORE_NAME = "cluster_config";
   public static final String CLUSTER_CONFIG_DISK_DIR_PREFIX = "ConfigDiskDir_";
 
   public static final String CLUSTER_CONFIG = "cluster";
 
-
-  /***
+  /**
    * Name of the lock service used for shared configuration
    */
-  public static final String SHARED_CONFIG_LOCK_SERVICE_NAME = "__CLUSTER_CONFIG_LS";
+  private static final String SHARED_CONFIG_LOCK_SERVICE_NAME = "__CLUSTER_CONFIG_LS";
 
-  /***
+  /**
    * Name of the lock for locking the shared configuration
    */
   public static final String SHARED_CONFIG_LOCK_NAME = "__CLUSTER_CONFIG_LOCK";
 
-  /***
+  /**
    * Name of the region which is used to store the configuration information
    */
-  public static final String CONFIG_REGION_NAME = "_ConfigurationRegion";
+  private static final String CONFIG_REGION_NAME = "_ConfigurationRegion";
 
-
-  public String CONFIG_DISK_DIR_NAME;
-  public String CONFIG_DISK_DIR_PATH;;
+  private final String configDirPath;//FilenameUtils.concat(System.getProperty("user.dir"), CONFIG_ARTIFACTS_DIR_NAME);
+  private final String configDiskDirName;
+  private final String configDiskDirPath;;
 
   private final Set<PersistentMemberPattern> newerSharedConfigurationLocatorInfo = new HashSet<PersistentMemberPattern>();
   private final AtomicReference<SharedConfigurationStatus> status = new AtomicReference<SharedConfigurationStatus>();
@@ -136,12 +124,9 @@ public class SharedConfiguration {
   private  GemFireCacheImpl cache;
   private final DistributedLockService sharedConfigLockingService;
 
-
-  /****
+  /**
    * Gets or creates (if not created) shared configuration lock service 
-   * @return DistributedLockService 
    */
-
   public static DistributedLockService getSharedConfigLockService(DistributedSystem ds) {
     DistributedLockService sharedConfigDls = DLockService.getServiceNamed(SHARED_CONFIG_LOCK_SERVICE_NAME);
     try {
@@ -154,19 +139,9 @@ public class SharedConfiguration {
     return sharedConfigDls;
   }
 
-  /**
-   * Returns an array containing the names of the subdirectories in a given directory
-   * @param path Path of the directory whose subdirectories are listed
-   * @return String[] names of first level subdirectories, null if no subdirectories are found or if the path is incorrect
-   */
-  private static String[] getSubdirectories(String path) {
-    File directory = new File(path);
-    return directory.list(DirectoryFileFilter.INSTANCE);
-  }
-
   public SharedConfiguration(Cache cache) throws IOException {
     this.cache = (GemFireCacheImpl)cache;
-    CONFIG_DISK_DIR_NAME = CLUSTER_CONFIG_DISK_DIR_PREFIX + cache.getDistributedSystem().getName();
+    this.configDiskDirName = CLUSTER_CONFIG_DISK_DIR_PREFIX + cache.getDistributedSystem().getName();
     String clusterConfigDir = cache.getDistributedSystem().getProperties().getProperty(DistributionConfig.CLUSTER_CONFIGURATION_DIR);
     if (StringUtils.isBlank(clusterConfigDir)) {
       clusterConfigDir = System.getProperty("user.dir");
@@ -177,17 +152,14 @@ public class SharedConfiguration {
       }
       clusterConfigDir = diskDir.getCanonicalPath();
     }
-    CONFIG_DISK_DIR_PATH = FilenameUtils.concat(clusterConfigDir, CONFIG_DISK_DIR_NAME);
-    CONFIG_DIR_PATH = FilenameUtils.concat(clusterConfigDir, CLUSTER_CONFIG_ARTIFACTS_DIR_NAME);
+    this.configDiskDirPath = FilenameUtils.concat(clusterConfigDir, this.configDiskDirName);
+    configDirPath = FilenameUtils.concat(clusterConfigDir, CLUSTER_CONFIG_ARTIFACTS_DIR_NAME);
     sharedConfigLockingService = getSharedConfigLockService(cache.getDistributedSystem());
     status.set(SharedConfigurationStatus.NOT_STARTED);
   }
 
-  /*****
+  /**
    * Add jar information into the shared configuration and save the jars in the file system
-   * @param jarNames
-   * @param jarBytes
-   * @param groups
    * @return true on success
    */
   public boolean addJars(String []jarNames, byte[][]jarBytes, String[]groups)  {
@@ -198,7 +170,7 @@ public class SharedConfiguration {
       }
       Region<String, Configuration> configRegion = getConfigurationRegion();
       for (String group : groups) {
-        Configuration configuration = (Configuration) configRegion.get(group);
+        Configuration configuration = configRegion.get(group);
 
         if (configuration == null) {
           configuration = new Configuration(group);
@@ -206,7 +178,7 @@ public class SharedConfiguration {
         }
         configuration.addJarNames(jarNames);
         configRegion.put(group, configuration);
-        String groupDir = FilenameUtils.concat(CONFIG_DIR_PATH, group);
+        String groupDir = FilenameUtils.concat(configDirPath, group);
         writeJarFiles(groupDir, jarNames, jarBytes);
       }
     } catch (Exception e) {
@@ -216,12 +188,8 @@ public class SharedConfiguration {
     return success;
   }
 
-
-  /***
+  /**
    * Adds/replaces the xml entity in the shared configuration
-   * @param xmlEntity
-   * @param groups
-   * @throws Exception
    */
   public void addXmlEntity(XmlEntity xmlEntity, String[] groups) throws Exception {
     Region<String, Configuration> configRegion = getConfigurationRegion();
@@ -248,30 +216,6 @@ public class SharedConfiguration {
     }
   }
 
-  /**
-   * Create a {@link Document} using
-   * {@link XmlUtils#createDocumentFromXml(String)} and if the version attribute
-   * is not equal to the current version then update the XML to the current
-   * schema and return the document.
-   * 
-   * @param xmlContent
-   *          XML content to load and upgrade.
-   * @return {@link Document} from xmlContent.
-   * @throws IOException 
-   * @throws ParserConfigurationException 
-   * @throws SAXException 
-   * @throws XPathExpressionException 
-   * @since 8.1
-   */
-  // UnitTest SharedConfigurationJUnitTest.testCreateAndUpgradeDocumentFromXml
-  static Document createAndUpgradeDocumentFromXml(final String xmlContent) throws SAXException, ParserConfigurationException, IOException, XPathExpressionException {
-    Document doc = XmlUtils.createDocumentFromXml(xmlContent);
-    if (!CacheXml.VERSION_LATEST.equals(XmlUtils.getAttribute(doc.getDocumentElement(), CacheXml.VERSION, CacheXml.GEODE_NAMESPACE))) {
-      doc = XmlUtils.upgradeSchema(doc, CacheXml.GEODE_NAMESPACE, CacheXml.LATEST_SCHEMA_LOCATION, CacheXml.VERSION_LATEST);
-    }
-    return doc;
-  }
-
   public void clearSharedConfiguration() throws Exception {
     Region<String, Configuration> configRegion = getConfigurationRegion();
     if (configRegion != null) {
@@ -279,11 +223,9 @@ public class SharedConfiguration {
     }
   }
 
-
-  /*****
+  /**
    * Creates the shared configuration service
    * @param loadSharedConfigFromDir when set to true, loads the configuration from the share_config directory
-   * @throws Exception 
    */
   public void initSharedConfiguration(boolean loadSharedConfigFromDir) throws Exception {
     status.set(SharedConfigurationStatus.STARTED);
@@ -349,23 +291,11 @@ public class SharedConfiguration {
     status.set(SharedConfigurationStatus.RUNNING);
   }
 
-
-  public boolean lockSharedConfiguration() {
-    return sharedConfigLockingService.lock(SHARED_CONFIG_LOCK_NAME, -1, -1);
-  }
-
-  public void unlockSharedConfiguration() {
-    sharedConfigLockingService.unlock(SHARED_CONFIG_LOCK_NAME);
-  }
-
-  /****
+  /**
    * Creates a ConfigurationResponse based on the configRequest, configuration response contains the requested shared configuration
    * This method locks the SharedConfiguration
-   * @param configRequest
-   * @return ConfigurationResponse
-   * @throws Exception 
    */
-  public ConfigurationResponse createConfigurationReponse(ConfigurationRequest configRequest) throws Exception {
+  public ConfigurationResponse createConfigurationReponse(final ConfigurationRequest configRequest) throws Exception {
 
     ConfigurationResponse configResponse = new ConfigurationResponse();
 
@@ -401,7 +331,7 @@ public class SharedConfiguration {
     return configResponse;
   }
 
-  /***
+  /**
    * Create a response containing the status of the Shared configuration and information about other locators containing newer
    * shared configuration data (if at all)
    * @return {@link SharedConfigurationStatusResponse} containing the {@link SharedConfigurationStatus}
@@ -413,13 +343,10 @@ public class SharedConfiguration {
     return response;
   }
 
-  /*****
+  /**
    * Deletes the xml entity from the shared configuration.
-   * @param xmlEntity 
-   * @param groups
-   * @throws Exception
    */
-  public void deleteXmlEntity (XmlEntity xmlEntity, String[] groups) throws Exception {
+  public void deleteXmlEntity(final XmlEntity xmlEntity, String[] groups) throws Exception {
     Region<String, Configuration> configRegion = getConfigurationRegion();
     //No group is specified, so delete in every single group if it exists.
     if (groups == null) {
@@ -441,7 +368,7 @@ public class SharedConfiguration {
     }
   }
 
-  public void modifyCacheAttributes(XmlEntity xmlEntity, String [] groups) throws Exception {
+  public void modifyCacheAttributes(final XmlEntity xmlEntity, String [] groups) throws Exception {
     Region<String, Configuration> configRegion = getConfigurationRegion();
     //No group is specified, so modify the cache attributes for a in every single group if it exists.
     if (groups == null) {
@@ -474,27 +401,26 @@ public class SharedConfiguration {
     }
   }
 
-  /***
-   * Only to be used for clean up in DUnits. 
+  /**
+   * For tests only. TODO: clean this up and remove from production code
+   * <p/>
+   * Throws {@code AssertionError} wrapping any exception thrown by operation.
    */
-  public void destroySharedConfiguration() {
-    Region<String, Configuration> configRegion;
+  public void destroySharedConfiguration_forTestsOnly() {
     try {
-      configRegion = getConfigurationRegion();
+      Region<String, Configuration> configRegion = getConfigurationRegion();
       if (configRegion != null) {
         configRegion.destroyRegion();
       }
       DiskStore configDiskStore = this.cache.findDiskStore(CLUSTER_CONFIG_ARTIFACTS_DIR_NAME);
       if (configDiskStore != null) {
         configDiskStore.destroy();
-        File file = new File(CONFIG_DISK_DIR_PATH);
+        File file = new File(configDiskDirPath);
         FileUtils.deleteDirectory(file);
       }
-      FileUtils.deleteDirectory(new File(CONFIG_DIR_PATH));
-    } catch (IOException e) {
-      e.printStackTrace();
-    } catch (Exception e1) {
-      e1.printStackTrace();
+      FileUtils.deleteDirectory(new File(configDirPath));
+    } catch (Exception exception) {
+      throw new AssertionError(exception);
     }
   }
 
@@ -521,7 +447,7 @@ public class SharedConfiguration {
         if (configuration != null) {
           Set<String> jarNameSet = configuration.getJarNames();
           for (String jarName : jarNameSet) {
-            String groupDirPath = FilenameUtils.concat(CONFIG_DIR_PATH, group);
+            String groupDirPath = FilenameUtils.concat(configDirPath, group);
             if (!jarsAdded.contains(jarName)) {
               String jarFilePath = FilenameUtils.concat(groupDirPath, jarName);
               jarNames[ctr]=jarName;
@@ -531,18 +457,163 @@ public class SharedConfiguration {
           }
         }
       }
+
       jars[0] = jarNames;
       jars[1] = jarBytes;
     }
     return jars;
   }
 
+  public Configuration getConfiguration(String groupName) throws Exception {
+    Configuration configuration = getConfigurationRegion().get(groupName);
+    return configuration;
+  }
+
+  public Map<String, Configuration> getEntireConfiguration() throws Exception {
+    Set<String> keys = getConfigurationRegion().keySet();
+    return getConfigurationRegion().getAll(keys);
+  }
+
+  /**
+   * Returns the path of Shared configuration directory
+   * @return {@link String}  path of the shared configuration directory
+   */
+  public String getSharedConfigurationDirPath() {
+    return configDirPath;
+  }
+
+  /**
+   * Gets the current status of the SharedConfiguration
+   * If the status is started , it determines if the shared configuration is waiting for new configuration on
+   * other locators
+   * @return {@link SharedConfigurationStatus}
+   */
+  public SharedConfigurationStatus getStatus() {
+    SharedConfigurationStatus scStatus = this.status.get();
+    if (scStatus == SharedConfigurationStatus.STARTED) {
+      PersistentMemberManager pmm = cache.getPersistentMemberManager();
+      Map<String, Set<PersistentMemberID>> waitingRegions = pmm.getWaitingRegions();
+      if (!waitingRegions.isEmpty()) {
+        this.status.compareAndSet(SharedConfigurationStatus.STARTED, SharedConfigurationStatus.WAITING);
+        Set<PersistentMemberID> persMemIds =  waitingRegions.get(Region.SEPARATOR_CHAR + CONFIG_REGION_NAME);
+        for (PersistentMemberID persMemId : persMemIds) {
+          newerSharedConfigurationLocatorInfo.add(new PersistentMemberPattern(persMemId));
+        }
+      }
+    }
+    return this.status.get();
+  }
+
+  /**
+   * Loads the
+   * @throws Exception
+   */
+  public void loadSharedConfigurationFromDisk() throws Exception {
+    Map<String, Configuration> sharedConfigurationMap = readSharedConfigurationFromDisk();
+    getConfigurationRegion().clear();
+    getConfigurationRegion().putAll(sharedConfigurationMap);
+  }
+
+  public void modifyProperties(final Properties properties, String[] groups) throws Exception {
+    if (groups == null) {
+      groups = new String[] {SharedConfiguration.CLUSTER_CONFIG};
+    }
+    Region<String, Configuration> configRegion = getConfigurationRegion();
+    for (String group : groups) {
+      Configuration configuration = configRegion.get(group);
+      if (configuration == null) {
+        configuration = new Configuration(group);
+      }
+      configuration.getGemfireProperties().putAll(properties);
+      configRegion.put(group, configuration);
+      writeConfig(configuration);
+    }
+  }
+
+  /**
+   * Removes the jar files from the shared configuration.
+   * @param jarNames Names of the jar files.
+   * @param groups Names of the groups which had the jar file deployed.
+   * @return true on success.
+   */
+  public boolean removeJars(final String[] jarNames, String[] groups){
+    boolean success = true;
+    try {
+      Region<String, Configuration> configRegion = getConfigurationRegion();
+      if (groups == null) {
+        Set<String> groupSet = configRegion.keySet();
+        groups = groupSet.toArray(new String[groupSet.size()]);
+      }
+      for (String group : groups) {
+        Configuration configuration = (Configuration) configRegion.get(group);
+        if (configuration != null) {
+          String dirPath = FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
+          removeJarFiles(dirPath, jarNames);
+        }
+      }
+      for (String group : groups) {
+        Configuration configuration = (Configuration) configRegion.get(group);
+        if (configuration != null) {
+          if (!configuration.getJarNames().isEmpty()) {
+            configuration.removeJarNames(jarNames);
+            configRegion.put(group, configuration);
+          }
+        }
+      }
+    } catch (Exception e) {
+      logger.info("Exception occurred while deleting the jar files", e);
+      success = false;
+    }
+    return success;
+  }
+
+  public void renameExistingSharedConfigDirectory() {
+    File configDirFile = new File(configDirPath);
+    if (configDirFile.exists()) {
+      String configDirFileName2 = CLUSTER_CONFIG_ARTIFACTS_DIR_NAME + new SimpleDateFormat("yyyyMMddhhmm").format(new Date()) + "." + System.nanoTime();
+      File configDirFile2 = new File(FilenameUtils.concat(configDirFileName2, configDirFileName2));
+      try {
+        FileUtils.moveDirectoryToDirectory(configDirFile, configDirFile2, true);
+      } catch (IOException e) {
+        logger.info(e);
+      }
+    }
+  }
+
+  /**
+   * Writes the contents of the {@link Configuration} to the file system
+   */
+  public void writeConfig(final Configuration configuration) throws Exception {
+    File configDir = new File(getSharedConfigurationDirPath());
+    if (!configDir.exists()) {
+      if (!configDir.mkdirs()) {
+        throw new IOException("Cannot create directory : " + getSharedConfigurationDirPath());
+      }
+    }
+    String dirPath = FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
+    File file = new File(dirPath);
+    if (!file.exists()) {
+      if (!file.mkdir()) {
+        throw new IOException("Cannot create directory : " + dirPath);
+      }
+    }
+
+    writeProperties(dirPath, configuration);
+    writeCacheXml(dirPath, configuration);
+  }
+
+  private boolean lockSharedConfiguration() {
+    return sharedConfigLockingService.lock(SHARED_CONFIG_LOCK_NAME, -1, -1);
+  }
+
+  private void unlockSharedConfiguration() {
+    sharedConfigLockingService.unlock(SHARED_CONFIG_LOCK_NAME);
+  }
 
-  /***
+  /**
    * Gets the Jar from existing locators in the system
-   * @throws Exception 
    */
-  public void getAllJarsFromOtherLocators() throws Exception {
+  private void getAllJarsFromOtherLocators() throws Exception {
     logger.info("Getting Jar files from other locators");
     DM dm = cache.getDistributionManager();
     DistributedMember me = cache.getMyId();
@@ -555,7 +626,6 @@ public class SharedConfiguration {
       logger.info("No other locators present");
       return;
     }
-    @SuppressWarnings("unchecked")
     ResultCollector<?, List<Object>> rc = (ResultCollector<?, List<Object>>) CliUtil.executeFunction(getAllJarsFunction, null , locators);
 
     List<Object> results = rc.getResult();
@@ -584,7 +654,7 @@ public class SharedConfiguration {
       for (String group : groups) {
         Configuration config = entireConfiguration.get(group);
         Set<String> groupJarNames = config.getJarNames();
-        String groupDirPath = FilenameUtils.concat(CONFIG_DIR_PATH, group);
+        String groupDirPath = FilenameUtils.concat(configDirPath, group);
 
         for (String groupJarName : groupJarNames) {
           Integer index = jarIndex.get(groupJarName);
@@ -609,29 +679,22 @@ public class SharedConfiguration {
     }
   }
 
-  public Configuration getConfiguration(String groupName) throws Exception {
-    Configuration configuration = (Configuration)getConfigurationRegion().get(groupName);
-    return configuration;
-  }
-
-  /*****
+  /**
    * Gets the region containing the shared configuration data.
    * The region is created , if it does not exist already.
    * Note : this could block if this locator contains stale persistent configuration data.
-   * @return  {@link Region} ConfigurationRegion
-   * @throws Exception 
+   * @return {@link Region} ConfigurationRegion
    */
   private Region<String, Configuration> getConfigurationRegion() throws Exception {
-    @SuppressWarnings("unchecked")
     Region<String, Configuration> configRegion = cache.getRegion(CONFIG_REGION_NAME);
 
     try {
       if (configRegion == null) {
-        File diskDir = new File(CONFIG_DISK_DIR_PATH);
+        File diskDir = new File(configDiskDirPath);
 
         if (!diskDir.exists()) {
           if (!diskDir.mkdirs()) {
-            throw new IOException("Cannot create directory at " + CONFIG_DISK_DIR_PATH);
+            throw new IOException("Cannot create directory at " + configDiskDirPath);
           }
         }
 
@@ -653,83 +716,24 @@ public class SharedConfiguration {
 
         configRegion = cache.createVMRegion(CONFIG_REGION_NAME, regionAttrsFactory.create(), internalArgs);
       }
+
     } catch (CancelException e) {
       if (configRegion == null) {
         this.status.set(SharedConfigurationStatus.STOPPED);
       }
       throw e; // CONFIG: don't rethrow as Exception, keep it a subclass of CancelException
+
     } catch (Exception e) {
       if (configRegion == null) {
         this.status.set(SharedConfigurationStatus.STOPPED);
       }
       throw new Exception("Error occurred while initializing cluster configuration", e);
     }
-    return configRegion;
-  }
 
-  public Map<String, Configuration> getEntireConfiguration() throws Exception {
-    Set<String> keys = getConfigurationRegion().keySet();
-    return getConfigurationRegion().getAll(keys);
-  }
-
-
-  /****
-   * Returns the path of Shared configuration directory
-   * @return {@link String}  path of the shared configuration directory
-   */
-  public String getSharedConfigurationDirPath() {
-    return CONFIG_DIR_PATH;
-  }
-
-
-  /*****
-   * Gets the current status of the SharedConfiguration
-   * If the status is started , it determines if the shared configuration is waiting for new configuration on 
-   * other locators
-   * @return {@link SharedConfigurationStatus}
-   */
-  public SharedConfigurationStatus getStatus() {
-    SharedConfigurationStatus scStatus = this.status.get();
-    if (scStatus == SharedConfigurationStatus.STARTED) {
-      PersistentMemberManager pmm = cache.getPersistentMemberManager();
-      Map<String, Set<PersistentMemberID>> waitingRegions = pmm.getWaitingRegions();
-      if (!waitingRegions.isEmpty()) {
-        this.status.compareAndSet(SharedConfigurationStatus.STARTED, SharedConfigurationStatus.WAITING);
-        Set<PersistentMemberID> persMemIds =  waitingRegions.get(Region.SEPARATOR_CHAR + CONFIG_REGION_NAME);
-        for (PersistentMemberID persMemId : persMemIds) {
-          newerSharedConfigurationLocatorInfo.add(new PersistentMemberPattern(persMemId));
-        }
-      }
-    }
-    return this.status.get();
-  }
-  /****
-   * Loads the 
-   * @throws Exception 
-   */
-  public void loadSharedConfigurationFromDisk() throws Exception {
-    Map<String, Configuration> sharedConfigurationMap = readSharedConfigurationFromDisk();
-    getConfigurationRegion().clear();
-    getConfigurationRegion().putAll(sharedConfigurationMap);
-  }
-
-  public void modifyProperties(Properties properties, String[] groups) throws Exception {
-    if (groups == null) {
-      groups = new String[] {SharedConfiguration.CLUSTER_CONFIG};
-    }
-    Region<String, Configuration> configRegion = getConfigurationRegion();
-    for (String group : groups) {
-      Configuration configuration = (Configuration) configRegion.get(group);
-      if (configuration == null) {
-        configuration = new Configuration(group);
-      } 
-      configuration.getGemfireProperties().putAll(properties);
-      configRegion.put(group, configuration);
-      writeConfig(configuration);
-    }
+    return configRegion;
   }
 
-  /*****
+  /**
    * Reads the configuration information from the shared configuration directory and returns a {@link Configuration} object
    * @param configName
    * @param configDirectory
@@ -739,7 +743,7 @@ public class SharedConfiguration {
    * @throws ParserConfigurationException 
    * @throws SAXException 
    */
-  private Configuration readConfiguration(String configName, String configDirectory) throws SAXException, ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
+  private Configuration readConfiguration(final String configName, final String configDirectory) throws SAXException, ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
     Configuration configuration = new Configuration(configName);
     String cacheXmlFullPath = FilenameUtils.concat(configDirectory, configuration.getCacheXmlFileName());
     String propertiesFullPath = FilenameUtils.concat(configDirectory, configuration.getPropertiesFileName());
@@ -760,14 +764,13 @@ public class SharedConfiguration {
     return configuration;
   }
 
-  /*****
+  /**
    * Reads the properties from the properties file.
    * @param propertiesFilePath
    * @return {@link Properties}
    * @throws IOException
    */
-  public Properties readProperties(String propertiesFilePath) throws IOException{
-
+  private Properties readProperties(final String propertiesFilePath) throws IOException {
     Properties properties = new Properties();
     File propsFile = new File(propertiesFilePath);
     FileInputStream fis = null;
@@ -784,9 +787,8 @@ public class SharedConfiguration {
     return properties;
   }
 
-
-  /****
-   * Reads the "shared_config" directory and loads all the cache.xml , gemfire.properties and deployd jars information
+  /**
+   * Reads the "shared_config" directory and loads all the cache.xml, gemfire.properties and deployed jars information
    * @return {@link Map} 
    * @throws TransformerException 
    * @throws TransformerFactoryConfigurationError 
@@ -794,12 +796,12 @@ public class SharedConfiguration {
    * @throws SAXException 
    */
   private Map<String, Configuration> readSharedConfigurationFromDisk() throws SAXException, ParserConfigurationException, TransformerFactoryConfigurationError, TransformerException {
-    String []subdirectoryNames = getSubdirectories(CONFIG_DIR_PATH);
+    String[] subdirectoryNames = getSubdirectories(configDirPath);
     Map<String, Configuration> sharedConfiguration = new HashMap<String, Configuration>();
 
     if (subdirectoryNames != null) {
       for (String subdirectoryName : subdirectoryNames) {
-        String fullpath = FilenameUtils.concat(CONFIG_DIR_PATH, subdirectoryName);
+        String fullpath = FilenameUtils.concat(configDirPath, subdirectoryName);
         Configuration configuration = readConfiguration(subdirectoryName, fullpath);
         sharedConfiguration.put(subdirectoryName, configuration);
       }
@@ -807,16 +809,13 @@ public class SharedConfiguration {
     return sharedConfiguration;
   }
 
-
-
-  /****
+  /**
    * Removes the jar files from the given directory     
    * @param dirPath Path of the configuration directory
    * @param jarNames Names of the jar files
    * @throws IOException
    */
-
-  public void removeJarFiles (String dirPath, String[] jarNames) throws IOException {
+  private void removeJarFiles(final String dirPath, final String[] jarNames) throws IOException {
     if (jarNames != null) {
       for (int i=0; i<jarNames.length; i++) {
         File jarFile = new File(FilenameUtils.concat(dirPath, jarNames[i]));
@@ -838,96 +837,21 @@ public class SharedConfiguration {
     }
   }
 
-  /****
-   * Removes the jar files from the shared configuration. 
-   * @param jarNames Names of the jar files.
-   * @param groups Names of the groups which had the jar file deployed.
-   * @return true on success.
-   */
-  public boolean removeJars(String []jarNames, String[] groups){
-    boolean success = true;
-    try {
-      Region<String, Configuration> configRegion = getConfigurationRegion();
-      if (groups == null) {
-        Set<String> groupSet = configRegion.keySet();
-        groups = groupSet.toArray(new String[groupSet.size()]);
-      }
-      for (String group : groups) {
-        Configuration configuration = (Configuration) configRegion.get(group);
-        if (configuration != null) {
-          String dirPath = FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
-          removeJarFiles(dirPath, jarNames);
-        }
-      }
-      for (String group : groups) {
-        Configuration configuration = (Configuration) configRegion.get(group);
-        if (configuration != null) {
-          if (!configuration.getJarNames().isEmpty()) {
-            configuration.removeJarNames(jarNames);
-            configRegion.put(group, configuration);
-          }
-        } 
-      }
-    } catch (Exception e) {
-      logger.info("Exception occurred while deleting the jar files", e);
-      success = false;
-    }
-    return success;
-  }
-
-  public void renameExistingSharedConfigDirectory() {
-    File configDirFile = new File(CONFIG_DIR_PATH);
-    if (configDirFile.exists()) {
-      String configDirFileName2 = CLUSTER_CONFIG_ARTIFACTS_DIR_NAME + new SimpleDateFormat("yyyyMMddhhmm").format(new Date()) + "." + System.nanoTime(); 
-      File configDirFile2 = new File(FilenameUtils.concat(configDirFileName2, configDirFileName2));
-      try {
-        FileUtils.moveDirectoryToDirectory(configDirFile, configDirFile2, true);
-      } catch (IOException e) {
-        logger.info(e);
-      }
-    } 
-  }
-  /***
+  /**
    * Writes the cache.xml to the file , based on Configuration
-   * @param dirPath Path of the directory in which the configuration is written
-   * @param configuration 
-   * @throws IOException 
    */
-  private void writeCacheXml(String dirPath, Configuration configuration) throws IOException {
+  private void writeCacheXml(final String dirPath, final Configuration configuration) throws IOException {
     String fullPath = FilenameUtils.concat(dirPath,configuration.getCacheXmlFileName());
     FileUtils.writeStringToFile(new File(fullPath), configuration.getCacheXmlContent(), "UTF-8") ;
   }
-  /***
-   * Writes the contents of the {@link Configuration} to the file system
-   * @param configuration
-   * @throws Exception
-   */
-  public void writeConfig(Configuration configuration) throws Exception {
-    File configDir = new File(getSharedConfigurationDirPath());
-    if (!configDir.exists()) {
-      if (!configDir.mkdirs()) {
-        throw new IOException("Cannot create directory : " + getSharedConfigurationDirPath());
-      }
-    }
-    String dirPath = FilenameUtils.concat(getSharedConfigurationDirPath(), configuration.getConfigName());
-    File file = new File(dirPath);
-    if (!file.exists()) {
-      if (!file.mkdir()) {
-        throw new IOException("Cannot create directory : " + dirPath);
-      }
-    }
-
-    writeProperties(dirPath, configuration);
-    writeCacheXml(dirPath, configuration);
-  }
 
-  /*****
+  /**
    * Writes the 
    * @param dirPath target directory , where the jar files are to be written
    * @param jarNames Array containing the name of the jar files.
    * @param jarBytes Array of byte arrays for the jar files.
    */
-  private void writeJarFiles(String dirPath , String[] jarNames, byte[][] jarBytes) {
+  private void writeJarFiles(final String dirPath, final String[] jarNames, final byte[][] jarBytes) {
     for (int i=0; i<jarNames.length; i++) {
       String filePath = FilenameUtils.concat(dirPath, jarNames[i]);
       File jarFile = new File(filePath);
@@ -939,17 +863,49 @@ public class SharedConfiguration {
     }
   }
 
-  /****
+  /**
    * Writes the properties to the file based on the {@link Configuration}
-   * @param dirPath
-   * @param configuration
-   * @throws IOException
    */
-  private void writeProperties(String dirPath, Configuration configuration) throws IOException {
+  private void writeProperties(final String dirPath, final Configuration configuration) throws IOException {
     String fullPath = FilenameUtils.concat(dirPath,configuration.getPropertiesFileName());
     BufferedWriter bw = new BufferedWriter(new FileWriter(fullPath));
     configuration.getGemfireProperties().store(bw, "");
     bw.close();
   }
 
+  /**
+   * Create a {@link Document} using
+   * {@link XmlUtils#createDocumentFromXml(String)} and if the version attribute
+   * is not equal to the current version then update the XML to the current
+   * schema and return the document.
+   *
+   * @param xmlContent XML content to load and upgrade.
+   * @return {@link Document} from xmlContent.
+   * @since 8.1
+   */
+  // UnitTest SharedConfigurationJUnitTest.testCreateAndUpgradeDocumentFromXml
+  static Document createAndUpgradeDocumentFromXml(final String xmlContent) throws SAXException, ParserConfigurationException, IOException, XPathExpressionException {
+    Document doc = XmlUtils.createDocumentFromXml(xmlContent);
+    if (!CacheXml.VERSION_LATEST.equals(XmlUtils.getAttribute(doc.getDocumentElement(), CacheXml.VERSION, CacheXml.GEODE_NAMESPACE))) {
+      doc = XmlUtils.upgradeSchema(doc, CacheXml.GEODE_NAMESPACE, CacheXml.LATEST_SCHEMA_LOCATION, CacheXml.VERSION_LATEST);
+    }
+    return doc;
+  }
+
+  /**
+   * Returns an array containing the names of the subdirectories in a given directory
+   * @param path Path of the directory whose subdirectories are listed
+   * @return String[] names of first level subdirectories, null if no subdirectories are found or if the path is incorrect
+   */
+  private static String[] getSubdirectories(String path) {
+    File directory = new File(path);
+    return directory.list(DirectoryFileFilter.INSTANCE);
+  }
+
+  private static class JarFileFilter implements FilenameFilter {
+    @Override
+    public boolean accept(File dir, String name) {
+      return name.endsWith(".jar");
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/main/resources/log4j2.xml b/geode-core/src/main/resources/log4j2.xml
index b300dc8..670c0f1 100755
--- a/geode-core/src/main/resources/log4j2.xml
+++ b/geode-core/src/main/resources/log4j2.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="TRACE" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
   <Properties>
     <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} &lt;%thread&gt; tid=%tid] %message%n%throwable%n</Property>
     <Property name="gemfire-default">true</Property>

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
deleted file mode 100755
index 745090d..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
+++ /dev/null
@@ -1,71 +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 com.gemstone.gemfire.distributed;
-
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests for AbstractLauncher class. These tests require file system I/O.
- */
-@Category(IntegrationTest.class)
-public class AbstractLauncherIntegrationJUnitTest {
-
-  @Rule
-  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  private File gemfirePropertiesFile;
-  private Properties expectedGemfireProperties;
-  
-  @Before
-  public void setUp() throws Exception {
-    this.gemfirePropertiesFile = this.temporaryFolder.newFile("gemfire.properties");
-    
-    this.expectedGemfireProperties = new Properties();
-    this.expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
-    this.expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
-    this.expectedGemfireProperties.store(new FileWriter(this.gemfirePropertiesFile, false), this.testName.getMethodName());
-
-    assertThat(this.gemfirePropertiesFile).isNotNull();
-    assertThat(this.gemfirePropertiesFile.exists()).isTrue();
-    assertThat(this.gemfirePropertiesFile.isFile()).isTrue();
-  }
-  
-  @Test
-  public void testLoadGemFirePropertiesFromFile() throws Exception {
-    final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(this.gemfirePropertiesFile.toURI().toURL());
-
-    assertThat(actualGemFireProperties).isNotNull();
-    assertThat(actualGemFireProperties).isEqualTo(this.expectedGemfireProperties);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTest.java
new file mode 100755
index 0000000..5af8faa
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for AbstractLauncher class. These tests require file system I/O.
+ */
+@Category(IntegrationTest.class)
+public class AbstractLauncherIntegrationTest {
+
+  @Rule
+  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+  
+  @Rule
+  public final TestName testName = new TestName();
+  
+  private File gemfirePropertiesFile;
+  private Properties expectedGemfireProperties;
+  
+  @Before
+  public void setUp() throws Exception {
+    this.gemfirePropertiesFile = this.temporaryFolder.newFile("gemfire.properties");
+    
+    this.expectedGemfireProperties = new Properties();
+    this.expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
+    this.expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
+    this.expectedGemfireProperties.store(new FileWriter(this.gemfirePropertiesFile, false), this.testName.getMethodName());
+
+    assertThat(this.gemfirePropertiesFile).isNotNull();
+    assertThat(this.gemfirePropertiesFile.exists()).isTrue();
+    assertThat(this.gemfirePropertiesFile.isFile()).isTrue();
+  }
+  
+  @Test
+  public void testLoadGemFirePropertiesFromFile() throws Exception {
+    final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(this.gemfirePropertiesFile.toURI().toURL());
+
+    assertThat(actualGemFireProperties).isNotNull();
+    assertThat(actualGemFireProperties).isEqualTo(this.expectedGemfireProperties);
+  }
+}


[03/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteJUnitTest.java
deleted file mode 100755
index 056e6ce..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteJUnitTest.java
+++ /dev/null
@@ -1,1430 +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 com.gemstone.gemfire.distributed;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
-import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
-import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.internal.process.PidUnavailableException;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessStreamReader;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import com.gemstone.gemfire.test.process.ProcessWrapper;
-
-/**
- * Integration tests for launching a Server in a forked process.
- *
- * @see com.gemstone.gemfire.distributed.AbstractLauncher
- * @see com.gemstone.gemfire.distributed.ServerLauncher
- * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
- * @see com.gemstone.gemfire.distributed.ServerLauncher.ServerState
- * @see com.gemstone.gemfire.internal.AvailablePortHelper
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherRemoteJUnitTest extends AbstractServerLauncherJUnitTestCase {
-  
-  protected volatile Process process;
-  protected volatile ProcessStreamReader processOutReader;
-  protected volatile ProcessStreamReader processErrReader;
-  
-  @Before
-  public final void setUpServerLauncherRemoteTest() throws Exception {
-  }
-
-  @After
-  public final void tearDownServerLauncherRemoteTest() throws Exception {    
-    if (this.process != null) {
-      this.process.destroy();
-      this.process = null;
-    }
-    if (this.processOutReader != null && this.processOutReader.isRunning()) {
-      this.processOutReader.stop();
-    }
-    if (this.processErrReader != null && this.processErrReader.isRunning()) {
-      this.processErrReader.stop();
-    }
-  }
-
-  protected Status getExpectedStopStatusForNotRunning() {
-    return Status.NOT_RESPONDING;
-  }
-  
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertTrue(factory.isAttachAPIFound());
-  }
-  
-  @Test
-  @Ignore("TRAC bug #52304: test is broken and needs to be reworked")
-  public void testRunningServerOutlivesForkingProcess() throws Throwable {
-    // launch ServerLauncherForkingProcess which then launches server
-    
-//    final List<String> command = new ArrayList<String>();
-//    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-//    command.add("-cp");
-//    command.add(System.getProperty("java.class.path"));
-//    command.add(ServerLauncherDUnitTest.class.getName().concat("$").concat(ServerLauncherForkingProcess.class.getSimpleName()));
-//
-//    process = new ProcessBuilder(command).directory(temporaryFolder.getRoot()).start();
-//    assertNotNull(process);
-//    processOutReader = new ProcessStreamReader(process.getInputStream(), createListener("sysout", getUniqueName() + "#sysout")).start();
-//    processErrReader = new ProcessStreamReader(process.getErrorStream(), createListener("syserr", getUniqueName() + "#syserr")).start();
-
-    @SuppressWarnings("unused")
-    File file = new File(this.temporaryFolder.getRoot(), ServerLauncherForkingProcess.class.getSimpleName().concat(".log"));
-    //-logger.info("log file is " + file);
-    
-    final ProcessWrapper pw = new ProcessWrapper.Builder().mainClass(ServerLauncherForkingProcess.class).build();
-    pw.execute(null, this.temporaryFolder.getRoot()).waitFor(true);
-    //logger.info("[testRunningServerOutlivesForkingProcess] ServerLauncherForkingProcess output is:\n\n"+pw.getOutput());
-    
-//    // create waiting thread since waitFor does not have a timeout 
-//    Thread waiting = new Thread(new Runnable() {
-//      @Override
-//      public void run() {
-//        try {
-//          assertEquals(0, process.waitFor());
-//        } catch (InterruptedException e) {
-//          logger.error("Interrupted while waiting for process", e);
-//        }
-//      }
-//    });
-
-//    // start waiting thread and join to it for timeout
-//    try {
-//      waiting.start();
-//      waiting.join(TIMEOUT_MILLISECONDS);
-//      assertFalse("ServerLauncherForkingProcess took too long and caused timeout", waiting.isAlive());
-//      
-//    } catch (Throwable e) {
-//      logger.error(e);
-//      if (failure == null) {
-//        failure = e;
-//      }
-//    } finally {
-//      if (waiting.isAlive()) {
-//        waiting.interrupt();
-//      }
-//    }
-
-    // wait for server to start
-    int pid = 0;
-    final String serverName = ServerLauncherForkingProcess.class.getSimpleName()+"_server";
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = serverName+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-      // validate the status
-      final ServerState actualStatus = dirLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
-      assertEquals(getJvmArguments(), actualStatus.getJvmArguments());
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + serverName + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(serverName, actualStatus.getMemberName());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartCreatesPidFile() throws Throwable {
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-    
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-      // check the status
-      final ServerState serverState = this.launcher.status();
-      assertNotNull(serverState);
-      assertEquals(Status.ONLINE, serverState.getStatus());
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartDeletesStaleControlFiles() throws Throwable {
-    // create existing control files
-    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStopRequestFileName());
-    this.stopRequestFile.createNewFile();
-    assertTrue(this.stopRequestFile.exists());
-
-    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusRequestFileName());
-    this.statusRequestFile.createNewFile();
-    assertTrue(this.statusRequestFile.exists());
-
-    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusFileName());
-    this.statusFile.createNewFile();
-    assertTrue(this.statusFile.exists());
-    
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate stale control files were deleted
-      waitForFileToDelete(this.stopRequestFile);
-      waitForFileToDelete(this.statusRequestFile);
-      waitForFileToDelete(this.statusFile);
-      
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-721: random ports (setup overriding default port), TemporaryFolder
-  @Test
-  public void testStartOverwritesStalePidFile() throws Throwable {
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    writePid(this.pidFile, Integer.MAX_VALUE);
-
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertFalse(pid == Integer.MAX_VALUE);
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  /**
-   * Confirms fix for #47778.
-   */
-  @Test
-  public void testStartUsingDisableDefaultServerLeavesPortFree() throws Throwable {
-    assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // verify server did not a port
-      assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-      
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      assertEquals("Port should be \"\" instead of " + portString, "", portString);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartUsingDisableDefaultServerSkipsPortCheck() throws Throwable {
-    // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
-    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      assertEquals("Port should be \"\" instead of " + portString, "", portString);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // verify port is still in use
-    this.errorCollector.checkThat(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET), is(equalTo(false)));
-  }
-
-  @Category(FlakyTest.class) // GEODE-764: random ports, BindException, forks JVM, uses ErrorCollector
-  @Test
-  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    final int otherPid = getPid();
-    assertTrue("Pid " + otherPid + " should be alive", ProcessUtils.isProcessAlive(otherPid));
-    writePid(this.pidFile, otherPid);
-
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-    command.add("--force");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertTrue(pid != otherPid);
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  /**
-   * Confirms fix for #47665.
-   */
-  @Test
-  public void testStartUsingServerPortInUseFails() throws Throwable {
-    // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
-    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    command.add("--server-port=" + this.serverPort);
-
-    String expectedString = "java.net.BindException";
-    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-
-    // wait for server to start and fail
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      int code = this.process.waitFor();
-      assertEquals("Expected exit code 1 but was " + code, 1, code);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      // check the status
-      final ServerState serverState = dirLauncher.status();
-      assertNotNull(serverState);
-      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
-      
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // if the following fails, then the SHORTER_TIMEOUT is too short for slow machines
-    // or this test needs to use MainLauncher in ProcessWrapper
-    
-    // validate that output contained BindException 
-    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
-
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = dirLauncher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  /**
-   * Confirms part of fix for #47664
-   */
-  @Test
-  public void testStartUsingServerPortOverridesCacheXml() throws Throwable {
-    // generate two free ports
-    final int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
-    
-    // write out cache.xml with one port
-    final CacheCreation creation = new CacheCreation();
-    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
-    attrs.setScope(Scope.DISTRIBUTED_ACK);
-    attrs.setDataPolicy(DataPolicy.REPLICATE);
-    creation.createRegion(getUniqueName(), attrs);
-    creation.addCacheServer().setPort(freeTCPPorts[0]);
-    
-    File cacheXmlFile = new File(this.temporaryFolder.getRoot(), getUniqueName()+".xml");
-    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
-    CacheXmlGenerator.generate(creation, pw);
-    pw.close();
-    
-    // launch server and specify a different port
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-Dgemfire."+DistributionConfig.CACHE_XML_FILE_NAME+"="+cacheXmlFile.getCanonicalPath());
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    command.add("--server-port=" + freeTCPPorts[1]);
-
-    String expectedString = "java.net.BindException";
-    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-    
-    // wait for server to start up
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // verify server used --server-port instead of default or port in cache.xml
-      assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
-      assertFalse(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
-      
-      ServerState status = this.launcher.status();
-      String portString = status.getPort();
-      int port = Integer.valueOf(portString);
-      assertEquals("Port should be " + freeTCPPorts[1] + " instead of " + port, freeTCPPorts[1], port);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-      waitForFileToDelete(this.pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  /**
-   * Confirms part of fix for #47664
-   */
-  @Test
-  public void testStartUsingServerPortUsedInsteadOfDefaultCacheXml() throws Throwable {
-    // write out cache.xml with one port
-    final CacheCreation creation = new CacheCreation();
-    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
-    attrs.setScope(Scope.DISTRIBUTED_ACK);
-    attrs.setDataPolicy(DataPolicy.REPLICATE);
-    creation.createRegion(getUniqueName(), attrs);
-    creation.addCacheServer();
-    
-    File cacheXmlFile = new File(this.temporaryFolder.getRoot(), getUniqueName()+".xml");
-    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
-    CacheXmlGenerator.generate(creation, pw);
-    pw.close();
-  
-    // launch server and specify a different port
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-Dgemfire."+DistributionConfig.CACHE_XML_FILE_NAME+"="+cacheXmlFile.getCanonicalPath());
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    command.add("--server-port=" + this.serverPort);
-
-    final String expectedString = "java.net.BindException";
-    final AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-    
-    // wait for server to start up
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-  
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // verify server used --server-port instead of default or port in cache.xml
-      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-      
-      final ServerState status = this.launcher.status();
-      final String portString = status.getPort();
-      int port = Integer.valueOf(portString);
-      assertEquals("Port should be " + this.serverPort + " instead of " + port, this.serverPort, port);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-1135: random ports, BindException, fork JVM
-  @Test
-  public void testStartWithDefaultPortInUseFails() throws Throwable {
-    String expectedString = "java.net.BindException";
-    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-
-    // make serverPort in use
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
-    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
-    
-    // launch server
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-    
-    // wait for server to start up
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      int code = this.process.waitFor();
-      assertEquals("Expected exit code 1 but was " + code, 1, code);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      // check the status
-      final ServerState serverState = dirLauncher.status();
-      assertNotNull(serverState);
-      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
-      
-      // creation of log file seems to be random -- look into why sometime
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // if the following fails, then the SHORTER_TIMEOUT might be too short for slow machines
-    // or this test needs to use MainLauncher in ProcessWrapper
-    
-    // validate that output contained BindException 
-    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
-
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = dirLauncher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartWithExistingPidFileFails() throws Throwable {
-  }/*
-    this.temporaryFolder.getRoot() = new File(getUniqueName());
-    this.temporaryFolder.getRoot().mkdir();
-    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
-
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
-    writePid(this.pidFile, realPid);
-    
-    // build and start the server
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-    
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart(dirLauncher, 10*1000, false);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-      
-    try {
-      // check the status
-      final ServerState serverState = dirLauncher.status();
-      assertNotNull(serverState);
-      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
-      
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    // just in case the launcher started...
-    ServerState status = null;
-    try {
-      status = dirLauncher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    try {
-      final Status theStatus = status.getStatus();
-      assertFalse(theStatus == Status.STARTING);
-      assertFalse(theStatus == Status.ONLINE);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartWithExistingPidFileFails
-  */
-
-  @Category(FlakyTest.class) // GEODE-957: random ports, BindException, fork JVM
-  @Test
-  public void testStatusUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    ServerLauncher pidLauncher = null; 
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // validate the status
-      final ServerState actualStatus = pidLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
-      assertEquals(jvmArguments, actualStatus.getJvmArguments());
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      if (pidLauncher == null) {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      } else {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-      }          
-      waitForPidToStop(pid);
-      waitForFileToDelete(this.pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStatusUsingWorkingDirectory() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      assertNotNull(this.launcher);
-      assertFalse(this.launcher.isRunning());
-
-      // validate the status
-      final ServerState actualStatus = this.launcher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
-      assertEquals(jvmArguments, actualStatus.getJvmArguments());
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStatusWithEmptyPidFile() throws Exception {
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile());
-    
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    final ServerState actualStatus = dirLauncher.status();
-    assertThat(actualStatus, is(notNullValue()));
-    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
-    assertThat(actualStatus.getPid(), is(nullValue()));
-    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
-    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
-    assertThat(actualStatus.getClasspath(), is(nullValue()));
-    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
-    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
-    assertThat(actualStatus.getLogFile(), is(nullValue()));
-    assertThat(actualStatus.getHost(), is(nullValue()));
-    assertThat(actualStatus.getMemberName(), is(nullValue()));
-  }
-  
-  @Test
-  public void testStatusWithNoPidFile() throws Exception {
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    ServerState serverState = dirLauncher.status();
-    assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
-  }
-  
-  @Test
-  public void testStatusWithStalePidFile() throws Exception {
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-    final int pid = 0;
-    assertFalse(ProcessUtils.isProcessAlive(pid));
-    writePid(this.pidFile, pid);
-    
-    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-        .setWorkingDirectory(temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    final ServerState actualStatus = dirLauncher.status();
-    assertThat(actualStatus, is(notNullValue()));
-    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
-    assertThat(actualStatus.getPid(), is(nullValue()));
-    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
-    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
-    assertThat(actualStatus.getClasspath(), is(nullValue()));
-    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
-    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
-    assertThat(actualStatus.getLogFile(), is(nullValue()));
-    assertThat(actualStatus.getHost(), is(nullValue()));
-    assertThat(actualStatus.getMemberName(), is(nullValue()));
-  }
-  
-  @Test
-  public void testStopUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    ServerLauncher pidLauncher = null; 
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // validate the status
-      final ServerState status = pidLauncher.status();
-      assertNotNull(status);
-      assertEquals(Status.ONLINE, status.getStatus());
-      assertEquals(pid, status.getPid().intValue());
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      if (pidLauncher == null) {
-        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      } else {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-      }          
-      waitForPidToStop(pid);
-      waitForFileToDelete(this.pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStopUsingWorkingDirectory() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      // stop the server
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-      assertFalse("PID file still exists!", this.pidFile.exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  protected void waitForServerToStart() throws Exception {
-    assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        try {
-          assertNotNull(process);
-          try {
-            final int value = process.exitValue();
-            fail("Process has died with exit value " + value + " while waiting for it to start.");
-          } catch (IllegalThreadStateException e) {
-            // expected
-          }
-          final ServerState serverState = launcher.status();
-          assertNotNull(serverState);
-          logger.info("serverState: "+serverState);
-          return Status.ONLINE.equals(serverState.getStatus());
-        }
-        catch (RuntimeException e) {
-          logger.error(e, e);
-          return false;
-        }
-      }
-    }, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS);
-  }
-  
-  protected static List<String> getJvmArguments() {
-    final List<String> jvmArguments = new ArrayList<String>();
-    jvmArguments.add("-Dgemfire.log-level=config");
-    jvmArguments.add("-Dgemfire.mcast-port=0");
-    return jvmArguments;
-  }
-  
-  /**
-   * Used only by {@link ServerLauncherRemoteJUnitTest#testRunningServerOutlivesForkingProcess}
-   */
-  public static class ServerLauncherForkingProcess {
-
-    public static void main(final String... args) throws IOException, PidUnavailableException {
-      //-System.out.println("inside main");
-      File file = new File(System.getProperty("user.dir"), ServerLauncherForkingProcess.class.getSimpleName().concat(".log"));
-      file.createNewFile();
-      LocalLogWriter logWriter = new LocalLogWriter(InternalLogWriter.ALL_LEVEL, new PrintStream(new FileOutputStream(file, true)));
-      //LogWriter logWriter = new PureLogWriter(LogWriterImpl.ALL_LEVEL);
-      logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main PID is " + getPid());
-
-      try {
-        // launch ServerLauncher
-        final List<String> jvmArguments = getJvmArguments();
-        assertTrue(jvmArguments.size() == 2);
-        final List<String> command = new ArrayList<String>();
-        command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-        for (String jvmArgument : jvmArguments) {
-          command.add(jvmArgument);
-        }
-        command.add("-cp");
-        command.add(System.getProperty("java.class.path"));
-        command.add(ServerLauncher.class.getName());
-        command.add(ServerLauncher.Command.START.getName());
-        command.add(ServerLauncherForkingProcess.class.getSimpleName()+"_server");
-        command.add("--disable-default-server");
-        command.add("--redirect-output");
-
-        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main command: " + command);
-        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main starting...");
-
-        //-System.out.println("launching " + command);
-        
-        @SuppressWarnings("unused")
-        Process forkedProcess = new ProcessBuilder(command).start();
-
-//        processOutReader = new ProcessStreamReader(forkedProcess.getInputStream()).start();
-//        processErrReader = new ProcessStreamReader(forkedProcess.getErrorStream()).start();
-
-//        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main waiting for Server to start...");
-//
-//        File workingDir = new File(System.getProperty("user.dir"));
-//        System.out.println("waiting for server to start in " + workingDir);
-//        final ServerLauncher dirLauncher = new ServerLauncher.Builder()
-//            .setWorkingDirectory(workingDir.getCanonicalPath())
-//            .build();
-//        waitForServerToStart(dirLauncher, true);
-
-        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main exiting...");
-
-        //-System.out.println("exiting");
-        System.exit(0);
-      }
-      catch (Throwable t) {
-        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t);
-        System.exit(-1);
-      }
-    }
-  }
-}


[08/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
new file mode 100755
index 0000000..c171cff
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -0,0 +1,979 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.DistributionLocator;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.logging.InternalLogWriter;
+import com.gemstone.gemfire.internal.logging.LocalLogWriter;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for launching a Locator in a forked process.
+ *
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherRemoteIntegrationTest extends AbstractLocatorLauncherRemoteIntegrationTestCase {
+  
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertTrue(factory.isAttachAPIFound());
+  }
+  
+  @Test
+  @Ignore("TRAC bug #52304: test is broken and needs to be reworked")
+  public void testRunningLocatorOutlivesForkingProcess() throws Exception {
+  }/*
+    // TODO: fix up this test
+    
+    this.temporaryFolder.getRoot() = new File(getUniqueName());
+    this.temporaryFolder.getRoot().mkdir();
+    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
+
+    // launch LocatorLauncherForkingProcess which then launches the GemFire Locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncherRemoteDUnitTest.class.getName().concat("$").concat(LocatorLauncherForkingProcess.class.getSimpleName()));
+    command.add(String.valueOf(this.locatorPort));
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    Thread waiting = new Thread(new Runnable() {
+      public void run() {
+        try {
+          assertEquals(0, process.waitFor());
+        }
+        catch (InterruptedException ignore) {
+          logger.error("Interrupted while waiting for process!", ignore);
+        }
+      }
+    });
+
+    try {
+      waiting.start();
+      waiting.join(TIMEOUT_MILLISECONDS);
+      assertFalse("Process took too long and timed out!", waiting.isAlive());
+    }
+    finally {
+      if (waiting.isAlive()) {
+        waiting.interrupt();
+      }
+    }
+
+    LocatorLauncher locatorLauncher = new Builder().setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()).build();
+
+    assertEquals(Status.ONLINE, locatorLauncher.status().getStatus());
+    assertEquals(Status.STOPPED, locatorLauncher.stop().getStatus());
+  }
+  */
+
+  @Category(FlakyTest.class) // GEODE-473: random ports, BindException, forks JVM, uses ErrorCollector
+  @Test
+  public void testStartCreatesPidFile() throws Throwable {
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+    
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+      // check the status
+      final LocatorState locatorState = this.launcher.status();
+      assertNotNull(locatorState);
+      assertEquals(Status.ONLINE, locatorState.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-530: BindException, random ports
+  @Test
+  public void testStartDeletesStaleControlFiles() throws Throwable {
+    // create existing control files
+    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
+    this.stopRequestFile.createNewFile();
+    assertTrue(this.stopRequestFile.exists());
+
+    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
+    this.statusRequestFile.createNewFile();
+    assertTrue(this.statusRequestFile.exists());
+
+    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
+    this.statusFile.createNewFile();
+    assertTrue(this.statusFile.exists());
+    
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate stale control files were deleted
+      waitForFileToDelete(this.stopRequestFile);
+      waitForFileToDelete(this.statusRequestFile);
+      waitForFileToDelete(this.statusFile);
+      
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-1229: BindException
+  @Test
+  public void testStartOverwritesStalePidFile() throws Throwable {
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    writePid(this.pidFile, Integer.MAX_VALUE);
+
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertFalse(pid == Integer.MAX_VALUE);
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-764: BindException
+  @Test
+  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    final int otherPid = getPid();
+    assertTrue("Pid " + otherPid + " should be alive", ProcessUtils.isProcessAlive(otherPid));
+    writePid(this.pidFile, otherPid);
+
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+    command.add("--force");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertTrue(pid != otherPid);
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartUsingPortInUseFails() throws Throwable {
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    command.add("--port=" + this.locatorPort);
+
+    String expectedString = "java.net.BindException";
+    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+
+    // wait for locator to start and fail
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      int code = process.waitFor();
+      assertEquals("Expected exit code 1 but was " + code, 1, code);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      // check the status
+      final LocatorState locatorState = dirLauncher.status();
+      assertNotNull(locatorState);
+      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+      
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // if the following fails, then the SHORTER_TIMEOUT is too short for slow machines
+    // or this test needs to use MainLauncher in ProcessWrapper
+    
+    // validate that output contained BindException 
+    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
+
+    // just in case the launcher started...
+    LocatorState status = null;
+    try {
+      status = dirLauncher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    this.errorCollector.checkThat(status.getStatus(), is(equalTo(getExpectedStopStatusForNotRunning())));
+  }
+
+  @Test
+  public void testStartWithDefaultPortInUseFails() throws Throwable {
+    String expectedString = "java.net.BindException";
+    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
+    
+    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
+    assertTrue(this.socket.isBound());
+    assertFalse(this.socket.isClosed());
+    
+    // launch locator
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-D" + DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.locatorPort);
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+    
+    // wait for locator to start up
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      int code = process.waitFor(); // TODO: create flavor with timeout in ProcessUtils
+      assertEquals("Expected exit code 1 but was " + code, 1, code);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      // check the status
+      final LocatorState locatorState = dirLauncher.status();
+      assertNotNull(locatorState);
+      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+      
+      // creation of log file seems to be random -- look into why sometime
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // if the following fails, then the SHORTER_TIMEOUT might be too short for slow machines
+    // or this test needs to use MainLauncher in ProcessWrapper
+    
+    // validate that output contained BindException 
+    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
+
+    // just in case the launcher started...
+    LocatorState status = null;
+    try {
+      status = dirLauncher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    this.errorCollector.checkThat(status.getStatus(), is(equalTo(getExpectedStopStatusForNotRunning())));
+  }
+
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartWithExistingPidFileFails() throws Throwable {
+  }/*
+    this.temporaryFolder.getRoot() = new File(getUniqueName());
+    this.temporaryFolder.getRoot().mkdir();
+    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
+
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
+    writePid(this.pidFile, realPid);
+    
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+    
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher, 10*1000, false);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+      
+    try {
+      // check the status
+      final LocatorState locatorState = dirLauncher.status();
+      assertNotNull(locatorState);
+      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+      
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    // just in case the launcher started...
+    try {
+      final LocatorState status = dirLauncher.stop();
+      final Status theStatus = status.getStatus();
+      assertFalse(theStatus == Status.STARTING);
+      assertFalse(theStatus == Status.ONLINE);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartWithExistingPidFileFails
+  */
+
+  @Test
+  public void testStatusUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    LocatorLauncher pidLauncher = null; 
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // validate the status
+      final LocatorState actualStatus = pidLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
+      assertEquals(jvmArguments, actualStatus.getJvmArguments());
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      if (pidLauncher == null) {
+        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      } else {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+      }          
+      waitForPidToStop(pid);
+      waitForFileToDelete(this.pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-569: BindException, random ports
+  @Test
+  public void testStatusUsingWorkingDirectory() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      assertNotNull(dirLauncher);
+      assertFalse(dirLauncher.isRunning());
+
+      // validate the status
+      final LocatorState actualStatus = dirLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
+      assertEquals(jvmArguments, actualStatus.getJvmArguments());
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStatusWithEmptyPidFile() throws Exception {
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile());
+    
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    final LocatorState actualStatus = dirLauncher.status();
+    assertThat(actualStatus, is(notNullValue()));
+    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
+    assertThat(actualStatus.getPid(), is(nullValue()));
+    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
+    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
+    assertThat(actualStatus.getClasspath(), is(nullValue()));
+    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
+    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
+    assertThat(actualStatus.getLogFile(), is(nullValue()));
+    assertThat(actualStatus.getHost(), is(nullValue()));
+    assertThat(actualStatus.getMemberName(), is(nullValue()));
+  }
+  
+  @Test
+  public void testStatusWithNoPidFile() throws Exception {
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    LocatorState locatorState = dirLauncher.status();
+    assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
+  }
+  
+  @Test
+  public void testStatusWithStalePidFile() throws Exception {
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+    final int pid = 0;
+    assertFalse(ProcessUtils.isProcessAlive(pid));
+    writePid(this.pidFile, pid);
+    
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    final LocatorState actualStatus = dirLauncher.status();
+    assertThat(actualStatus, is(notNullValue()));
+    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
+    assertThat(actualStatus.getPid(), is(nullValue()));
+    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
+    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
+    assertThat(actualStatus.getClasspath(), is(nullValue()));
+    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
+    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
+    assertThat(actualStatus.getLogFile(), is(nullValue()));
+    assertThat(actualStatus.getHost(), is(nullValue()));
+    assertThat(actualStatus.getMemberName(), is(nullValue()));
+  }
+  
+  @Test
+  public void testStopUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    LocatorLauncher pidLauncher = null; 
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // validate the status
+      final LocatorState status = pidLauncher.status();
+      assertNotNull(status);
+      assertEquals(Status.ONLINE, status.getStatus());
+      assertEquals(pid, status.getPid().intValue());
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      if (pidLauncher == null) {
+        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      } else {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+      }          
+      waitForPidToStop(pid);
+      waitForFileToDelete(pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-847: random ports, BindException, forks JVM, uses ErrorCollector
+  @Test
+  public void testStopUsingWorkingDirectory() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for locator to start
+    int pid = 0;
+    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForLocatorToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      // stop the locator
+      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      waitForPidToStop(pid);
+      assertFalse("PID file still exists!", this.pidFile.exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  /**
+   * Used only by {@link LocatorLauncherRemoteIntegrationTest#testRunningLocatorOutlivesForkingProcess}
+   */
+  public static class LocatorLauncherForkingProcess {
+
+    public static void main(final String... args) throws FileNotFoundException {
+      File file = new File(System.getProperty("user.dir"), LocatorLauncherForkingProcess.class.getSimpleName().concat(".log"));
+
+      LocalLogWriter logWriter = new LocalLogWriter(InternalLogWriter.ALL_LEVEL, new PrintStream(new FileOutputStream(file, true)));
+
+      try {
+        final int port = Integer.parseInt(args[0]);
+
+        // launch LocatorLauncher
+        List<String> command = new ArrayList<String>();
+        command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getAbsolutePath());
+        command.add("-cp");
+        command.add(System.getProperty("java.class.path"));
+        command.add("-Dgemfire.mcast-port=0");
+        command.add(LocatorLauncher.class.getName());
+        command.add(LocatorLauncher.Command.START.getName());
+        command.add(LocatorLauncherForkingProcess.class.getSimpleName() + "_Locator");
+        command.add("--port=" + port);
+        command.add("--redirect-output");
+        
+        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main command: " + command);
+        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main starting...");
+        
+        Process forkedProcess = new ProcessBuilder(command).start();
+
+        @SuppressWarnings("unused")
+        ProcessStreamReader processOutReader = new ProcessStreamReader.Builder(forkedProcess).inputStream(forkedProcess.getInputStream()).build().start();
+        @SuppressWarnings("unused")
+        ProcessStreamReader processErrReader = new ProcessStreamReader.Builder(forkedProcess).inputStream(forkedProcess.getErrorStream()).build().start();
+
+        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main waiting for locator to start...");
+
+        waitForLocatorToStart(port, TIMEOUT_MILLISECONDS, 10, true);
+
+        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main exiting...");
+
+        System.exit(0);
+      }
+      catch (Throwable t) {
+        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t);
+        System.exit(-1);
+      }
+    }
+  }
+}



[04/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileJUnitTest.java
deleted file mode 100755
index d8e318f..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteFileJUnitTest.java
+++ /dev/null
@@ -1,222 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessStreamReader;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.lang.AttachAPINotFoundException;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Subclass of ServerLauncherRemoteDUnitTest which forces the code to not find 
- * the Attach API which is in the JDK tools.jar.  As a result ServerLauncher
- * ends up using the FileProcessController implementation.
- * 
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherRemoteFileJUnitTest extends ServerLauncherRemoteJUnitTest {
-  
-  @Before
-  public void setUpServerLauncherRemoteFileTest() throws Exception {
-    System.setProperty(ProcessControllerFactory.PROPERTY_DISABLE_ATTACH_API, "true");
-  }
-  
-  @After
-  public void tearDownServerLauncherRemoteFileTest() throws Exception {   
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override and assert Attach API is NOT found
-   */
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertFalse(factory.isAttachAPIFound());
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override because FileProcessController cannot request status with PID
-   */
-  public void testStatusUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    ServerLauncher pidLauncher = null; 
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // status with pid only should throw AttachAPINotFoundException
-      try {
-        pidLauncher.status();
-        fail("FileProcessController should have thrown AttachAPINotFoundException");
-      } catch (AttachAPINotFoundException e) {
-        // passed
-      }
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the server
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid, true);
-      waitForFileToDelete(this.pidFile);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    } finally {
-      new File(ProcessType.SERVER.getStatusRequestFileName()).delete(); // TODO: delete
-    }
-  }
-  
-  @Override
-  @Test
-  /**
-   * Override because FileProcessController cannot request stop with PID
-   */
-  public void testStopUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(ServerLauncher.class.getName());
-    command.add(ServerLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--disable-default-server");
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
-
-    // wait for server to start
-    int pid = 0;
-    ServerLauncher pidLauncher = null; 
-    this.launcher = new ServerLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForServerToStart();
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // stop with pid only should throw AttachAPINotFoundException
-      try {
-        pidLauncher.stop();
-        fail("FileProcessController should have thrown AttachAPINotFoundException");
-      } catch (AttachAPINotFoundException e) {
-        // passed
-      }
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      // stop the server
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-      waitForFileToDelete(this.pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    } finally {
-      new File(ProcessType.SERVER.getStopRequestFileName()).delete(); // TODO: delete
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
new file mode 100755
index 0000000..0f80b8c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -0,0 +1,1430 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheCreation;
+import com.gemstone.gemfire.internal.cache.xmlcache.CacheXmlGenerator;
+import com.gemstone.gemfire.internal.cache.xmlcache.RegionAttributesCreation;
+import com.gemstone.gemfire.internal.logging.InternalLogWriter;
+import com.gemstone.gemfire.internal.logging.LocalLogWriter;
+import com.gemstone.gemfire.internal.process.PidUnavailableException;
+import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.FlakyTest;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.gemstone.gemfire.test.process.ProcessWrapper;
+
+/**
+ * Integration tests for launching a Server in a forked process.
+ *
+ * @see com.gemstone.gemfire.distributed.AbstractLauncher
+ * @see com.gemstone.gemfire.distributed.ServerLauncher
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.ServerState
+ * @see com.gemstone.gemfire.internal.AvailablePortHelper
+ * @since 8.0
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherRemoteIntegrationTest extends AbstractServerLauncherIntegrationTestCase {
+  
+  protected volatile Process process;
+  protected volatile ProcessStreamReader processOutReader;
+  protected volatile ProcessStreamReader processErrReader;
+  
+  @Before
+  public final void setUpServerLauncherRemoteTest() throws Exception {
+  }
+
+  @After
+  public final void tearDownServerLauncherRemoteTest() throws Exception {    
+    if (this.process != null) {
+      this.process.destroy();
+      this.process = null;
+    }
+    if (this.processOutReader != null && this.processOutReader.isRunning()) {
+      this.processOutReader.stop();
+    }
+    if (this.processErrReader != null && this.processErrReader.isRunning()) {
+      this.processErrReader.stop();
+    }
+  }
+
+  protected Status getExpectedStopStatusForNotRunning() {
+    return Status.NOT_RESPONDING;
+  }
+  
+  @Test
+  public void testIsAttachAPIFound() throws Exception {
+    final ProcessControllerFactory factory = new ProcessControllerFactory();
+    assertTrue(factory.isAttachAPIFound());
+  }
+  
+  @Test
+  @Ignore("TRAC bug #52304: test is broken and needs to be reworked")
+  public void testRunningServerOutlivesForkingProcess() throws Throwable {
+    // launch ServerLauncherForkingProcess which then launches server
+    
+//    final List<String> command = new ArrayList<String>();
+//    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+//    command.add("-cp");
+//    command.add(System.getProperty("java.class.path"));
+//    command.add(ServerLauncherDUnitTest.class.getName().concat("$").concat(ServerLauncherForkingProcess.class.getSimpleName()));
+//
+//    process = new ProcessBuilder(command).directory(temporaryFolder.getRoot()).start();
+//    assertNotNull(process);
+//    processOutReader = new ProcessStreamReader(process.getInputStream(), createListener("sysout", getUniqueName() + "#sysout")).start();
+//    processErrReader = new ProcessStreamReader(process.getErrorStream(), createListener("syserr", getUniqueName() + "#syserr")).start();
+
+    @SuppressWarnings("unused")
+    File file = new File(this.temporaryFolder.getRoot(), ServerLauncherForkingProcess.class.getSimpleName().concat(".log"));
+    //-logger.info("log file is " + file);
+    
+    final ProcessWrapper pw = new ProcessWrapper.Builder().mainClass(ServerLauncherForkingProcess.class).build();
+    pw.execute(null, this.temporaryFolder.getRoot()).waitFor(true);
+    //logger.info("[testRunningServerOutlivesForkingProcess] ServerLauncherForkingProcess output is:\n\n"+pw.getOutput());
+    
+//    // create waiting thread since waitFor does not have a timeout 
+//    Thread waiting = new Thread(new Runnable() {
+//      @Override
+//      public void run() {
+//        try {
+//          assertEquals(0, process.waitFor());
+//        } catch (InterruptedException e) {
+//          logger.error("Interrupted while waiting for process", e);
+//        }
+//      }
+//    });
+
+//    // start waiting thread and join to it for timeout
+//    try {
+//      waiting.start();
+//      waiting.join(TIMEOUT_MILLISECONDS);
+//      assertFalse("ServerLauncherForkingProcess took too long and caused timeout", waiting.isAlive());
+//      
+//    } catch (Throwable e) {
+//      logger.error(e);
+//      if (failure == null) {
+//        failure = e;
+//      }
+//    } finally {
+//      if (waiting.isAlive()) {
+//        waiting.interrupt();
+//      }
+//    }
+
+    // wait for server to start
+    int pid = 0;
+    final String serverName = ServerLauncherForkingProcess.class.getSimpleName()+"_server";
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart(dirLauncher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = serverName+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+      // validate the status
+      final ServerState actualStatus = dirLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
+      assertEquals(getJvmArguments(), actualStatus.getJvmArguments());
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + serverName + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(serverName, actualStatus.getMemberName());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartCreatesPidFile() throws Throwable {
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+    
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+      // check the status
+      final ServerState serverState = this.launcher.status();
+      assertNotNull(serverState);
+      assertEquals(Status.ONLINE, serverState.getStatus());
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartDeletesStaleControlFiles() throws Throwable {
+    // create existing control files
+    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStopRequestFileName());
+    this.stopRequestFile.createNewFile();
+    assertTrue(this.stopRequestFile.exists());
+
+    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusRequestFileName());
+    this.statusRequestFile.createNewFile();
+    assertTrue(this.statusRequestFile.exists());
+
+    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getStatusFileName());
+    this.statusFile.createNewFile();
+    assertTrue(this.statusFile.exists());
+    
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate stale control files were deleted
+      waitForFileToDelete(this.stopRequestFile);
+      waitForFileToDelete(this.statusRequestFile);
+      waitForFileToDelete(this.statusFile);
+      
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-721: random ports (setup overriding default port), TemporaryFolder
+  @Test
+  public void testStartOverwritesStalePidFile() throws Throwable {
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    writePid(this.pidFile, Integer.MAX_VALUE);
+
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertFalse(pid == Integer.MAX_VALUE);
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  /**
+   * Confirms fix for #47778.
+   */
+  @Test
+  public void testStartUsingDisableDefaultServerLeavesPortFree() throws Throwable {
+    assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // verify server did not a port
+      assertTrue(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+      
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      assertEquals("Port should be \"\" instead of " + portString, "", portString);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Test
+  public void testStartUsingDisableDefaultServerSkipsPortCheck() throws Throwable {
+    // make serverPort in use
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      assertEquals("Port should be \"\" instead of " + portString, "", portString);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // verify port is still in use
+    this.errorCollector.checkThat(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET), is(equalTo(false)));
+  }
+
+  @Category(FlakyTest.class) // GEODE-764: random ports, BindException, forks JVM, uses ErrorCollector
+  @Test
+  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    final int otherPid = getPid();
+    assertTrue("Pid " + otherPid + " should be alive", ProcessUtils.isProcessAlive(otherPid));
+    writePid(this.pidFile, otherPid);
+
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+    command.add("--force");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+      assertTrue(pid != otherPid);
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  /**
+   * Confirms fix for #47665.
+   */
+  @Test
+  public void testStartUsingServerPortInUseFails() throws Throwable {
+    // make serverPort in use
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    command.add("--server-port=" + this.serverPort);
+
+    String expectedString = "java.net.BindException";
+    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+
+    // wait for server to start and fail
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      int code = this.process.waitFor();
+      assertEquals("Expected exit code 1 but was " + code, 1, code);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      // check the status
+      final ServerState serverState = dirLauncher.status();
+      assertNotNull(serverState);
+      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
+      
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // if the following fails, then the SHORTER_TIMEOUT is too short for slow machines
+    // or this test needs to use MainLauncher in ProcessWrapper
+    
+    // validate that output contained BindException 
+    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
+
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = dirLauncher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  /**
+   * Confirms part of fix for #47664
+   */
+  @Test
+  public void testStartUsingServerPortOverridesCacheXml() throws Throwable {
+    // generate two free ports
+    final int[] freeTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+    
+    // write out cache.xml with one port
+    final CacheCreation creation = new CacheCreation();
+    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
+    attrs.setScope(Scope.DISTRIBUTED_ACK);
+    attrs.setDataPolicy(DataPolicy.REPLICATE);
+    creation.createRegion(getUniqueName(), attrs);
+    creation.addCacheServer().setPort(freeTCPPorts[0]);
+    
+    File cacheXmlFile = new File(this.temporaryFolder.getRoot(), getUniqueName()+".xml");
+    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
+    CacheXmlGenerator.generate(creation, pw);
+    pw.close();
+    
+    // launch server and specify a different port
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-Dgemfire."+DistributionConfig.CACHE_XML_FILE_NAME+"="+cacheXmlFile.getCanonicalPath());
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    command.add("--server-port=" + freeTCPPorts[1]);
+
+    String expectedString = "java.net.BindException";
+    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+    
+    // wait for server to start up
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // verify server used --server-port instead of default or port in cache.xml
+      assertTrue(AvailablePort.isPortAvailable(freeTCPPorts[0], AvailablePort.SOCKET));
+      assertFalse(AvailablePort.isPortAvailable(freeTCPPorts[1], AvailablePort.SOCKET));
+      
+      ServerState status = this.launcher.status();
+      String portString = status.getPort();
+      int port = Integer.valueOf(portString);
+      assertEquals("Port should be " + freeTCPPorts[1] + " instead of " + port, freeTCPPorts[1], port);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+      waitForFileToDelete(this.pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  /**
+   * Confirms part of fix for #47664
+   */
+  @Test
+  public void testStartUsingServerPortUsedInsteadOfDefaultCacheXml() throws Throwable {
+    // write out cache.xml with one port
+    final CacheCreation creation = new CacheCreation();
+    final RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
+    attrs.setScope(Scope.DISTRIBUTED_ACK);
+    attrs.setDataPolicy(DataPolicy.REPLICATE);
+    creation.createRegion(getUniqueName(), attrs);
+    creation.addCacheServer();
+    
+    File cacheXmlFile = new File(this.temporaryFolder.getRoot(), getUniqueName()+".xml");
+    final PrintWriter pw = new PrintWriter(new FileWriter(cacheXmlFile), true);
+    CacheXmlGenerator.generate(creation, pw);
+    pw.close();
+  
+    // launch server and specify a different port
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-Dgemfire."+DistributionConfig.CACHE_XML_FILE_NAME+"="+cacheXmlFile.getCanonicalPath());
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    command.add("--server-port=" + this.serverPort);
+
+    final String expectedString = "java.net.BindException";
+    final AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+    
+    // wait for server to start up
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+  
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // verify server used --server-port instead of default or port in cache.xml
+      assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+      
+      final ServerState status = this.launcher.status();
+      final String portString = status.getPort();
+      int port = Integer.valueOf(portString);
+      assertEquals("Port should be " + this.serverPort + " instead of " + port, this.serverPort, port);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  @Category(FlakyTest.class) // GEODE-1135: random ports, BindException, fork JVM
+  @Test
+  public void testStartWithDefaultPortInUseFails() throws Throwable {
+    String expectedString = "java.net.BindException";
+    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
+
+    // make serverPort in use
+    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.serverPort, 50, null, -1);
+    assertFalse(AvailablePort.isPortAvailable(this.serverPort, AvailablePort.SOCKET));
+    
+    // launch server
+    final List<String> jvmArguments = getJvmArguments();
+    jvmArguments.add("-D" + AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.serverPort);
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--redirect-output");
+    
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
+    
+    // wait for server to start up
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      int code = this.process.waitFor();
+      assertEquals("Expected exit code 1 but was " + code, 1, code);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+      
+    try {
+      // check the status
+      final ServerState serverState = dirLauncher.status();
+      assertNotNull(serverState);
+      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
+      
+      // creation of log file seems to be random -- look into why sometime
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+    
+    // if the following fails, then the SHORTER_TIMEOUT might be too short for slow machines
+    // or this test needs to use MainLauncher in ProcessWrapper
+    
+    // validate that output contained BindException 
+    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
+
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = dirLauncher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      assertEquals(getExpectedStopStatusForNotRunning(), status.getStatus());
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  @Ignore("Need to rewrite this without using dunit.Host")
+  public void testStartWithExistingPidFileFails() throws Throwable {
+  }/*
+    this.temporaryFolder.getRoot() = new File(getUniqueName());
+    this.temporaryFolder.getRoot().mkdir();
+    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
+
+    // create existing pid file
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
+    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
+    writePid(this.pidFile, realPid);
+    
+    // build and start the server
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // collect and throw the FIRST failure
+    Throwable failure = null;
+    
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart(dirLauncher, 10*1000, false);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+      
+    try {
+      // check the status
+      final ServerState serverState = dirLauncher.status();
+      assertNotNull(serverState);
+      assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
+      
+      final String logFileName = getUniqueName()+".log";
+      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+      
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+
+    // just in case the launcher started...
+    ServerState status = null;
+    try {
+      status = dirLauncher.stop();
+    } catch (Throwable t) { 
+      // ignore
+    }
+    
+    try {
+      final Status theStatus = status.getStatus();
+      assertFalse(theStatus == Status.STARTING);
+      assertFalse(theStatus == Status.ONLINE);
+    } catch (Throwable e) {
+      logger.error(e);
+      if (failure == null) {
+        failure = e;
+      }
+    }
+    
+    if (failure != null) {
+      throw failure;
+    }
+  } // testStartWithExistingPidFileFails
+  */
+
+  @Category(FlakyTest.class) // GEODE-957: random ports, BindException, fork JVM
+  @Test
+  public void testStatusUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    ServerLauncher pidLauncher = null; 
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // validate the status
+      final ServerState actualStatus = pidLauncher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
+      assertEquals(jvmArguments, actualStatus.getJvmArguments());
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      if (pidLauncher == null) {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      } else {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+      }          
+      waitForPidToStop(pid);
+      waitForFileToDelete(this.pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStatusUsingWorkingDirectory() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      assertNotNull(this.launcher);
+      assertFalse(this.launcher.isRunning());
+
+      // validate the status
+      final ServerState actualStatus = this.launcher.status();
+      assertNotNull(actualStatus);
+      assertEquals(Status.ONLINE, actualStatus.getStatus());
+      assertEquals(pid, actualStatus.getPid().intValue());
+      assertTrue(actualStatus.getUptime() > 0);
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
+      assertEquals(jvmArguments, actualStatus.getJvmArguments());
+      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
+      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
+      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
+      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
+      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
+      assertEquals(getUniqueName(), actualStatus.getMemberName());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStatusWithEmptyPidFile() throws Exception {
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile());
+    
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    final ServerState actualStatus = dirLauncher.status();
+    assertThat(actualStatus, is(notNullValue()));
+    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
+    assertThat(actualStatus.getPid(), is(nullValue()));
+    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
+    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
+    assertThat(actualStatus.getClasspath(), is(nullValue()));
+    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
+    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
+    assertThat(actualStatus.getLogFile(), is(nullValue()));
+    assertThat(actualStatus.getHost(), is(nullValue()));
+    assertThat(actualStatus.getMemberName(), is(nullValue()));
+  }
+  
+  @Test
+  public void testStatusWithNoPidFile() throws Exception {
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    ServerState serverState = dirLauncher.status();
+    assertEquals(Status.NOT_RESPONDING, serverState.getStatus());
+  }
+  
+  @Test
+  public void testStatusWithStalePidFile() throws Exception {
+    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+    final int pid = 0;
+    assertFalse(ProcessUtils.isProcessAlive(pid));
+    writePid(this.pidFile, pid);
+    
+    final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+        .setWorkingDirectory(temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    final ServerState actualStatus = dirLauncher.status();
+    assertThat(actualStatus, is(notNullValue()));
+    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
+    assertThat(actualStatus.getPid(), is(nullValue()));
+    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
+    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
+    assertThat(actualStatus.getClasspath(), is(nullValue()));
+    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
+    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
+    assertThat(actualStatus.getLogFile(), is(nullValue()));
+    assertThat(actualStatus.getHost(), is(nullValue()));
+    assertThat(actualStatus.getMemberName(), is(nullValue()));
+  }
+  
+  @Test
+  public void testStopUsingPid() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    ServerLauncher pidLauncher = null; 
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // use launcher with pid
+      pidLauncher = new Builder()
+          .setPid(pid)
+          .build();
+
+      assertNotNull(pidLauncher);
+      assertFalse(pidLauncher.isRunning());
+
+      // validate the status
+      final ServerState status = pidLauncher.status();
+      assertNotNull(status);
+      assertEquals(Status.ONLINE, status.getStatus());
+      assertEquals(pid, status.getPid().intValue());
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the server
+    try {
+      if (pidLauncher == null) {
+        assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      } else {
+        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
+      }          
+      waitForPidToStop(pid);
+      waitForFileToDelete(this.pidFile);
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+  
+  @Test
+  public void testStopUsingWorkingDirectory() throws Throwable {
+    final List<String> jvmArguments = getJvmArguments();
+    
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(ServerLauncher.class.getName());
+    command.add(ServerLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--disable-default-server");
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
+
+    // wait for server to start
+    int pid = 0;
+    this.launcher = new ServerLauncher.Builder()
+        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
+        .build();
+    try {
+      waitForServerToStart();
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.SERVER.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      // validate log file was created
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      // stop the server
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+      assertFalse("PID file still exists!", this.pidFile.exists());
+      
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  protected void waitForServerToStart() throws Exception {
+    assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        try {
+          assertNotNull(process);
+          try {
+            final int value = process.exitValue();
+            fail("Process has died with exit value " + value + " while waiting for it to start.");
+          } catch (IllegalThreadStateException e) {
+            // expected
+          }
+          final ServerState serverState = launcher.status();
+          assertNotNull(serverState);
+          logger.info("serverState: "+serverState);
+          return Status.ONLINE.equals(serverState.getStatus());
+        }
+        catch (RuntimeException e) {
+          logger.error(e, e);
+          return false;
+        }
+      }
+    }, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS);
+  }
+  
+  protected static List<String> getJvmArguments() {
+    final List<String> jvmArguments = new ArrayList<String>();
+    jvmArguments.add("-Dgemfire.log-level=config");
+    jvmArguments.add("-Dgemfire.mcast-port=0");
+    return jvmArguments;
+  }
+  
+  /**
+   * Used only by {@link ServerLauncherRemoteIntegrationTest#testRunningServerOutlivesForkingProcess}
+   */
+  public static class ServerLauncherForkingProcess {
+
+    public static void main(final String... args) throws IOException, PidUnavailableException {
+      //-System.out.println("inside main");
+      File file = new File(System.getProperty("user.dir"), ServerLauncherForkingProcess.class.getSimpleName().concat(".log"));
+      file.createNewFile();
+      LocalLogWriter logWriter = new LocalLogWriter(InternalLogWriter.ALL_LEVEL, new PrintStream(new FileOutputStream(file, true)));
+      //LogWriter logWriter = new PureLogWriter(LogWriterImpl.ALL_LEVEL);
+      logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main PID is " + getPid());
+
+      try {
+        // launch ServerLauncher
+        final List<String> jvmArguments = getJvmArguments();
+        assertTrue(jvmArguments.size() == 2);
+        final List<String> command = new ArrayList<String>();
+        command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+        for (String jvmArgument : jvmArguments) {
+          command.add(jvmArgument);
+        }
+        command.add("-cp");
+        command.add(System.getProperty("java.class.path"));
+        command.add(ServerLauncher.class.getName());
+        command.add(ServerLauncher.Command.START.getName());
+        command.add(ServerLauncherForkingProcess.class.getSimpleName()+"_server");
+        command.add("--disable-default-server");
+        command.add("--redirect-output");
+
+        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main command: " + command);
+        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main starting...");
+
+        //-System.out.println("launching " + command);
+        
+        @SuppressWarnings("unused")
+        Process forkedProcess = new ProcessBuilder(command).start();
+
+//        processOutReader = new ProcessStreamReader(forkedProcess.getInputStream()).start();
+//        processErrReader = new ProcessStreamReader(forkedProcess.getErrorStream()).start();
+
+//        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main waiting for Server to start...");
+//
+//        File workingDir = new File(System.getProperty("user.dir"));
+//        System.out.println("waiting for server to start in " + workingDir);
+//        final ServerLauncher dirLauncher = new ServerLauncher.Builder()
+//            .setWorkingDirectory(workingDir.getCanonicalPath())
+//            .build();
+//        waitForServerToStart(dirLauncher, true);
+
+        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main exiting...");
+
+        //-System.out.println("exiting");
+        System.exit(0);
+      }
+      catch (Throwable t) {
+        logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t);
+        System.exit(-1);
+      }
+    }
+  }
+}


[07/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
deleted file mode 100755
index 7eabba6..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
+++ /dev/null
@@ -1,1152 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.DistributionLocator;
-import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.SocketCreator;
-import com.gemstone.gemfire.internal.lang.StringUtils;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
-import com.gemstone.gemfire.internal.logging.LocalLogWriter;
-import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
-import com.gemstone.gemfire.internal.process.ProcessStreamReader;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.test.junit.categories.FlakyTest;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Integration tests for launching a Locator in a forked process.
- *
- * @since 8.0
- */
-@Category(IntegrationTest.class)
-public class LocatorLauncherRemoteJUnitTest extends AbstractLocatorLauncherJUnitTestCase {
-  
-  protected volatile Process process;
-  protected volatile ProcessStreamReader processOutReader;
-  protected volatile ProcessStreamReader processErrReader;
-  
-  @Before
-  public final void setUpLocatorLauncherRemoteTest() throws Exception {
-  }
-
-  @After
-  public final void tearDownLocatorLauncherRemoteTest() throws Exception {
-    if (this.process != null) {
-      this.process.destroy();
-      this.process = null;
-    }
-    if (this.processOutReader != null && this.processOutReader.isRunning()) {
-      this.processOutReader.stop();
-    }
-    if (this.processErrReader != null && this.processErrReader.isRunning()) {
-      this.processErrReader.stop();
-    }
-  }
-
-  protected Status getExpectedStopStatusForNotRunning() {
-    return Status.NOT_RESPONDING;
-  }
-  
-  @Test
-  public void testIsAttachAPIFound() throws Exception {
-    final ProcessControllerFactory factory = new ProcessControllerFactory();
-    assertTrue(factory.isAttachAPIFound());
-  }
-  
-  @Test
-  @Ignore("TRAC bug #52304: test is broken and needs to be reworked")
-  public void testRunningLocatorOutlivesForkingProcess() throws Exception {
-  }/*
-    // TODO: fix up this test
-    
-    this.temporaryFolder.getRoot() = new File(getUniqueName());
-    this.temporaryFolder.getRoot().mkdir();
-    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
-
-    // launch LocatorLauncherForkingProcess which then launches the GemFire Locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncherRemoteDUnitTest.class.getName().concat("$").concat(LocatorLauncherForkingProcess.class.getSimpleName()));
-    command.add(String.valueOf(this.locatorPort));
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    Thread waiting = new Thread(new Runnable() {
-      public void run() {
-        try {
-          assertEquals(0, process.waitFor());
-        }
-        catch (InterruptedException ignore) {
-          logger.error("Interrupted while waiting for process!", ignore);
-        }
-      }
-    });
-
-    try {
-      waiting.start();
-      waiting.join(TIMEOUT_MILLISECONDS);
-      assertFalse("Process took too long and timed out!", waiting.isAlive());
-    }
-    finally {
-      if (waiting.isAlive()) {
-        waiting.interrupt();
-      }
-    }
-
-    LocatorLauncher locatorLauncher = new Builder().setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()).build();
-
-    assertEquals(Status.ONLINE, locatorLauncher.status().getStatus());
-    assertEquals(Status.STOPPED, locatorLauncher.stop().getStatus());
-  }
-  */
-
-  @Category(FlakyTest.class) // GEODE-473: random ports, BindException, forks JVM, uses ErrorCollector
-  @Test
-  public void testStartCreatesPidFile() throws Throwable {
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    int pid = 0;
-    this.launcher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-    
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-      // check the status
-      final LocatorState locatorState = this.launcher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.ONLINE, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  private static class ToSystemOut implements ProcessStreamReader.InputListener {
-    @Override
-    public void notifyInputLine(String line) {
-      System.out.println(line);
-    }
-  }
-
-  @Test
-  public void testStartUsesCustomLoggingConfiguration() throws Throwable {
-    // TODO: create working dir, copy custom xml to that dir and point log4j at it
-
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
-    //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    for (String line : command) {
-      System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
-    }
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
-
-    int pid = 0;
-    String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
-    System.out.println("KIRK: workingDirectory=" + workingDirectory);
-    this.launcher = new LocatorLauncher.Builder()
-            .setWorkingDirectory(workingDirectory)
-            .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // check the status
-      final LocatorState locatorState = this.launcher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.ONLINE, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartUsesCustomLoggingConfigurationWithLauncherLifecycleCommands() throws Throwable {
-    // TODO: create working dir, copy custom xml to that dir and point log4j at it
-
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-Dlog4j.configurationFile=/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
-    //command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=/Users/klund/dev/doesnotexist.xml");
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    for (String line : command) {
-      System.out.println("KIRK:testStartUsesCustomLoggingConfiguration:stdout: " + line);
-    }
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
-
-    int pid = 0;
-    String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
-    System.out.println("KIRK: workingDirectory=" + workingDirectory);
-    this.launcher = new LocatorLauncher.Builder()
-            .setWorkingDirectory(workingDirectory)
-            .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // check the status
-      final LocatorState locatorState = this.launcher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.ONLINE, locatorState.getStatus());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-530: BindException, random ports
-  @Test
-  public void testStartDeletesStaleControlFiles() throws Throwable {
-    // create existing control files
-    this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
-    this.stopRequestFile.createNewFile();
-    assertTrue(this.stopRequestFile.exists());
-
-    this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
-    this.statusRequestFile.createNewFile();
-    assertTrue(this.statusRequestFile.exists());
-
-    this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
-    this.statusFile.createNewFile();
-    assertTrue(this.statusFile.exists());
-    
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    this.launcher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate stale control files were deleted
-      waitForFileToDelete(this.stopRequestFile);
-      waitForFileToDelete(this.statusRequestFile);
-      waitForFileToDelete(this.statusFile);
-      
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-1229: BindException
-  @Test
-  public void testStartOverwritesStalePidFile() throws Throwable {
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    writePid(this.pidFile, Integer.MAX_VALUE);
-
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    int pid = 0;
-    this.launcher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertFalse(pid == Integer.MAX_VALUE);
-
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-764: BindException
-  @Test
-  public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    final int otherPid = getPid();
-    assertTrue("Pid " + otherPid + " should be alive", ProcessUtils.isProcessAlive(otherPid));
-    writePid(this.pidFile, otherPid);
-
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-    command.add("--force");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    this.launcher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(this.launcher);
-
-      // validate the pid file and its contents
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-      assertTrue(pid != otherPid);
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Test
-  public void testStartUsingPortInUseFails() throws Throwable {
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
-    
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    command.add("--port=" + this.locatorPort);
-
-    String expectedString = "java.net.BindException";
-    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-
-    // wait for locator to start and fail
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      int code = process.waitFor();
-      assertEquals("Expected exit code 1 but was " + code, 1, code);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      // check the status
-      final LocatorState locatorState = dirLauncher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
-      
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // if the following fails, then the SHORTER_TIMEOUT is too short for slow machines
-    // or this test needs to use MainLauncher in ProcessWrapper
-    
-    // validate that output contained BindException 
-    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
-
-    // just in case the launcher started...
-    LocatorState status = null;
-    try {
-      status = dirLauncher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    this.errorCollector.checkThat(status.getStatus(), is(equalTo(getExpectedStopStatusForNotRunning())));
-  }
-
-  @Test
-  public void testStartWithDefaultPortInUseFails() throws Throwable {
-    String expectedString = "java.net.BindException";
-    AtomicBoolean outputContainedExpectedString = new AtomicBoolean();
-
-    this.socket = SocketCreator.getDefaultInstance().createServerSocket(this.locatorPort, 50, null, -1);
-    
-    assertFalse(AvailablePort.isPortAvailable(this.locatorPort, AvailablePort.SOCKET));
-    assertTrue(this.socket.isBound());
-    assertFalse(this.socket.isClosed());
-    
-    // launch locator
-    final List<String> jvmArguments = getJvmArguments();
-    jvmArguments.add("-D" + DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" + this.locatorPort);
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--redirect-output");
-    
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createExpectedListener("sysout", getUniqueName() + "#sysout", expectedString, outputContainedExpectedString)).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createExpectedListener("syserr", getUniqueName() + "#syserr", expectedString, outputContainedExpectedString)).build().start();
-    
-    // wait for locator to start up
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      int code = process.waitFor(); // TODO: create flavor with timeout in ProcessUtils
-      assertEquals("Expected exit code 1 but was " + code, 1, code);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-      
-    try {
-      // check the status
-      final LocatorState locatorState = dirLauncher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
-      
-      // creation of log file seems to be random -- look into why sometime
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-    
-    // if the following fails, then the SHORTER_TIMEOUT might be too short for slow machines
-    // or this test needs to use MainLauncher in ProcessWrapper
-    
-    // validate that output contained BindException 
-    this.errorCollector.checkThat(outputContainedExpectedString.get(), is(equalTo(true)));
-
-    // just in case the launcher started...
-    LocatorState status = null;
-    try {
-      status = dirLauncher.stop();
-    } catch (Throwable t) { 
-      // ignore
-    }
-    
-    this.errorCollector.checkThat(status.getStatus(), is(equalTo(getExpectedStopStatusForNotRunning())));
-  }
-
-  @Test
-  @Ignore("Need to rewrite this without using dunit.Host")
-  public void testStartWithExistingPidFileFails() throws Throwable {
-  }/*
-    this.temporaryFolder.getRoot() = new File(getUniqueName());
-    this.temporaryFolder.getRoot().mkdir();
-    assertTrue(this.temporaryFolder.getRoot().isDirectory() && this.temporaryFolder.getRoot().canWrite());
-
-    // create existing pid file
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    final int realPid = Host.getHost(0).getVM(3).invoke(() -> ProcessUtils.identifyPid());
-    assertFalse("Remote pid shouldn't be the same as local pid " + realPid, realPid == ProcessUtils.identifyPid());
-    writePid(this.pidFile, realPid);
-    
-    // build and start the locator
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // collect and throw the FIRST failure
-    Throwable failure = null;
-    
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher, 10*1000, false);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-      
-    try {
-      // check the status
-      final LocatorState locatorState = dirLauncher.status();
-      assertNotNull(locatorState);
-      assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
-      
-      final String logFileName = getUniqueName()+".log";
-      assertFalse("Log file should not exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-      
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-
-    // just in case the launcher started...
-    try {
-      final LocatorState status = dirLauncher.stop();
-      final Status theStatus = status.getStatus();
-      assertFalse(theStatus == Status.STARTING);
-      assertFalse(theStatus == Status.ONLINE);
-    } catch (Throwable e) {
-      logger.error(e);
-      if (failure == null) {
-        failure = e;
-      }
-    }
-    
-    if (failure != null) {
-      throw failure;
-    }
-  } // testStartWithExistingPidFileFails
-  */
-
-  @Test
-  public void testStatusUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    LocatorLauncher pidLauncher = null; 
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // validate the status
-      final LocatorState actualStatus = pidLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
-      assertEquals(jvmArguments, actualStatus.getJvmArguments());
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      if (pidLauncher == null) {
-        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      } else {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-      }          
-      waitForPidToStop(pid);
-      waitForFileToDelete(this.pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-569: BindException, random ports
-  @Test
-  public void testStatusUsingWorkingDirectory() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      assertNotNull(dirLauncher);
-      assertFalse(dirLauncher.isRunning());
-
-      // validate the status
-      final LocatorState actualStatus = dirLauncher.status();
-      assertNotNull(actualStatus);
-      assertEquals(Status.ONLINE, actualStatus.getStatus());
-      assertEquals(pid, actualStatus.getPid().intValue());
-      assertTrue(actualStatus.getUptime() > 0);
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath(), actualStatus.getWorkingDirectory());
-      assertEquals(jvmArguments, actualStatus.getJvmArguments());
-      assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
-      assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
-      assertEquals(System.getProperty("java.version"),  actualStatus.getJavaVersion());
-      assertEquals(this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
-      assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
-      assertEquals(getUniqueName(), actualStatus.getMemberName());
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      waitForPidToStop(pid);
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-  
-  @Test
-  public void testStatusWithEmptyPidFile() throws Exception {
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    assertTrue(this.pidFile + " already exists", this.pidFile.createNewFile());
-    
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    final LocatorState actualStatus = dirLauncher.status();
-    assertThat(actualStatus, is(notNullValue()));
-    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
-    assertThat(actualStatus.getPid(), is(nullValue()));
-    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
-    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
-    assertThat(actualStatus.getClasspath(), is(nullValue()));
-    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
-    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
-    assertThat(actualStatus.getLogFile(), is(nullValue()));
-    assertThat(actualStatus.getHost(), is(nullValue()));
-    assertThat(actualStatus.getMemberName(), is(nullValue()));
-  }
-  
-  @Test
-  public void testStatusWithNoPidFile() throws Exception {
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    LocatorState locatorState = dirLauncher.status();
-    assertEquals(Status.NOT_RESPONDING, locatorState.getStatus());
-  }
-  
-  @Test
-  public void testStatusWithStalePidFile() throws Exception {
-    this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-    final int pid = 0;
-    assertFalse(ProcessUtils.isProcessAlive(pid));
-    writePid(this.pidFile, pid);
-    
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    final LocatorState actualStatus = dirLauncher.status();
-    assertThat(actualStatus, is(notNullValue()));
-    assertThat(actualStatus.getStatus(), is(equalTo(Status.NOT_RESPONDING)));
-    assertThat(actualStatus.getPid(), is(nullValue()));
-    assertThat(actualStatus.getUptime().intValue(), is(equalTo(0)));
-    assertThat(actualStatus.getWorkingDirectory(), is(equalTo(this.temporaryFolder.getRoot().getCanonicalPath())));
-    assertThat(actualStatus.getClasspath(), is(nullValue()));
-    assertThat(actualStatus.getGemFireVersion(), is(equalTo(GemFireVersion.getGemFireVersion())));
-    assertThat(actualStatus.getJavaVersion(), is(nullValue()));
-    assertThat(actualStatus.getLogFile(), is(nullValue()));
-    assertThat(actualStatus.getHost(), is(nullValue()));
-    assertThat(actualStatus.getMemberName(), is(nullValue()));
-  }
-  
-  @Test
-  public void testStopUsingPid() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(createLoggingListener("sysout", getUniqueName() + "#sysout")).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(createLoggingListener("syserr", getUniqueName() + "#syserr")).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    LocatorLauncher pidLauncher = null; 
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-      // use launcher with pid
-      pidLauncher = new Builder()
-          .setPid(pid)
-          .build();
-
-      assertNotNull(pidLauncher);
-      assertFalse(pidLauncher.isRunning());
-
-      // validate the status
-      final LocatorState status = pidLauncher.status();
-      assertNotNull(status);
-      assertEquals(Status.ONLINE, status.getStatus());
-      assertEquals(pid, status.getPid().intValue());
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    // stop the locator
-    try {
-      if (pidLauncher == null) {
-        assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      } else {
-        assertEquals(Status.STOPPED, pidLauncher.stop().getStatus());
-      }          
-      waitForPidToStop(pid);
-      waitForFileToDelete(pidFile);
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  @Category(FlakyTest.class) // GEODE-847: random ports, BindException, forks JVM, uses ErrorCollector
-  @Test
-  public void testStopUsingWorkingDirectory() throws Throwable {
-    final List<String> jvmArguments = getJvmArguments();
-    
-    final List<String> command = new ArrayList<String>();
-    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
-    for (String jvmArgument : jvmArguments) {
-      command.add(jvmArgument);
-    }
-    command.add("-cp");
-    command.add(System.getProperty("java.class.path"));
-    command.add(LocatorLauncher.class.getName());
-    command.add(LocatorLauncher.Command.START.getName());
-    command.add(getUniqueName());
-    command.add("--port=" + this.locatorPort);
-    command.add("--redirect-output");
-
-    this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
-    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
-    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
-
-    // wait for locator to start
-    int pid = 0;
-    final LocatorLauncher dirLauncher = new LocatorLauncher.Builder()
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath())
-        .build();
-    try {
-      waitForLocatorToStart(dirLauncher);
-
-      // validate the pid file and its contents
-      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
-      assertTrue(this.pidFile.exists());
-      pid = readPid(this.pidFile);
-      assertTrue(pid > 0);
-      assertTrue(ProcessUtils.isProcessAlive(pid));
-
-      // validate log file was created
-      final String logFileName = getUniqueName()+".log";
-      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
-
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      // stop the locator
-      assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
-      waitForPidToStop(pid);
-      assertFalse("PID file still exists!", this.pidFile.exists());
-      
-    } catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-
-  public static List<String> getJvmArguments() {
-    final List<String> jvmArguments = new ArrayList<String>();
-    jvmArguments.add("-Dgemfire.log-level=config");
-    return jvmArguments;
-  }
-  
-  /**
-   * Used only by {@link LocatorLauncherRemoteJUnitTest#testRunningLocatorOutlivesForkingProcess}
-   */
-  public static class LocatorLauncherForkingProcess {
-
-    public static void main(final String... args) throws FileNotFoundException {
-      File file = new File(System.getProperty("user.dir"), LocatorLauncherForkingProcess.class.getSimpleName().concat(".log"));
-
-      LocalLogWriter logWriter = new LocalLogWriter(InternalLogWriter.ALL_LEVEL, new PrintStream(new FileOutputStream(file, true)));
-
-      try {
-        final int port = Integer.parseInt(args[0]);
-
-        // launch LocatorLauncher
-        List<String> command = new ArrayList<String>();
-        command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getAbsolutePath());
-        command.add("-cp");
-        command.add(System.getProperty("java.class.path"));
-        command.add("-Dgemfire.mcast-port=0");
-        command.add(LocatorLauncher.class.getName());
-        command.add(LocatorLauncher.Command.START.getName());
-        command.add(LocatorLauncherForkingProcess.class.getSimpleName() + "_Locator");
-        command.add("--port=" + port);
-        command.add("--redirect-output");
-        
-        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main command: " + command);
-        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main starting...");
-        
-        Process forkedProcess = new ProcessBuilder(command).start();
-
-        @SuppressWarnings("unused")
-        ProcessStreamReader processOutReader = new ProcessStreamReader.Builder(forkedProcess).inputStream(forkedProcess.getInputStream()).build().start();
-        @SuppressWarnings("unused")
-        ProcessStreamReader processErrReader = new ProcessStreamReader.Builder(forkedProcess).inputStream(forkedProcess.getErrorStream()).build().start();
-
-        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main waiting for locator to start...");
-
-        waitForLocatorToStart(port, TIMEOUT_MILLISECONDS, 10, true);
-
-        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main exiting...");
-
-        System.exit(0);
-      }
-      catch (Throwable t) {
-        logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t);
-        System.exit(-1);
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherTest.java
new file mode 100644
index 0000000..39fdd4d
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherTest.java
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import joptsimple.OptionException;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+/**
+ * The LocatorLauncherTest class is a test suite of test cases for testing the contract and functionality of
+ * launching a GemFire Locator.
+ *
+ * @see com.gemstone.gemfire.distributed.LocatorLauncher
+ * @see com.gemstone.gemfire.distributed.LocatorLauncher.Builder
+ * @see com.gemstone.gemfire.distributed.LocatorLauncher.Command
+ * @see org.junit.Assert
+ * @see org.junit.Test
+ * @since 7.0
+ */
+@Category(UnitTest.class)
+public class LocatorLauncherTest {
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TestName testName = new TestName();
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testBuilderParseArgumentsWithNonNumericPort() {
+    try {
+      new Builder().parseArguments("start", "locator1", "--port", "oneTwoThree");
+    }
+    catch (IllegalArgumentException expected) {
+      assertTrue(expected.getCause() instanceof OptionException);
+      assertTrue(expected.getMessage(), expected.getMessage().contains(
+        LocalizedStrings.Launcher_Builder_PARSE_COMMAND_LINE_ARGUMENT_ERROR_MESSAGE.toLocalizedString(
+          "Locator", expected.getCause().getMessage())));
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testForceDefaultsToFalse() {
+    assertFalse(new Builder().getForce());
+  }
+
+  @Test
+  public void testForceSetToTrue() {
+    Builder builder = new Builder();
+
+    builder.parseArguments("start", "--force");
+
+    assertTrue(Boolean.TRUE.equals(builder.getForce()));
+  }
+
+  @Test
+  public void testSetAndGetCommand() {
+    final Builder builder = new Builder();
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+    assertSame(builder, builder.setCommand(Command.START));
+    assertEquals(Command.START, builder.getCommand());
+    assertSame(builder, builder.setCommand(Command.STATUS));
+    assertEquals(Command.STATUS, builder.getCommand());
+    assertSame(builder, builder.setCommand(Command.STOP));
+    assertEquals(Command.STOP, builder.getCommand());
+    assertSame(builder, builder.setCommand(null));
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+  }
+
+  @Test
+  public void testSetAndGetBindAddress() throws UnknownHostException {
+    final Builder builder = new Builder();
+
+    assertNull(builder.getBindAddress());
+    assertSame(builder, builder.setBindAddress(null));
+    assertNull(builder.getBindAddress());
+    assertSame(builder, builder.setBindAddress(""));
+    assertNull(builder.getBindAddress());
+    assertSame(builder, builder.setBindAddress("  "));
+    assertNull(builder.getBindAddress());
+    assertSame(builder, builder.setBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
+    assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetBindAddressToUnknownHost() {
+    try {
+      new Builder().setBindAddress("badhostname.badcompany.bad");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Locator");
+      final String expectedMessage2 = "badhostname.badcompany.bad is not an address for this machine.";
+      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
+      if (expected.getMessage().equals(expectedMessage1)) {
+        assertTrue(expected.getCause() instanceof UnknownHostException);
+      }
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetBindAddressToNonLocalHost() {
+    try {
+      new Builder().setBindAddress("yahoo.com");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage = "yahoo.com is not an address for this machine.";
+      assertEquals(expectedMessage, expected.getMessage());
+      throw expected;
+    }
+  }
+  
+  @Test
+  public void testSetBindAddressToLocalHost() throws Exception {        
+    String host = InetAddress.getLocalHost().getHostName();            
+    new Builder().setBindAddress(host);
+  }
+  
+  @Test
+  public void testSetAndGetHostnameForClients() {
+    final Builder builder = new Builder();
+
+    assertNull(builder.getHostnameForClients());
+    assertSame(builder, builder.setHostnameForClients("Pegasus"));
+    assertEquals("Pegasus", builder.getHostnameForClients());
+    assertSame(builder, builder.setHostnameForClients(null));
+    assertNull(builder.getHostnameForClients());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetHostnameForClientsWithBlankString() {
+    try {
+      new Builder().setHostnameForClients(" ");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
+        .toLocalizedString(), expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetHostnameForClientsWithEmptyString() {
+    try {
+      new Builder().setHostnameForClients("");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.LocatorLauncher_Builder_INVALID_HOSTNAME_FOR_CLIENTS_ERROR_MESSAGE
+        .toLocalizedString(), expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetMemberName() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMemberName());
+    assertSame(builder, builder.setMemberName("locatorOne"));
+    assertEquals("locatorOne", builder.getMemberName());
+    assertSame(builder, builder.setMemberName(null));
+    assertNull(builder.getMemberName());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMemberNameWithBlankString() {
+    try {
+      new Builder().setMemberName("  ");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Locator"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMemberNameWithEmptyString() {
+    try {
+      new Builder().setMemberName("");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Locator"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetPid() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getPid());
+    assertSame(builder, builder.setPid(0));
+    assertEquals(0, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(1));
+    assertEquals(1, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(1024));
+    assertEquals(1024, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(12345));
+    assertEquals(12345, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(null));
+    assertNull(builder.getPid());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetPidToInvalidValue() {
+    try {
+      new Builder().setPid(-1);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_PID_ERROR_MESSAGE.toLocalizedString(), expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void testSetAndGetPort() {
+    Builder builder = new Builder();
+
+    assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
+    assertSame(builder, builder.setPort(65535));
+    assertEquals(65535, builder.getPort().intValue());
+    assertSame(builder, builder.setPort(1024));
+    assertEquals(1024, builder.getPort().intValue());
+    assertSame(builder, builder.setPort(80));
+    assertEquals(80, builder.getPort().intValue());
+    assertSame(builder, builder.setPort(1));
+    assertEquals(1, builder.getPort().intValue());
+    assertSame(builder, builder.setPort(0));
+    assertEquals(0, builder.getPort().intValue());
+    assertSame(builder, builder.setPort(null));
+    assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetPortToOverflow() {
+    try {
+      new Builder().setPort(65536);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Locator"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetPortToUnderflow() {
+    try {
+      new Builder().setPort(-1);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Locator"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testBuild() throws Exception {
+    Builder builder = new Builder();
+
+    LocatorLauncher launcher = builder.setCommand(Command.START)
+      .setDebug(true)
+      .setHostnameForClients("beanstock.vmware.com")
+      .setMemberName("Beanstock")
+      .setPort(8192)
+      .build();
+
+    assertNotNull(launcher);
+    assertEquals(builder.getCommand(), launcher.getCommand());
+    assertTrue(launcher.isDebugging());
+    assertEquals(builder.getHostnameForClients(), launcher.getHostnameForClients());
+    assertEquals(builder.getMemberName(), launcher.getMemberName());
+    assertEquals(builder.getPort(), launcher.getPort());
+    assertEquals(builder.getWorkingDirectory(), launcher.getWorkingDirectory());
+    assertFalse(launcher.isHelping());
+    assertFalse(launcher.isRunning());
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
+    LocatorLauncher launcher = new Builder()
+      .setCommand(LocatorLauncher.Command.START)
+      .setMemberName(null)
+      .set(DistributionConfig.NAME_NAME, "locatorABC")
+      .build();
+
+    assertNotNull(launcher);
+    assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
+    assertNull(launcher.getMemberName());
+    assertEquals("locatorABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "locatorXYZ");
+
+    LocatorLauncher launcher = new Builder()
+      .setCommand(LocatorLauncher.Command.START)
+      .setMemberName(null)
+      .build();
+
+    assertNotNull(launcher);
+    assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
+    assertNull(launcher.getMemberName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateJUnitTest.java
deleted file mode 100755
index 248c39f..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateJUnitTest.java
+++ /dev/null
@@ -1,208 +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 com.gemstone.gemfire.distributed;
-
-import static com.googlecode.catchexception.CatchException.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.ServiceState;
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
-import com.gemstone.gemfire.management.internal.cli.json.GfJsonException;
-import com.gemstone.gemfire.management.internal.cli.json.GfJsonObject;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-/**
- * Unit tests for LocatorLauncher.LocatorState
- */
-@Category(UnitTest.class)
-public class LocatorStateJUnitTest {
-
-  @Test
-  public void fromJsonWithEmptyStringThrowsIllegalArgumentException() throws Exception {
-    // given: empty string
-    String emptyString = "";
-    
-    // when: passed to fromJson
-    verifyException(this).fromJson(emptyString);
-    
-    // then: throws IllegalArgumentException with cause of GfJsonException
-    assertThat((Exception)caughtException())
-        .isInstanceOf(IllegalArgumentException.class)
-        .hasCauseInstanceOf(GfJsonException.class);
-    
-    assertThat(caughtException().getCause())
-        .isInstanceOf(GfJsonException.class)
-        .hasNoCause();
-  }
-  
-  @Test
-  public void fromJsonWithWhiteSpaceStringThrowsIllegalArgumentException() throws Exception {
-    // given: white space string
-    String whiteSpaceString = "      ";
-    
-    // when: passed to fromJson
-    verifyException(this).fromJson(whiteSpaceString);
-
-    // then: throws IllegalArgumentException with cause of GfJsonException
-    assertThat((Exception)caughtException())
-        .isInstanceOf(IllegalArgumentException.class)
-        .hasCauseInstanceOf(GfJsonException.class);
-    
-    assertThat(caughtException().getCause())
-        .isInstanceOf(GfJsonException.class)
-        .hasNoCause();
-  }
-  
-  @Test
-  public void fromJsonWithNullStringThrowsNullPointerException() throws Exception {
-    // given: null string
-    String nullString = null;
-    
-    // when: passed to fromJson
-    verifyException(this).fromJson(nullString);
-    
-    // then: throws NullPointerException
-    assertThat((Exception)caughtException())
-        .isInstanceOf(NullPointerException.class)
-        .hasNoCause();
-  }
-  
-  @Test
-  public void fromJsonWithValidJsonStringReturnsLocatorState() throws Exception {
-    // given: valid json string
-    String jsonString = createStatusJson();
-    
-    // when: passed to fromJson
-    LocatorState value = fromJson(jsonString);
-    
-    // then: return valid instance of LocatorState
-    assertThat(value).isInstanceOf(LocatorState.class);
-    
-    assertThat(value.getClasspath()).isEqualTo(getClasspath());
-    assertThat(value.getGemFireVersion()).isEqualTo(getGemFireVersion());
-    assertThat(value.getHost()).isEqualTo(getHost());
-    assertThat(value.getJavaVersion()).isEqualTo(getJavaVersion());
-    assertThat(value.getJvmArguments()).isEqualTo(getJvmArguments());
-    assertThat(value.getServiceLocation()).isEqualTo(getServiceLocation());
-    assertThat(value.getLogFile()).isEqualTo(getLogFile());
-    assertThat(value.getMemberName()).isEqualTo(getMemberName());
-    assertThat(value.getPid()).isEqualTo(getPid());
-    assertThat(value.getPort()).isEqualTo(getPort());
-    assertThat(value.getStatus().getDescription()).isEqualTo(getStatusDescription());
-    assertThat(value.getStatusMessage()).isEqualTo(getStatusMessage());
-    assertThat(value.getTimestamp().getTime()).isEqualTo(getTimestampTime());
-    assertThat(value.getUptime()).isEqualTo(getUptime());
-    assertThat(value.getWorkingDirectory()).isEqualTo(getWorkingDirectory());
-  }
-  
-  protected LocatorState fromJson(final String value) {
-    return LocatorState.fromJson(value);
-  }
-
-  private String classpath = "test_classpath";
-  private String gemFireVersion = "test_gemfireversion";
-  private String host = "test_host";
-  private String javaVersion = "test_javaversion";
-  private String jvmArguments = "test_jvmarguments";
-  private String serviceLocation = "test_location";
-  private String logFile = "test_logfile";
-  private String memberName = "test_membername";
-  private Integer pid = 6396;
-  private String port = "test_port";
-  private String statusDescription = Status.NOT_RESPONDING.getDescription();
-  private String statusMessage = "test_statusmessage";
-  private Long timestampTime = 1450728233024L;
-  private Long uptime = 1629L;
-  private String workingDirectory = "test_workingdirectory";
-  
-  private String getClasspath() {
-    return this.classpath;
-  }
-  private String getGemFireVersion() {
-    return this.gemFireVersion;
-  }
-  private String getHost() {
-    return this.host;
-  }
-  private String getJavaVersion() {
-    return this.javaVersion;
-  }
-  private List<String> getJvmArguments() {
-    List<String> list = new ArrayList<String>();
-    list.add(this.jvmArguments);
-    return list;
-  }
-  private String getServiceLocation() {
-    return this.serviceLocation;
-  }
-  private String getLogFile() {
-    return this.logFile;
-  }
-  private String getMemberName() {
-    return this.memberName;
-  }
-  private Integer getPid() {
-    return this.pid;
-  }
-  private String getPort() {
-    return this.port;
-  }
-  private String getStatusDescription() {
-    return this.statusDescription;
-  }
-  private String getStatusMessage() {
-    return this.statusMessage;
-  }
-  private Long getTimestampTime() {
-    return this.timestampTime;
-  }
-  private Long getUptime() {
-    return this.uptime;
-  }
-  private String getWorkingDirectory() {
-    return this.workingDirectory;
-  }
-
-  private String createStatusJson() {
-    final Map<String, Object> map = new HashMap<String, Object>();
-    map.put(ServiceState.JSON_CLASSPATH, getClasspath());
-    map.put(ServiceState.JSON_GEMFIREVERSION, getGemFireVersion());
-    map.put(ServiceState.JSON_HOST, getHost());
-    map.put(ServiceState.JSON_JAVAVERSION, getJavaVersion());
-    map.put(ServiceState.JSON_JVMARGUMENTS, getJvmArguments());
-    map.put(ServiceState.JSON_LOCATION, getServiceLocation());
-    map.put(ServiceState.JSON_LOGFILE, getLogFile());
-    map.put(ServiceState.JSON_MEMBERNAME, getMemberName());
-    map.put(ServiceState.JSON_PID, getPid());
-    map.put(ServiceState.JSON_PORT, getPort());
-    map.put(ServiceState.JSON_STATUS, getStatusDescription());
-    map.put(ServiceState.JSON_STATUSMESSAGE, getStatusMessage());
-    map.put(ServiceState.JSON_TIMESTAMP, getTimestampTime());
-    map.put(ServiceState.JSON_UPTIME, getUptime());
-    map.put(ServiceState.JSON_WORKINGDIRECTORY, getWorkingDirectory());
-    return new GfJsonObject(map).toString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateTest.java
new file mode 100755
index 0000000..55d7d6a
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorStateTest.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static com.googlecode.catchexception.CatchException.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.ServiceState;
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+import com.gemstone.gemfire.management.internal.cli.json.GfJsonException;
+import com.gemstone.gemfire.management.internal.cli.json.GfJsonObject;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for LocatorLauncher.LocatorState
+ */
+@Category(UnitTest.class)
+public class LocatorStateTest {
+
+  @Test
+  public void fromJsonWithEmptyStringThrowsIllegalArgumentException() throws Exception {
+    // given: empty string
+    String emptyString = "";
+    
+    // when: passed to fromJson
+    verifyException(this).fromJson(emptyString);
+    
+    // then: throws IllegalArgumentException with cause of GfJsonException
+    assertThat((Exception)caughtException())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasCauseInstanceOf(GfJsonException.class);
+    
+    assertThat(caughtException().getCause())
+        .isInstanceOf(GfJsonException.class)
+        .hasNoCause();
+  }
+  
+  @Test
+  public void fromJsonWithWhiteSpaceStringThrowsIllegalArgumentException() throws Exception {
+    // given: white space string
+    String whiteSpaceString = "      ";
+    
+    // when: passed to fromJson
+    verifyException(this).fromJson(whiteSpaceString);
+
+    // then: throws IllegalArgumentException with cause of GfJsonException
+    assertThat((Exception)caughtException())
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasCauseInstanceOf(GfJsonException.class);
+    
+    assertThat(caughtException().getCause())
+        .isInstanceOf(GfJsonException.class)
+        .hasNoCause();
+  }
+  
+  @Test
+  public void fromJsonWithNullStringThrowsNullPointerException() throws Exception {
+    // given: null string
+    String nullString = null;
+    
+    // when: passed to fromJson
+    verifyException(this).fromJson(nullString);
+    
+    // then: throws NullPointerException
+    assertThat((Exception)caughtException())
+        .isInstanceOf(NullPointerException.class)
+        .hasNoCause();
+  }
+  
+  @Test
+  public void fromJsonWithValidJsonStringReturnsLocatorState() throws Exception {
+    // given: valid json string
+    String jsonString = createStatusJson();
+    
+    // when: passed to fromJson
+    LocatorState value = fromJson(jsonString);
+    
+    // then: return valid instance of LocatorState
+    assertThat(value).isInstanceOf(LocatorState.class);
+    
+    assertThat(value.getClasspath()).isEqualTo(getClasspath());
+    assertThat(value.getGemFireVersion()).isEqualTo(getGemFireVersion());
+    assertThat(value.getHost()).isEqualTo(getHost());
+    assertThat(value.getJavaVersion()).isEqualTo(getJavaVersion());
+    assertThat(value.getJvmArguments()).isEqualTo(getJvmArguments());
+    assertThat(value.getServiceLocation()).isEqualTo(getServiceLocation());
+    assertThat(value.getLogFile()).isEqualTo(getLogFile());
+    assertThat(value.getMemberName()).isEqualTo(getMemberName());
+    assertThat(value.getPid()).isEqualTo(getPid());
+    assertThat(value.getPort()).isEqualTo(getPort());
+    assertThat(value.getStatus().getDescription()).isEqualTo(getStatusDescription());
+    assertThat(value.getStatusMessage()).isEqualTo(getStatusMessage());
+    assertThat(value.getTimestamp().getTime()).isEqualTo(getTimestampTime());
+    assertThat(value.getUptime()).isEqualTo(getUptime());
+    assertThat(value.getWorkingDirectory()).isEqualTo(getWorkingDirectory());
+  }
+  
+  protected LocatorState fromJson(final String value) {
+    return LocatorState.fromJson(value);
+  }
+
+  private String classpath = "test_classpath";
+  private String gemFireVersion = "test_gemfireversion";
+  private String host = "test_host";
+  private String javaVersion = "test_javaversion";
+  private String jvmArguments = "test_jvmarguments";
+  private String serviceLocation = "test_location";
+  private String logFile = "test_logfile";
+  private String memberName = "test_membername";
+  private Integer pid = 6396;
+  private String port = "test_port";
+  private String statusDescription = Status.NOT_RESPONDING.getDescription();
+  private String statusMessage = "test_statusmessage";
+  private Long timestampTime = 1450728233024L;
+  private Long uptime = 1629L;
+  private String workingDirectory = "test_workingdirectory";
+  
+  private String getClasspath() {
+    return this.classpath;
+  }
+  private String getGemFireVersion() {
+    return this.gemFireVersion;
+  }
+  private String getHost() {
+    return this.host;
+  }
+  private String getJavaVersion() {
+    return this.javaVersion;
+  }
+  private List<String> getJvmArguments() {
+    List<String> list = new ArrayList<String>();
+    list.add(this.jvmArguments);
+    return list;
+  }
+  private String getServiceLocation() {
+    return this.serviceLocation;
+  }
+  private String getLogFile() {
+    return this.logFile;
+  }
+  private String getMemberName() {
+    return this.memberName;
+  }
+  private Integer getPid() {
+    return this.pid;
+  }
+  private String getPort() {
+    return this.port;
+  }
+  private String getStatusDescription() {
+    return this.statusDescription;
+  }
+  private String getStatusMessage() {
+    return this.statusMessage;
+  }
+  private Long getTimestampTime() {
+    return this.timestampTime;
+  }
+  private Long getUptime() {
+    return this.uptime;
+  }
+  private String getWorkingDirectory() {
+    return this.workingDirectory;
+  }
+
+  private String createStatusJson() {
+    final Map<String, Object> map = new HashMap<String, Object>();
+    map.put(ServiceState.JSON_CLASSPATH, getClasspath());
+    map.put(ServiceState.JSON_GEMFIREVERSION, getGemFireVersion());
+    map.put(ServiceState.JSON_HOST, getHost());
+    map.put(ServiceState.JSON_JAVAVERSION, getJavaVersion());
+    map.put(ServiceState.JSON_JVMARGUMENTS, getJvmArguments());
+    map.put(ServiceState.JSON_LOCATION, getServiceLocation());
+    map.put(ServiceState.JSON_LOGFILE, getLogFile());
+    map.put(ServiceState.JSON_MEMBERNAME, getMemberName());
+    map.put(ServiceState.JSON_PID, getPid());
+    map.put(ServiceState.JSON_PORT, getPort());
+    map.put(ServiceState.JSON_STATUS, getStatusDescription());
+    map.put(ServiceState.JSON_STATUSMESSAGE, getStatusMessage());
+    map.put(ServiceState.JSON_TIMESTAMP, getTimestampTime());
+    map.put(ServiceState.JSON_UPTIME, getUptime());
+    map.put(ServiceState.JSON_WORKINGDIRECTORY, getWorkingDirectory());
+    return new GfJsonObject(map).toString();
+  }
+}


[11/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
new file mode 100755
index 0000000..34c36da
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationTestCase.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.logging.log4j.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.rules.TestName;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.FileUtil;
+import com.gemstone.gemfire.internal.lang.StringUtils;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.process.PidUnavailableException;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader.InputListener;
+import com.gemstone.gemfire.internal.util.IOUtils;
+import com.gemstone.gemfire.internal.util.StopWatch;
+
+/**
+ * @since 8.0
+ */
+public abstract class AbstractLauncherIntegrationTestCase {
+  protected static final Logger logger = LogService.getLogger();
+  
+  protected static final int WAIT_FOR_PROCESS_TO_DIE_TIMEOUT = 5 * 60 * 1000; // 5 minutes
+  protected static final int TIMEOUT_MILLISECONDS = WAIT_FOR_PROCESS_TO_DIE_TIMEOUT;
+  protected static final int WAIT_FOR_FILE_CREATION_TIMEOUT = 10*1000;
+  protected static final int WAIT_FOR_FILE_DELETION_TIMEOUT = 10*1000;
+  protected static final int WAIT_FOR_MBEAN_TIMEOUT = 10*1000;
+  protected static final int INTERVAL = 100;
+  protected static final int INTERVAL_MILLISECONDS = INTERVAL;
+  
+  private static final String EXPECTED_EXCEPTION_ADD = "<ExpectedException action=add>{}</ExpectedException>";
+  private static final String EXPECTED_EXCEPTION_REMOVE = "<ExpectedException action=remove>{}</ExpectedException>";
+  private static final String EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED = "MBean Not Registered In GemFire Domain";
+  
+  protected volatile ServerSocket socket;
+  
+  protected volatile File pidFile;
+  protected volatile File stopRequestFile;
+  protected volatile File statusRequestFile;
+  protected volatile File statusFile;
+  
+  @Rule
+  public TestName testName= new TestName();
+
+  @Rule
+  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Before
+  public final void setUpAbstractLauncherIntegrationTestCase() throws Exception {
+    System.setProperty("gemfire." + DistributionConfig.MCAST_PORT_NAME, Integer.toString(0));
+    logger.info(EXPECTED_EXCEPTION_ADD, EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
+  }
+
+  @After
+  public final void tearDownAbstractLauncherIntegrationTestCase() throws Exception {
+    logger.info(EXPECTED_EXCEPTION_REMOVE, EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
+    if (this.socket != null) {
+      this.socket.close();
+      this.socket = null;
+    }
+    delete(this.pidFile); this.pidFile = null;
+    delete(this.stopRequestFile); this.stopRequestFile = null;
+    delete(this.statusRequestFile); this.statusRequestFile = null;
+    delete(this.statusFile); this.statusFile = null;
+  }
+  
+  protected void delete(final File file) throws Exception {
+    assertEventuallyTrue("deleting " + file, new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        if (file == null) {
+          return true;
+        }
+        try {
+          FileUtil.delete(file);
+        } catch (IOException e) {
+        }
+        return !file.exists();
+      }
+    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
+  }
+  
+  protected void waitForPidToStop(final int pid, boolean throwOnTimeout) throws Exception {
+    assertEventuallyFalse("Process never died", new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        return ProcessUtils.isProcessAlive(pid);
+      }
+    }, WAIT_FOR_PROCESS_TO_DIE_TIMEOUT, INTERVAL);
+  }
+  
+  protected void waitForPidToStop(final int pid) throws Exception {
+    waitForPidToStop(pid, true);
+  }
+  
+  protected void waitForFileToDelete(final File file, boolean throwOnTimeout) throws Exception {
+    if (file == null) {
+      return;
+    }
+    assertEventuallyTrue("waiting for file " + file + " to delete", new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        return !file.exists();
+      }
+    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
+  }
+  
+  protected void waitForFileToDelete(final File file) throws Exception {
+    waitForFileToDelete(file, true);
+  }
+  
+  protected static int getPid() throws PidUnavailableException {
+    return ProcessUtils.identifyPid();
+  }
+
+  protected InputListener createLoggingListener(final String name, final String header) {
+    return new InputListener() {
+      @Override
+      public void notifyInputLine(String line) {
+        logger.info(new StringBuilder("[").append(header).append("]").append(line).toString());
+      }
+      @Override
+      public String toString() {
+        return name;
+      }
+    };
+  }
+
+  protected InputListener createCollectionListener(final String name, final String header, final List<String> lines) {
+    return new InputListener() {
+      @Override
+      public void notifyInputLine(String line) {
+        lines.add(line);
+      }
+      @Override
+      public String toString() {
+        return name;
+      }
+    };
+  }
+
+  protected InputListener createExpectedListener(final String name, final String header, final String expected, final AtomicBoolean atomic) {
+    return new InputListener() {
+      @Override
+      public void notifyInputLine(String line) {
+        if (line.contains(expected)) {
+          atomic.set(true);
+        }
+      }
+      @Override
+      public String toString() {
+        return name;
+      }
+    };
+  }
+
+  protected void writeGemfireProperties(final Properties gemfireProperties, final File gemfirePropertiesFile) throws IOException {
+    if (!gemfirePropertiesFile.exists()) {
+      gemfireProperties.store(new FileWriter(gemfirePropertiesFile), "Configuration settings for the GemFire Server");
+    }
+  }
+
+  protected int readPid(final File pidFile) throws IOException {
+    BufferedReader reader = null;
+    try {
+      reader = new BufferedReader(new FileReader(pidFile));
+      return Integer.parseInt(StringUtils.trim(reader.readLine()));
+    }
+    finally {
+      IOUtils.close(reader);
+    }
+  }
+
+  protected void writePid(final File pidFile, final int pid) throws IOException {
+    FileWriter writer = new FileWriter(pidFile);
+    writer.write(String.valueOf(pid));
+    writer.write("\n");
+    writer.flush();
+    writer.close();
+  }
+
+  protected void waitForFileToExist(final File file, boolean throwOnTimeout) throws Exception {
+    assertEventuallyTrue("waiting for file " + file + " to exist", new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        return file.exists();
+      }
+    }, WAIT_FOR_FILE_CREATION_TIMEOUT, INTERVAL);
+  }
+  
+  protected void waitForFileToExist(final File file) throws Exception {
+    waitForFileToExist(file, true);
+  }
+  
+  protected String getUniqueName() {
+    return getClass().getSimpleName() + "_" + testName.getMethodName();
+  }
+  
+  protected static void assertEventuallyTrue(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
+    boolean done = false;
+    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (callable.call())) {
+      Thread.sleep(interval);
+    }
+    assertTrue(message, done);
+  }
+  
+  protected static void assertEventuallyFalse(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
+    boolean done = false;
+    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (!callable.call())) {
+      Thread.sleep(interval);
+    }
+    assertTrue(message, done);
+  }
+  
+  protected static void disconnectFromDS() {
+    InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance();
+    if (ids != null) {
+      ids.disconnect();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
deleted file mode 100644
index f5867d4..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
+++ /dev/null
@@ -1,298 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.lang.StringUtils;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * The AbstractLauncherJUnitTest class is a test suite of unit tests testing the contract and functionality
- * of the AbstractLauncher class.
- * <p/>
- * @see com.gemstone.gemfire.distributed.AbstractLauncher
- * @see org.junit.Assert
- * @see org.junit.Test
- * @since 7.0
- */
-@Category(UnitTest.class)
-public class AbstractLauncherJUnitTest {
-
-  protected AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
-    return new FakeServiceLauncher(memberName, memberId);
-  }
-
-  @Test
-  public void testIsAttachAPINotFound() {
-    final AbstractLauncher<?> launcher = createAbstractLauncher("012", "TestMember");
-
-    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
-      "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/ibm/tools/attach/AgentNotSupportedException")));
-    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
-      "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new IllegalArgumentException(
-      "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new IllegalStateException(
-      "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
-    assertFalse(launcher.isAttachAPINotFound(new NoClassDefFoundError(
-      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/companyx/app/service/MyServiceClass")));
-    assertFalse(launcher.isAttachAPINotFound(new ClassNotFoundException(
-      "Caused by: java.lang.ClassNotFoundException: com.companyx.app.attach.NutsNotAttachedException")));
-  }
-
-  @Test
-  public void testIsSet() {
-    final Properties properties = new Properties();
-
-    assertFalse(properties.containsKey(DistributionConfig.NAME_NAME));
-    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
-
-    properties.setProperty(DistributionConfig.NAME_NAME, "");
-
-    assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
-    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
-
-    properties.setProperty(DistributionConfig.NAME_NAME, "  ");
-
-    assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
-    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
-
-    properties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
-
-    assertTrue(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
-    assertFalse(AbstractLauncher.isSet(properties, "NaMe"));
-  }
-
-  @Test
-  public void testLoadGemFirePropertiesWithNullURL() {
-    final Properties properties = AbstractLauncher.loadGemFireProperties(null);
-    assertNotNull(properties);
-    assertTrue(properties.isEmpty());
-  }
-
-  @Test
-  public void testLoadGemFirePropertiesWithNonExistingURL() throws MalformedURLException {
-    final Properties properties = AbstractLauncher.loadGemFireProperties(new URL("file:///path/to/non_existing/gemfire.properties"));
-    assertNotNull(properties);
-    assertTrue(properties.isEmpty());
-  }
-
-  @Test
-  public void testGetDistributedSystemProperties() {
-    AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "1");
-
-    assertNotNull(launcher);
-    assertEquals("1", launcher.getMemberId());
-    assertEquals("memberOne", launcher.getMemberName());
-
-    Properties distributedSystemProperties = launcher.getDistributedSystemProperties();
-
-    assertNotNull(distributedSystemProperties);
-    assertTrue(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
-    assertEquals("memberOne", distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
-
-    launcher = createAbstractLauncher(null, "22");
-
-    assertNotNull(launcher);
-    assertEquals("22", launcher.getMemberId());
-    assertNull(launcher.getMemberName());
-
-    distributedSystemProperties = launcher.getDistributedSystemProperties();
-
-    assertNotNull(distributedSystemProperties);
-    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
-
-    launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "333");
-
-    assertNotNull(launcher);
-    assertEquals("333", launcher.getMemberId());
-    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
-
-    distributedSystemProperties = launcher.getDistributedSystemProperties();
-
-    assertNotNull(distributedSystemProperties);
-    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
-
-    launcher = createAbstractLauncher("  ", "4444");
-
-    assertNotNull(launcher);
-    assertEquals("4444", launcher.getMemberId());
-    assertEquals("  ", launcher.getMemberName());
-
-    distributedSystemProperties = launcher.getDistributedSystemProperties();
-
-    assertNotNull(distributedSystemProperties);
-    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
-  }
-
-  @Test
-  public void testGetDistributedSystemPropertiesWithDefaults() {
-    AbstractLauncher<?> launcher = createAbstractLauncher("TestMember", "123");
-
-    assertNotNull(launcher);
-    assertEquals("123", launcher.getMemberId());
-    assertEquals("TestMember", launcher.getMemberName());
-
-    Properties defaults = new Properties();
-
-    defaults.setProperty("testKey", "testValue");
-
-    Properties distributedSystemProperties = launcher.getDistributedSystemProperties(defaults);
-
-    assertNotNull(distributedSystemProperties);
-    assertEquals(launcher.getMemberName(), distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
-    assertEquals("testValue", distributedSystemProperties.getProperty("testKey"));
-  }
-
-  @Test
-  public void testGetMember() {
-    AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "123");
-
-    assertNotNull(launcher);
-    assertEquals("123", launcher.getMemberId());
-    assertEquals("memberOne", launcher.getMemberName());
-    assertEquals("memberOne", launcher.getMember());
-
-    launcher = createAbstractLauncher(null, "123");
-
-    assertNotNull(launcher);
-    assertEquals("123", launcher.getMemberId());
-    assertNull(launcher.getMemberName());
-    assertEquals("123", launcher.getMember());
-
-    launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "123");
-
-    assertNotNull(launcher);
-    assertEquals("123", launcher.getMemberId());
-    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
-    assertEquals("123", launcher.getMember());
-
-    launcher = createAbstractLauncher(" ", "123");
-
-    assertNotNull(launcher);
-    assertEquals("123", launcher.getMemberId());
-    assertEquals(" ", launcher.getMemberName());
-    assertEquals("123", launcher.getMember());
-
-    launcher = createAbstractLauncher(null, StringUtils.EMPTY_STRING);
-
-    assertNotNull(launcher);
-    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberId());
-    assertNull(launcher.getMemberName());
-    assertNull(launcher.getMember());
-
-    launcher = createAbstractLauncher(null, " ");
-
-    assertNotNull(launcher);
-    assertEquals(" ", launcher.getMemberId());
-    assertNull(launcher.getMemberName());
-    assertNull(launcher.getMember());
-  }
-
-  @Test
-  public void testAbstractLauncherServiceStateToDaysHoursMinutesSeconds() {
-    assertEquals("", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(null));
-    assertEquals("0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(0l));
-    assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1000l));
-    assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1999l));
-    assertEquals("2 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(2001l));
-    assertEquals("45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(45000l));
-    assertEquals("1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 1000l));
-    assertEquals("1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(61 * 1000l));
-    assertEquals("1 minute 30 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(90 * 1000l));
-    assertEquals("2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(120 * 1000l));
-    assertEquals("2 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(121 * 1000l));
-    assertEquals("2 minutes 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(135 * 1000l));
-    assertEquals("1 hour 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l));
-    assertEquals("1 hour 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 1000l));
-    assertEquals("1 hour 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 15000l));
-    assertEquals("1 hour 1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l));
-    assertEquals("1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 1000l));
-    assertEquals("1 hour 1 minute 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 45000l));
-    assertEquals("1 hour 2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 62 * 1000l));
-    assertEquals("1 hour 5 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 1000l));
-    assertEquals("1 hour 5 minutes 10 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 10000l));
-    assertEquals("1 hour 59 minutes 11 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 119 * 1000l + 11000l));
-    assertEquals("1 day 1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
-      TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(1) + TimeUnit.SECONDS.toMillis(1)));
-    assertEquals("1 day 5 hours 15 minutes 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
-      TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(5) + TimeUnit.MINUTES.toMillis(15) + TimeUnit.SECONDS.toMillis(45)));
-    assertEquals("2 days 1 hour 30 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
-      TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
-  }
-
-  protected static final class FakeServiceLauncher extends AbstractLauncher<String> {
-
-    private final String memberId;
-    private final String memberName;
-
-    public FakeServiceLauncher(final String memberName, final String memberId) {
-      this.memberId = memberId;
-      this.memberName = memberName;
-    }
-
-    @Override
-    boolean isAttachAPIOnClasspath() {
-      return false;
-    }
-
-    @Override
-    public String getLogFileName() {
-      throw new UnsupportedOperationException("Not Implemented!");
-    }
-
-    @Override
-    public String getMemberId() {
-      return memberId;
-    }
-
-    @Override
-    public String getMemberName() {
-      return memberName;
-    }
-
-    @Override
-    public Integer getPid() {
-      throw new UnsupportedOperationException("Not Implemented!");
-    }
-
-    @Override
-    public String getServiceName() {
-      return "TestService";
-    }
-
-    @Override
-    public void run() {
-      throw new UnsupportedOperationException("Not Implemented!");
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTestCase.java
deleted file mode 100755
index 77961e0..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTestCase.java
+++ /dev/null
@@ -1,254 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.logging.log4j.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.rules.TestName;
-
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.FileUtil;
-import com.gemstone.gemfire.internal.lang.StringUtils;
-import com.gemstone.gemfire.internal.logging.LogService;
-import com.gemstone.gemfire.internal.process.PidUnavailableException;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.internal.process.ProcessStreamReader.InputListener;
-import com.gemstone.gemfire.internal.util.IOUtils;
-import com.gemstone.gemfire.internal.util.StopWatch;
-
-/**
- * @since 8.0
- */
-public abstract class AbstractLauncherJUnitTestCase {
-  protected static final Logger logger = LogService.getLogger();
-  
-  protected static final int WAIT_FOR_PROCESS_TO_DIE_TIMEOUT = 5 * 60 * 1000; // 5 minutes
-  protected static final int TIMEOUT_MILLISECONDS = WAIT_FOR_PROCESS_TO_DIE_TIMEOUT;
-  protected static final int WAIT_FOR_FILE_CREATION_TIMEOUT = 10*1000;
-  protected static final int WAIT_FOR_FILE_DELETION_TIMEOUT = 10*1000;
-  protected static final int WAIT_FOR_MBEAN_TIMEOUT = 10*1000;
-  protected static final int INTERVAL = 100;
-  protected static final int INTERVAL_MILLISECONDS = INTERVAL;
-  
-  private static final String EXPECTED_EXCEPTION_ADD = "<ExpectedException action=add>{}</ExpectedException>";
-  private static final String EXPECTED_EXCEPTION_REMOVE = "<ExpectedException action=remove>{}</ExpectedException>";
-  private static final String EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED = "MBean Not Registered In GemFire Domain";
-  
-  protected volatile ServerSocket socket;
-  
-  protected volatile File pidFile;
-  protected volatile File stopRequestFile;
-  protected volatile File statusRequestFile;
-  protected volatile File statusFile;
-  
-  @Rule
-  public TestName testName= new TestName();
-
-  @Rule
-  public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Before
-  public final void setUpLauncherTest() throws Exception {
-    System.setProperty("gemfire." + DistributionConfig.MCAST_PORT_NAME, Integer.toString(0));
-    logger.info(EXPECTED_EXCEPTION_ADD, EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
-  }
-
-  @After
-  public final void tearDownLauncherTest() throws Exception {    
-    logger.info(EXPECTED_EXCEPTION_REMOVE, EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED);
-    if (this.socket != null) {
-      this.socket.close();
-      this.socket = null;
-    }
-    delete(this.pidFile); this.pidFile = null;
-    delete(this.stopRequestFile); this.stopRequestFile = null;
-    delete(this.statusRequestFile); this.statusRequestFile = null;
-    delete(this.statusFile); this.statusFile = null;
-  }
-  
-  protected void delete(final File file) throws Exception {
-    assertEventuallyTrue("deleting " + file, new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        if (file == null) {
-          return true;
-        }
-        try {
-          FileUtil.delete(file);
-        } catch (IOException e) {
-        }
-        return !file.exists();
-      }
-    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
-  }
-  
-  protected void waitForPidToStop(final int pid, boolean throwOnTimeout) throws Exception {
-    assertEventuallyFalse("Process never died", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return ProcessUtils.isProcessAlive(pid);
-      }
-    }, WAIT_FOR_PROCESS_TO_DIE_TIMEOUT, INTERVAL);
-  }
-  
-  protected void waitForPidToStop(final int pid) throws Exception {
-    waitForPidToStop(pid, true);
-  }
-  
-  protected void waitForFileToDelete(final File file, boolean throwOnTimeout) throws Exception {
-    if (file == null) {
-      return;
-    }
-    assertEventuallyTrue("waiting for file " + file + " to delete", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return !file.exists();
-      }
-    }, WAIT_FOR_FILE_DELETION_TIMEOUT, INTERVAL);
-  }
-  
-  protected void waitForFileToDelete(final File file) throws Exception {
-    waitForFileToDelete(file, true);
-  }
-  
-  protected static int getPid() throws PidUnavailableException {
-    return ProcessUtils.identifyPid();
-  }
-
-  protected InputListener createLoggingListener(final String name, final String header) {
-    return new InputListener() {
-      @Override
-      public void notifyInputLine(String line) {
-        logger.info(new StringBuilder("[").append(header).append("]").append(line).toString());
-      }
-      @Override
-      public String toString() {
-        return name;
-      }
-    };
-  }
-
-  protected InputListener createCollectionListener(final String name, final String header, final List<String> lines) {
-    return new InputListener() {
-      @Override
-      public void notifyInputLine(String line) {
-        lines.add(line);
-      }
-      @Override
-      public String toString() {
-        return name;
-      }
-    };
-  }
-
-  protected InputListener createExpectedListener(final String name, final String header, final String expected, final AtomicBoolean atomic) {
-    return new InputListener() {
-      @Override
-      public void notifyInputLine(String line) {
-        if (line.contains(expected)) {
-          atomic.set(true);
-        }
-      }
-      @Override
-      public String toString() {
-        return name;
-      }
-    };
-  }
-
-  protected void writeGemfireProperties(final Properties gemfireProperties, final File gemfirePropertiesFile) throws IOException {
-    if (!gemfirePropertiesFile.exists()) {
-      gemfireProperties.store(new FileWriter(gemfirePropertiesFile), "Configuration settings for the GemFire Server");
-    }
-  }
-
-  protected int readPid(final File pidFile) throws IOException {
-    BufferedReader reader = null;
-    try {
-      reader = new BufferedReader(new FileReader(pidFile));
-      return Integer.parseInt(StringUtils.trim(reader.readLine()));
-    }
-    finally {
-      IOUtils.close(reader);
-    }
-  }
-
-  protected void writePid(final File pidFile, final int pid) throws IOException {
-    FileWriter writer = new FileWriter(pidFile);
-    writer.write(String.valueOf(pid));
-    writer.write("\n");
-    writer.flush();
-    writer.close();
-  }
-
-  protected void waitForFileToExist(final File file, boolean throwOnTimeout) throws Exception {
-    assertEventuallyTrue("waiting for file " + file + " to exist", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        return file.exists();
-      }
-    }, WAIT_FOR_FILE_CREATION_TIMEOUT, INTERVAL);
-  }
-  
-  protected void waitForFileToExist(final File file) throws Exception {
-    waitForFileToExist(file, true);
-  }
-  
-  protected String getUniqueName() {
-    return getClass().getSimpleName() + "_" + testName.getMethodName();
-  }
-  
-  protected static void assertEventuallyTrue(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
-    boolean done = false;
-    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (callable.call())) {
-      Thread.sleep(interval);
-    }
-    assertTrue(message, done);
-  }
-  
-  protected static void assertEventuallyFalse(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
-    boolean done = false;
-    for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (!callable.call())) {
-      Thread.sleep(interval);
-    }
-    assertTrue(message, done);
-  }
-  
-  protected static void disconnectFromDS() {
-    InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance();
-    if (ids != null) {
-      ids.disconnect();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusJUnitTest.java
deleted file mode 100755
index ca24a4e..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusJUnitTest.java
+++ /dev/null
@@ -1,264 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.List;
-
-import com.gemstone.gemfire.distributed.AbstractLauncherServiceStatusJUnitTest.TestLauncher.TestState;
-import com.gemstone.gemfire.internal.GemFireVersion;
-import com.gemstone.gemfire.internal.process.PidUnavailableException;
-import com.gemstone.gemfire.internal.process.ProcessUtils;
-import com.gemstone.gemfire.management.internal.cli.json.GfJsonArray;
-import com.gemstone.gemfire.management.internal.cli.json.GfJsonException;
-import com.gemstone.gemfire.management.internal.cli.json.GfJsonObject;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * Tests marshaling of ServiceStatus to and from JSON.
- * 
- * @since 7.0
- */
-@Category(UnitTest.class)
-public class AbstractLauncherServiceStatusJUnitTest {
-
-  private static final String SERVICE_NAME = "Test";
-  private static final InetAddress HOST = getLocalHost();
-  private static final int PORT = 12345;
-  private static final String NAME = AbstractLauncherServiceStatusJUnitTest.class.getSimpleName();
-  private static final int PID = identifyPid();
-  private static final long UPTIME = 123456789;
-  private static final String WORKING_DIRECTORY = identifyWorkingDirectory();
-  private static final List<String> JVM_ARGUMENTS = ManagementFactory.getRuntimeMXBean().getInputArguments();
-  private static final String CLASSPATH = ManagementFactory.getRuntimeMXBean().getClassPath();
-  private static final String GEMFIRE_VERSION = GemFireVersion.getGemFireVersion();
-  private static final String JAVA_VERSION = System.getProperty("java.version");
-
-  private TestLauncher launcher;
-
-  @Before
-  public void setUp() {
-    this.launcher = new TestLauncher(HOST, PORT, NAME);
-  }
-
-  @Test
-  public void testMarshallingTestStatusToAndFromJson() {
-    final TestState status = this.launcher.status();
-    final String json = status.toJson();
-    validateJson(status, json);
-    validateStatus(status, TestState.fromJson(json));
-  }
-
-  private void validateStatus(final TestState expected, final TestState actual) {
-    assertEquals(expected.getClasspath(), actual.getClasspath());
-    assertEquals(expected.getGemFireVersion(), actual.getGemFireVersion());
-    assertEquals(expected.getJavaVersion(), actual.getJavaVersion());
-    assertEquals(expected.getJvmArguments(), actual.getJvmArguments());
-    assertEquals(expected.getPid(), actual.getPid());
-    assertEquals(expected.getStatus(), actual.getStatus());
-    assertEquals(expected.getTimestamp(), actual.getTimestamp());
-    assertEquals(expected.getUptime(), actual.getUptime());
-    assertEquals(expected.getWorkingDirectory(), actual.getWorkingDirectory());
-    assertEquals(expected.getHost(), actual.getHost());
-    assertEquals(expected.getPort(), actual.getPort());
-    assertEquals(expected.getMemberName(), actual.getMemberName());
-  }
-
-  private void validateJson(final TestState expected, final String json) {
-    final TestState actual = TestState.fromJson(json);
-    validateStatus(expected, actual);
-  }
-
-  private static int identifyPid() {
-    try {
-      return ProcessUtils.identifyPid();
-    }
-    catch (PidUnavailableException e) {
-      return 0;
-    }
-  }
-
-  private static String identifyWorkingDirectory() {
-    try {
-      return new File(System.getProperty("user.dir")).getCanonicalPath();
-    }
-    catch (IOException e) {
-      return new File(System.getProperty("user.dir")).getAbsolutePath();
-    }
-  }
-
-  private static InetAddress getLocalHost() {
-    try {
-      return InetAddress.getLocalHost();
-    }
-    catch (UnknownHostException e) {
-      return null;
-    }
-  }
-  
-  static class TestLauncher extends AbstractLauncher<String> {
-
-    private final InetAddress bindAddress;
-    private final int port;
-    private final String memberName;
-    private final File logFile;
-
-    TestLauncher(InetAddress bindAddress,
-                 int port,
-                 String memberName) {
-      this.bindAddress = bindAddress;
-      this.port = port;
-      this.memberName = memberName;
-      this.logFile = new File(memberName + ".log");
-    }
-
-    public TestState status() {
-      return new TestState(Status.ONLINE,
-        null,
-        System.currentTimeMillis(),
-        getId(),
-        PID,
-        UPTIME,
-        WORKING_DIRECTORY,
-        JVM_ARGUMENTS,
-        CLASSPATH,
-        GEMFIRE_VERSION,
-        JAVA_VERSION,
-        getLogFileName(),
-        getBindAddressAsString(),
-        getPortAsString(),
-        NAME);
-    }
-
-    @Override
-    public void run() {
-    }
-
-    public String getId() {
-      return getServiceName() + "@" + getBindAddress() + "[" + getPort() + "]";
-    }
-
-    @Override
-    public String getLogFileName() {
-      try {
-        return this.logFile.getCanonicalPath();
-      }
-      catch (IOException e) {
-        return this.logFile.getAbsolutePath();
-      }
-    }
-
-    @Override
-    public String getMemberName() {
-      return this.memberName;
-    }
-
-    @Override
-    public Integer getPid() {
-      return null;
-    }
-
-    @Override
-    public String getServiceName() {
-      return SERVICE_NAME;
-    }
-
-    InetAddress getBindAddress() {
-      return this.bindAddress;
-    }
-
-    String getBindAddressAsString() {
-      return this.bindAddress.getCanonicalHostName();
-    }
-
-    int getPort() {
-      return this.port;
-    }
-
-    String getPortAsString() {
-      return String.valueOf(getPort());
-    }
-
-    public static class TestState extends ServiceState<String> {
-
-      protected static TestState fromJson(final String json) {
-        try {
-          final GfJsonObject gfJsonObject = new GfJsonObject(json);
-
-          final Status status = Status.valueOfDescription(gfJsonObject.getString(JSON_STATUS));
-          final List<String> jvmArguments =
-            Arrays.asList(GfJsonArray.toStringArray(gfJsonObject.getJSONArray(JSON_JVMARGUMENTS)));
-
-          return new TestState(status,
-            gfJsonObject.getString(JSON_STATUSMESSAGE),
-            gfJsonObject.getLong(JSON_TIMESTAMP),
-            gfJsonObject.getString(JSON_LOCATION),
-            gfJsonObject.getInt(JSON_PID),
-            gfJsonObject.getLong(JSON_UPTIME),
-            gfJsonObject.getString(JSON_WORKINGDIRECTORY),
-            jvmArguments,
-            gfJsonObject.getString(JSON_CLASSPATH),
-            gfJsonObject.getString(JSON_GEMFIREVERSION),
-            gfJsonObject.getString(JSON_JAVAVERSION),
-            gfJsonObject.getString(JSON_LOGFILE),
-            gfJsonObject.getString(JSON_HOST),
-            gfJsonObject.getString(JSON_PORT),
-            gfJsonObject.getString(JSON_MEMBERNAME));
-        }
-        catch (GfJsonException e) {
-          throw new IllegalArgumentException("Unable to create TestState from JSON: " + json);
-        }
-      }
-
-      protected TestState(final Status status,
-                          final String statusMessage,
-                          final long timestamp,
-                          final String location,
-                          final Integer pid,
-                          final Long uptime,
-                          final String workingDirectory,
-                          final List<String> jvmArguments,
-                          final String classpath,
-                          final String gemfireVersion,
-                          final String javaVersion,
-                          final String logFile,
-                          final String host,
-                          final String port,
-                          final String name) {
-        super(status, statusMessage, timestamp, location, pid, uptime, workingDirectory, jvmArguments, classpath,
-          gemfireVersion, javaVersion, logFile, host, port, name);
-      }
-
-      @Override
-      protected String getServiceName() {
-        return SERVICE_NAME;
-      }
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
new file mode 100755
index 0000000..a0c381e
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherServiceStatusTest.java
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.List;
+
+import com.gemstone.gemfire.distributed.AbstractLauncherServiceStatusTest.TestLauncher.TestState;
+import com.gemstone.gemfire.internal.GemFireVersion;
+import com.gemstone.gemfire.internal.process.PidUnavailableException;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.management.internal.cli.json.GfJsonArray;
+import com.gemstone.gemfire.management.internal.cli.json.GfJsonException;
+import com.gemstone.gemfire.management.internal.cli.json.GfJsonObject;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Tests marshaling of ServiceStatus to and from JSON.
+ * 
+ * @since 7.0
+ */
+@Category(UnitTest.class)
+public class AbstractLauncherServiceStatusTest {
+
+  private static final String SERVICE_NAME = "Test";
+  private static final InetAddress HOST = getLocalHost();
+  private static final int PORT = 12345;
+  private static final String NAME = AbstractLauncherServiceStatusTest.class.getSimpleName();
+  private static final int PID = identifyPid();
+  private static final long UPTIME = 123456789;
+  private static final String WORKING_DIRECTORY = identifyWorkingDirectory();
+  private static final List<String> JVM_ARGUMENTS = ManagementFactory.getRuntimeMXBean().getInputArguments();
+  private static final String CLASSPATH = ManagementFactory.getRuntimeMXBean().getClassPath();
+  private static final String GEMFIRE_VERSION = GemFireVersion.getGemFireVersion();
+  private static final String JAVA_VERSION = System.getProperty("java.version");
+
+  private TestLauncher launcher;
+
+  @Before
+  public void setUp() {
+    this.launcher = new TestLauncher(HOST, PORT, NAME);
+  }
+
+  @Test
+  public void testMarshallingTestStatusToAndFromJson() {
+    final TestState status = this.launcher.status();
+    final String json = status.toJson();
+    validateJson(status, json);
+    validateStatus(status, TestState.fromJson(json));
+  }
+
+  private void validateStatus(final TestState expected, final TestState actual) {
+    assertEquals(expected.getClasspath(), actual.getClasspath());
+    assertEquals(expected.getGemFireVersion(), actual.getGemFireVersion());
+    assertEquals(expected.getJavaVersion(), actual.getJavaVersion());
+    assertEquals(expected.getJvmArguments(), actual.getJvmArguments());
+    assertEquals(expected.getPid(), actual.getPid());
+    assertEquals(expected.getStatus(), actual.getStatus());
+    assertEquals(expected.getTimestamp(), actual.getTimestamp());
+    assertEquals(expected.getUptime(), actual.getUptime());
+    assertEquals(expected.getWorkingDirectory(), actual.getWorkingDirectory());
+    assertEquals(expected.getHost(), actual.getHost());
+    assertEquals(expected.getPort(), actual.getPort());
+    assertEquals(expected.getMemberName(), actual.getMemberName());
+  }
+
+  private void validateJson(final TestState expected, final String json) {
+    final TestState actual = TestState.fromJson(json);
+    validateStatus(expected, actual);
+  }
+
+  private static int identifyPid() {
+    try {
+      return ProcessUtils.identifyPid();
+    }
+    catch (PidUnavailableException e) {
+      return 0;
+    }
+  }
+
+  private static String identifyWorkingDirectory() {
+    try {
+      return new File(System.getProperty("user.dir")).getCanonicalPath();
+    }
+    catch (IOException e) {
+      return new File(System.getProperty("user.dir")).getAbsolutePath();
+    }
+  }
+
+  private static InetAddress getLocalHost() {
+    try {
+      return InetAddress.getLocalHost();
+    }
+    catch (UnknownHostException e) {
+      return null;
+    }
+  }
+  
+  static class TestLauncher extends AbstractLauncher<String> {
+
+    private final InetAddress bindAddress;
+    private final int port;
+    private final String memberName;
+    private final File logFile;
+
+    TestLauncher(InetAddress bindAddress,
+                 int port,
+                 String memberName) {
+      this.bindAddress = bindAddress;
+      this.port = port;
+      this.memberName = memberName;
+      this.logFile = new File(memberName + ".log");
+    }
+
+    public TestState status() {
+      return new TestState(Status.ONLINE,
+        null,
+        System.currentTimeMillis(),
+        getId(),
+        PID,
+        UPTIME,
+        WORKING_DIRECTORY,
+        JVM_ARGUMENTS,
+        CLASSPATH,
+        GEMFIRE_VERSION,
+        JAVA_VERSION,
+        getLogFileName(),
+        getBindAddressAsString(),
+        getPortAsString(),
+        NAME);
+    }
+
+    @Override
+    public void run() {
+    }
+
+    public String getId() {
+      return getServiceName() + "@" + getBindAddress() + "[" + getPort() + "]";
+    }
+
+    @Override
+    public String getLogFileName() {
+      try {
+        return this.logFile.getCanonicalPath();
+      }
+      catch (IOException e) {
+        return this.logFile.getAbsolutePath();
+      }
+    }
+
+    @Override
+    public String getMemberName() {
+      return this.memberName;
+    }
+
+    @Override
+    public Integer getPid() {
+      return null;
+    }
+
+    @Override
+    public String getServiceName() {
+      return SERVICE_NAME;
+    }
+
+    InetAddress getBindAddress() {
+      return this.bindAddress;
+    }
+
+    String getBindAddressAsString() {
+      return this.bindAddress.getCanonicalHostName();
+    }
+
+    int getPort() {
+      return this.port;
+    }
+
+    String getPortAsString() {
+      return String.valueOf(getPort());
+    }
+
+    public static class TestState extends ServiceState<String> {
+
+      protected static TestState fromJson(final String json) {
+        try {
+          final GfJsonObject gfJsonObject = new GfJsonObject(json);
+
+          final Status status = Status.valueOfDescription(gfJsonObject.getString(JSON_STATUS));
+          final List<String> jvmArguments =
+            Arrays.asList(GfJsonArray.toStringArray(gfJsonObject.getJSONArray(JSON_JVMARGUMENTS)));
+
+          return new TestState(status,
+            gfJsonObject.getString(JSON_STATUSMESSAGE),
+            gfJsonObject.getLong(JSON_TIMESTAMP),
+            gfJsonObject.getString(JSON_LOCATION),
+            gfJsonObject.getInt(JSON_PID),
+            gfJsonObject.getLong(JSON_UPTIME),
+            gfJsonObject.getString(JSON_WORKINGDIRECTORY),
+            jvmArguments,
+            gfJsonObject.getString(JSON_CLASSPATH),
+            gfJsonObject.getString(JSON_GEMFIREVERSION),
+            gfJsonObject.getString(JSON_JAVAVERSION),
+            gfJsonObject.getString(JSON_LOGFILE),
+            gfJsonObject.getString(JSON_HOST),
+            gfJsonObject.getString(JSON_PORT),
+            gfJsonObject.getString(JSON_MEMBERNAME));
+        }
+        catch (GfJsonException e) {
+          throw new IllegalArgumentException("Unable to create TestState from JSON: " + json);
+        }
+      }
+
+      protected TestState(final Status status,
+                          final String statusMessage,
+                          final long timestamp,
+                          final String location,
+                          final Integer pid,
+                          final Long uptime,
+                          final String workingDirectory,
+                          final List<String> jvmArguments,
+                          final String classpath,
+                          final String gemfireVersion,
+                          final String javaVersion,
+                          final String logFile,
+                          final String host,
+                          final String port,
+                          final String name) {
+        super(status, statusMessage, timestamp, location, pid, uptime, workingDirectory, jvmArguments, classpath,
+          gemfireVersion, javaVersion, logFile, host, port, name);
+      }
+
+      @Override
+      protected String getServiceName() {
+        return SERVICE_NAME;
+      }
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
new file mode 100644
index 0000000..02bfa00
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherTest.java
@@ -0,0 +1,298 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.lang.StringUtils;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * The AbstractLauncherTest class is a test suite of unit tests testing the contract and functionality
+ * of the AbstractLauncher class.
+ * <p/>
+ * @see com.gemstone.gemfire.distributed.AbstractLauncher
+ * @see org.junit.Assert
+ * @see org.junit.Test
+ * @since 7.0
+ */
+@Category(UnitTest.class)
+public class AbstractLauncherTest {
+
+  protected AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
+    return new FakeServiceLauncher(memberName, memberId);
+  }
+
+  @Test
+  public void testIsAttachAPINotFound() {
+    final AbstractLauncher<?> launcher = createAbstractLauncher("012", "TestMember");
+
+    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException")));
+    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
+      "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
+    assertTrue(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/ibm/tools/attach/AgentNotSupportedException")));
+    assertTrue(launcher.isAttachAPINotFound(new ClassNotFoundException(
+      "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
+    assertFalse(launcher.isAttachAPINotFound(new IllegalArgumentException(
+      "Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException")));
+    assertFalse(launcher.isAttachAPINotFound(new IllegalStateException(
+      "Caused by: java.lang.ClassNotFoundException: com.ibm.tools.attach.AgentNotSupportedException")));
+    assertFalse(launcher.isAttachAPINotFound(new NoClassDefFoundError(
+      "Exception in thread \"main\" java.lang.NoClassDefFoundError: com/companyx/app/service/MyServiceClass")));
+    assertFalse(launcher.isAttachAPINotFound(new ClassNotFoundException(
+      "Caused by: java.lang.ClassNotFoundException: com.companyx.app.attach.NutsNotAttachedException")));
+  }
+
+  @Test
+  public void testIsSet() {
+    final Properties properties = new Properties();
+
+    assertFalse(properties.containsKey(DistributionConfig.NAME_NAME));
+    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+
+    properties.setProperty(DistributionConfig.NAME_NAME, "");
+
+    assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
+    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+
+    properties.setProperty(DistributionConfig.NAME_NAME, "  ");
+
+    assertTrue(properties.containsKey(DistributionConfig.NAME_NAME));
+    assertFalse(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+
+    properties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
+
+    assertTrue(AbstractLauncher.isSet(properties, DistributionConfig.NAME_NAME));
+    assertFalse(AbstractLauncher.isSet(properties, "NaMe"));
+  }
+
+  @Test
+  public void testLoadGemFirePropertiesWithNullURL() {
+    final Properties properties = AbstractLauncher.loadGemFireProperties(null);
+    assertNotNull(properties);
+    assertTrue(properties.isEmpty());
+  }
+
+  @Test
+  public void testLoadGemFirePropertiesWithNonExistingURL() throws MalformedURLException {
+    final Properties properties = AbstractLauncher.loadGemFireProperties(new URL("file:///path/to/non_existing/gemfire.properties"));
+    assertNotNull(properties);
+    assertTrue(properties.isEmpty());
+  }
+
+  @Test
+  public void testGetDistributedSystemProperties() {
+    AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "1");
+
+    assertNotNull(launcher);
+    assertEquals("1", launcher.getMemberId());
+    assertEquals("memberOne", launcher.getMemberName());
+
+    Properties distributedSystemProperties = launcher.getDistributedSystemProperties();
+
+    assertNotNull(distributedSystemProperties);
+    assertTrue(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+    assertEquals("memberOne", distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
+
+    launcher = createAbstractLauncher(null, "22");
+
+    assertNotNull(launcher);
+    assertEquals("22", launcher.getMemberId());
+    assertNull(launcher.getMemberName());
+
+    distributedSystemProperties = launcher.getDistributedSystemProperties();
+
+    assertNotNull(distributedSystemProperties);
+    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+
+    launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "333");
+
+    assertNotNull(launcher);
+    assertEquals("333", launcher.getMemberId());
+    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+
+    distributedSystemProperties = launcher.getDistributedSystemProperties();
+
+    assertNotNull(distributedSystemProperties);
+    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+
+    launcher = createAbstractLauncher("  ", "4444");
+
+    assertNotNull(launcher);
+    assertEquals("4444", launcher.getMemberId());
+    assertEquals("  ", launcher.getMemberName());
+
+    distributedSystemProperties = launcher.getDistributedSystemProperties();
+
+    assertNotNull(distributedSystemProperties);
+    assertFalse(distributedSystemProperties.containsKey(DistributionConfig.NAME_NAME));
+  }
+
+  @Test
+  public void testGetDistributedSystemPropertiesWithDefaults() {
+    AbstractLauncher<?> launcher = createAbstractLauncher("TestMember", "123");
+
+    assertNotNull(launcher);
+    assertEquals("123", launcher.getMemberId());
+    assertEquals("TestMember", launcher.getMemberName());
+
+    Properties defaults = new Properties();
+
+    defaults.setProperty("testKey", "testValue");
+
+    Properties distributedSystemProperties = launcher.getDistributedSystemProperties(defaults);
+
+    assertNotNull(distributedSystemProperties);
+    assertEquals(launcher.getMemberName(), distributedSystemProperties.getProperty(DistributionConfig.NAME_NAME));
+    assertEquals("testValue", distributedSystemProperties.getProperty("testKey"));
+  }
+
+  @Test
+  public void testGetMember() {
+    AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "123");
+
+    assertNotNull(launcher);
+    assertEquals("123", launcher.getMemberId());
+    assertEquals("memberOne", launcher.getMemberName());
+    assertEquals("memberOne", launcher.getMember());
+
+    launcher = createAbstractLauncher(null, "123");
+
+    assertNotNull(launcher);
+    assertEquals("123", launcher.getMemberId());
+    assertNull(launcher.getMemberName());
+    assertEquals("123", launcher.getMember());
+
+    launcher = createAbstractLauncher(StringUtils.EMPTY_STRING, "123");
+
+    assertNotNull(launcher);
+    assertEquals("123", launcher.getMemberId());
+    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberName());
+    assertEquals("123", launcher.getMember());
+
+    launcher = createAbstractLauncher(" ", "123");
+
+    assertNotNull(launcher);
+    assertEquals("123", launcher.getMemberId());
+    assertEquals(" ", launcher.getMemberName());
+    assertEquals("123", launcher.getMember());
+
+    launcher = createAbstractLauncher(null, StringUtils.EMPTY_STRING);
+
+    assertNotNull(launcher);
+    assertEquals(StringUtils.EMPTY_STRING, launcher.getMemberId());
+    assertNull(launcher.getMemberName());
+    assertNull(launcher.getMember());
+
+    launcher = createAbstractLauncher(null, " ");
+
+    assertNotNull(launcher);
+    assertEquals(" ", launcher.getMemberId());
+    assertNull(launcher.getMemberName());
+    assertNull(launcher.getMember());
+  }
+
+  @Test
+  public void testAbstractLauncherServiceStateToDaysHoursMinutesSeconds() {
+    assertEquals("", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(null));
+    assertEquals("0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(0l));
+    assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1000l));
+    assertEquals("1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(1999l));
+    assertEquals("2 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(2001l));
+    assertEquals("45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(45000l));
+    assertEquals("1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 1000l));
+    assertEquals("1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(61 * 1000l));
+    assertEquals("1 minute 30 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(90 * 1000l));
+    assertEquals("2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(120 * 1000l));
+    assertEquals("2 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(121 * 1000l));
+    assertEquals("2 minutes 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(135 * 1000l));
+    assertEquals("1 hour 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l));
+    assertEquals("1 hour 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 1000l));
+    assertEquals("1 hour 15 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 60 * 1000l + 15000l));
+    assertEquals("1 hour 1 minute 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l));
+    assertEquals("1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 1000l));
+    assertEquals("1 hour 1 minute 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 61 * 1000l + 45000l));
+    assertEquals("1 hour 2 minutes 0 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 62 * 1000l));
+    assertEquals("1 hour 5 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 1000l));
+    assertEquals("1 hour 5 minutes 10 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 65 * 1000l + 10000l));
+    assertEquals("1 hour 59 minutes 11 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(60 * 119 * 1000l + 11000l));
+    assertEquals("1 day 1 hour 1 minute 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+      TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(1) + TimeUnit.SECONDS.toMillis(1)));
+    assertEquals("1 day 5 hours 15 minutes 45 seconds", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+      TimeUnit.DAYS.toMillis(1) + TimeUnit.HOURS.toMillis(5) + TimeUnit.MINUTES.toMillis(15) + TimeUnit.SECONDS.toMillis(45)));
+    assertEquals("2 days 1 hour 30 minutes 1 second", AbstractLauncher.ServiceState.toDaysHoursMinutesSeconds(
+      TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
+  }
+
+  protected static final class FakeServiceLauncher extends AbstractLauncher<String> {
+
+    private final String memberId;
+    private final String memberName;
+
+    public FakeServiceLauncher(final String memberName, final String memberId) {
+      this.memberId = memberId;
+      this.memberName = memberName;
+    }
+
+    @Override
+    boolean isAttachAPIOnClasspath() {
+      return false;
+    }
+
+    @Override
+    public String getLogFileName() {
+      throw new UnsupportedOperationException("Not Implemented!");
+    }
+
+    @Override
+    public String getMemberId() {
+      return memberId;
+    }
+
+    @Override
+    public String getMemberName() {
+      return memberName;
+    }
+
+    @Override
+    public Integer getPid() {
+      throw new UnsupportedOperationException("Not Implemented!");
+    }
+
+    @Override
+    public String getServiceName() {
+      return "TestService";
+    }
+
+    @Override
+    public void run() {
+      throw new UnsupportedOperationException("Not Implemented!");
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
new file mode 100755
index 0000000..93c18d1
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherIntegrationTestCase.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.ErrorCollector;
+import org.junit.rules.TemporaryFolder;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
+import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.DistributionLocator;
+
+/**
+ * @since 8.0
+ */
+public abstract class AbstractLocatorLauncherIntegrationTestCase extends AbstractLauncherIntegrationTestCase {
+
+  protected volatile int locatorPort;
+  protected volatile LocatorLauncher launcher;
+  
+  @Rule
+  public ErrorCollector errorCollector = new ErrorCollector();
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public final void setUpAbstractLocatorLauncherIntegrationTestCase() throws Exception {
+    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
+    System.setProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
+    this.locatorPort = port;
+  }
+  
+  @After
+  public final void tearDownAbstractLocatorLauncherIntegrationTestCase() throws Exception {
+    this.locatorPort = 0;
+    if (this.launcher != null) {
+      this.launcher.stop();
+      this.launcher = null;
+    }
+  }
+  
+  protected void waitForLocatorToStart(final LocatorLauncher launcher, int timeout, int interval, boolean throwOnTimeout) throws Exception {
+    assertEventuallyTrue("waiting for process to start: " + launcher.status(), new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        try {
+          final LocatorState LocatorState = launcher.status();
+          return (LocatorState != null && Status.ONLINE.equals(LocatorState.getStatus()));
+        }
+        catch (RuntimeException e) {
+          return false;
+        }
+      }
+    }, timeout, interval);
+  }
+  
+  protected void waitForLocatorToStart(final LocatorLauncher launcher, int timeout, boolean throwOnTimeout) throws Exception {
+    waitForLocatorToStart(launcher, timeout, INTERVAL_MILLISECONDS, throwOnTimeout);
+  }
+  
+  protected void waitForLocatorToStart(final LocatorLauncher launcher, boolean throwOnTimeout) throws Exception {
+    waitForLocatorToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, throwOnTimeout);
+  }
+  
+  protected void waitForLocatorToStart(final LocatorLauncher launcher) throws Exception {
+    waitForLocatorToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, true);
+  }
+  
+  protected static void waitForLocatorToStart(int port, int timeout, int interval, boolean throwOnTimeout) throws Exception {
+    final LocatorLauncher locatorLauncher = new Builder().setPort(port).build();
+    assertEventuallyTrue("Waiting for Locator in other process to start.", new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        try {
+          final LocatorState locatorState = locatorLauncher.status();
+          return (locatorState != null && Status.ONLINE.equals(locatorState.getStatus()));
+        }
+        catch (RuntimeException e) {
+          return false;
+        }
+      }
+    }, timeout, interval);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherJUnitTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherJUnitTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherJUnitTestCase.java
deleted file mode 100755
index 62c4d86..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLocatorLauncherJUnitTestCase.java
+++ /dev/null
@@ -1,105 +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 com.gemstone.gemfire.distributed;
-
-import java.util.concurrent.Callable;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.ErrorCollector;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
-import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.DistributionLocator;
-
-/**
- * @since 8.0
- */
-public abstract class AbstractLocatorLauncherJUnitTestCase extends AbstractLauncherJUnitTestCase {
-
-  protected volatile int locatorPort;
-  protected volatile LocatorLauncher launcher;
-  
-  @Rule
-  public ErrorCollector errorCollector = new ErrorCollector();
-
-  @Rule
-  public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-  @Before
-  public final void setUpLocatorLauncherTest() throws Exception {
-    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
-    System.setProperty(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
-    this.locatorPort = port;
-  }
-  
-  @After
-  public final void tearDownLocatorLauncherTest() throws Exception {    
-    this.locatorPort = 0;
-    if (this.launcher != null) {
-      this.launcher.stop();
-      this.launcher = null;
-    }
-  }
-  
-  protected void waitForLocatorToStart(final LocatorLauncher launcher, int timeout, int interval, boolean throwOnTimeout) throws Exception {
-    assertEventuallyTrue("waiting for process to start: " + launcher.status(), new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        try {
-          final LocatorState LocatorState = launcher.status();
-          return (LocatorState != null && Status.ONLINE.equals(LocatorState.getStatus()));
-        }
-        catch (RuntimeException e) {
-          return false;
-        }
-      }
-    }, timeout, interval);
-  }
-  
-  protected void waitForLocatorToStart(final LocatorLauncher launcher, int timeout, boolean throwOnTimeout) throws Exception {
-    waitForLocatorToStart(launcher, timeout, INTERVAL_MILLISECONDS, throwOnTimeout);
-  }
-  
-  protected void waitForLocatorToStart(final LocatorLauncher launcher, boolean throwOnTimeout) throws Exception {
-    waitForLocatorToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, throwOnTimeout);
-  }
-  
-  protected void waitForLocatorToStart(final LocatorLauncher launcher) throws Exception {
-    waitForLocatorToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, true);
-  }
-  
-  protected static void waitForLocatorToStart(int port, int timeout, int interval, boolean throwOnTimeout) throws Exception {
-    final LocatorLauncher locatorLauncher = new Builder().setPort(port).build();
-    assertEventuallyTrue("Waiting for Locator in other process to start.", new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        try {
-          final LocatorState locatorState = locatorLauncher.status();
-          return (locatorState != null && Status.ONLINE.equals(locatorState.getStatus()));
-        }
-        catch (RuntimeException e) {
-          return false;
-        }
-      }
-    }, timeout, interval);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
new file mode 100755
index 0000000..bbb170c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherIntegrationTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.Callable;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.rules.ErrorCollector;
+import org.junit.rules.TemporaryFolder;
+
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+
+/**
+ * @since 8.0
+ */
+public abstract class AbstractServerLauncherIntegrationTestCase extends AbstractLauncherIntegrationTestCase {
+  
+  protected volatile int serverPort;
+  protected volatile ServerLauncher launcher;
+
+  @Rule
+  public ErrorCollector errorCollector= new ErrorCollector();
+  
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+  @Before
+  public final void setUpServerLauncherTest() throws Exception {
+    System.setProperty("gemfire." + DistributionConfig.MCAST_PORT_NAME, Integer.toString(0));
+    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
+    System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
+    this.serverPort = port;
+  }
+
+  @After
+  public final void tearDownServerLauncherTest() throws Exception {    
+    this.serverPort = 0;
+    if (this.launcher != null) {
+      this.launcher.stop();
+      this.launcher = null;
+    }
+  }
+  
+  protected void waitForServerToStart(final ServerLauncher launcher, int timeout, int interval, boolean throwOnTimeout) throws Exception {
+    assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
+      @Override
+      public Boolean call() throws Exception {
+        try {
+          final ServerState serverState = launcher.status();
+          assertNotNull(serverState);
+          return Status.ONLINE.equals(serverState.getStatus());
+        }
+        catch (RuntimeException e) {
+          return false;
+        }
+      }
+    }, timeout, interval);
+  }
+
+  protected void waitForServerToStart(final ServerLauncher launcher, boolean throwOnTimeout) throws Exception {
+    waitForServerToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, throwOnTimeout);
+  }
+  
+  protected void waitForServerToStart(final ServerLauncher launcher, int timeout, boolean throwOnTimeout) throws Exception {
+    waitForServerToStart(launcher, timeout, INTERVAL_MILLISECONDS, throwOnTimeout);
+  }
+  
+  protected void waitForServerToStart(final ServerLauncher launcher) throws Exception {
+    waitForServerToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, true);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherJUnitTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherJUnitTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherJUnitTestCase.java
deleted file mode 100755
index 0ee3e7c..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/AbstractServerLauncherJUnitTestCase.java
+++ /dev/null
@@ -1,93 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import java.util.concurrent.Callable;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.ErrorCollector;
-import org.junit.rules.TemporaryFolder;
-
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.ServerLauncher.ServerState;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
-
-/**
- * @since 8.0
- */
-public abstract class AbstractServerLauncherJUnitTestCase extends AbstractLauncherJUnitTestCase {
-  
-  protected volatile int serverPort;
-  protected volatile ServerLauncher launcher;
-
-  @Rule
-  public ErrorCollector errorCollector= new ErrorCollector();
-  
-  @Rule
-  public TemporaryFolder temporaryFolder = new TemporaryFolder();
-
-  @Before
-  public final void setUpServerLauncherTest() throws Exception {
-    System.setProperty("gemfire." + DistributionConfig.MCAST_PORT_NAME, Integer.toString(0));
-    final int port = AvailablePortHelper.getRandomAvailableTCPPort();
-    System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(port));
-    this.serverPort = port;
-  }
-
-  @After
-  public final void tearDownServerLauncherTest() throws Exception {    
-    this.serverPort = 0;
-    if (this.launcher != null) {
-      this.launcher.stop();
-      this.launcher = null;
-    }
-  }
-  
-  protected void waitForServerToStart(final ServerLauncher launcher, int timeout, int interval, boolean throwOnTimeout) throws Exception {
-    assertEventuallyTrue("waiting for local Server to start: " + launcher.status(), new Callable<Boolean>() {
-      @Override
-      public Boolean call() throws Exception {
-        try {
-          final ServerState serverState = launcher.status();
-          assertNotNull(serverState);
-          return Status.ONLINE.equals(serverState.getStatus());
-        }
-        catch (RuntimeException e) {
-          return false;
-        }
-      }
-    }, timeout, interval);
-  }
-
-  protected void waitForServerToStart(final ServerLauncher launcher, boolean throwOnTimeout) throws Exception {
-    waitForServerToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, throwOnTimeout);
-  }
-  
-  protected void waitForServerToStart(final ServerLauncher launcher, int timeout, boolean throwOnTimeout) throws Exception {
-    waitForServerToStart(launcher, timeout, INTERVAL_MILLISECONDS, throwOnTimeout);
-  }
-  
-  protected void waitForServerToStart(final ServerLauncher launcher) throws Exception {
-    waitForServerToStart(launcher, TIMEOUT_MILLISECONDS, INTERVAL_MILLISECONDS, true);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedTestSuite.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedTestSuite.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedTestSuite.java
deleted file mode 100755
index 58b8d2a..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/DistributedTestSuite.java
+++ /dev/null
@@ -1,35 +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 com.gemstone.gemfire.distributed;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-   DistributedMemberDUnitTest.class,
-   DistributedSystemDUnitTest.class,
-   LocatorDUnitTest.class,
-   RoleDUnitTest.class,
-   SystemAdminDUnitTest.class
-})
-/**
- * Suite of tests for distributed membership dunit tests.
- * 
- */
-public class DistributedTestSuite {
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
index a5b07ee..2b067d0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
@@ -39,7 +39,7 @@ import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 
 /**
- * Extracted from LocatorLauncherLocalJUnitTest.
+ * Extracted from LocatorLauncherLocalIntegrationTest.
  * 
  * @since 8.0
  */



[02/12] incubator-geode git commit: Fixing tests

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherTest.java
new file mode 100755
index 0000000..c8e1882
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherTest.java
@@ -0,0 +1,903 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collections;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.ServerLauncher.Command;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.distributed.support.DistributedSystemAdapter;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+import edu.umd.cs.mtc.MultithreadedTestCase;
+import edu.umd.cs.mtc.TestFramework;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.concurrent.Synchroniser;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
+
+/**
+ * The ServerLauncherTest class is a test suite of unit tests testing the contract, functionality and invariants
+ * of the ServerLauncher class.
+ *
+ * @see com.gemstone.gemfire.distributed.ServerLauncher
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.Builder
+ * @see com.gemstone.gemfire.distributed.ServerLauncher.Command
+ * @see org.junit.Assert
+ * @see org.junit.Test
+ * @since 7.0
+ */
+@SuppressWarnings({"deprecation", "unused"})
+@Category(UnitTest.class)
+public class ServerLauncherTest {
+
+  private Mockery mockContext;
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TestName testName = new TestName();
+  
+  @Before
+  public void setup() {
+    mockContext = new Mockery() {{
+      setImposteriser(ClassImposteriser.INSTANCE);
+      setThreadingPolicy(new Synchroniser());
+    }};
+  }
+
+  @After
+  public void tearDown() {
+    mockContext.assertIsSatisfied();
+    mockContext = null;
+  }
+
+  @Test
+  public void testParseCommand() {
+    Builder builder = new Builder();
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+
+    builder.parseCommand((String[]) null);
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+
+    builder.parseCommand(); // empty String array
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+
+    builder.parseCommand(Command.START.getName());
+
+    assertEquals(Command.START, builder.getCommand());
+
+    builder.parseCommand("Status");
+
+    assertEquals(Command.STATUS, builder.getCommand());
+
+    builder.parseCommand("sToP");
+
+    assertEquals(Command.STOP, builder.getCommand());
+
+    builder.parseCommand("--opt", "START", "-o", Command.STATUS.getName());
+
+    assertEquals(Command.START, builder.getCommand());
+
+    builder.setCommand(null);
+    builder.parseCommand("badCommandName", "--start", "stat");
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+  }
+
+  @Test
+  public void testParseMemberName() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMemberName());
+
+    builder.parseMemberName((String[]) null);
+
+    assertNull(builder.getMemberName());
+
+    builder.parseMemberName(); // empty String array
+
+    assertNull(builder.getMemberName());
+
+    builder.parseMemberName(Command.START.getName(), "--opt", "-o");
+
+    assertNull(builder.getMemberName());
+
+    builder.parseMemberName("memberOne");
+
+    assertEquals("memberOne", builder.getMemberName());
+  }
+
+  @Test
+  public void testSetAndGetCommand() {
+    Builder builder = new Builder();
+
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+    assertSame(builder, builder.setCommand(Command.STATUS));
+    assertEquals(Command.STATUS, builder.getCommand());
+    assertSame(builder, builder.setCommand(null));
+    assertEquals(Builder.DEFAULT_COMMAND, builder.getCommand());
+  }
+
+  @Test
+  public void testSetAndGetMemberName() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMemberName());
+    assertSame(builder, builder.setMemberName("serverOne"));
+    assertEquals("serverOne", builder.getMemberName());
+    assertSame(builder, builder.setMemberName(null));
+    assertNull(builder.getMemberName());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMemberNameToBlankString() {
+    try {
+      new Builder().setMemberName("  ");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Server"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMemberNameToEmptyString() {
+    try {
+      new Builder().setMemberName("");
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_ERROR_MESSAGE.toLocalizedString("Server"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetPid() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getPid());
+    assertSame(builder, builder.setPid(0));
+    assertEquals(0, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(1));
+    assertEquals(1, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(1024));
+    assertEquals(1024, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(12345));
+    assertEquals(12345, builder.getPid().intValue());
+    assertSame(builder, builder.setPid(null));
+    assertNull(builder.getPid());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetPidToInvalidValue() {
+    try {
+      new Builder().setPid(-1);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_PID_ERROR_MESSAGE.toLocalizedString(), expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetServerBindAddress() throws Exception {
+    Builder builder = new Builder();
+
+    assertNull(builder.getServerBindAddress());
+    assertSame(builder, builder.setServerBindAddress(null));
+    assertNull(builder.getServerBindAddress());
+    assertSame(builder, builder.setServerBindAddress(""));
+    assertNull(builder.getServerBindAddress());
+    assertSame(builder, builder.setServerBindAddress("  "));
+    assertNull(builder.getServerBindAddress());
+    assertSame(builder, builder.setServerBindAddress(InetAddress.getLocalHost().getCanonicalHostName()));
+    assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetServerBindAddressToUnknownHost() {
+    try {
+      new Builder().setServerBindAddress("badHostName.badCompany.com");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage1 = LocalizedStrings.Launcher_Builder_UNKNOWN_HOST_ERROR_MESSAGE.toLocalizedString("Server");
+      final String expectedMessage2 = "badHostName.badCompany.com is not an address for this machine.";
+      assertTrue(expected.getMessage().equals(expectedMessage1) || expected.getMessage().equals(expectedMessage2));
+      if (expected.getMessage().equals(expectedMessage1)) {
+        assertTrue(expected.getCause() instanceof UnknownHostException);
+      }
+      throw expected;
+    }
+  }
+  
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetServerBindAddressToNonLocalHost() {
+    try {
+      new Builder().setServerBindAddress("yahoo.com");
+    }
+    catch (IllegalArgumentException expected) {
+      final String expectedMessage = "yahoo.com is not an address for this machine.";
+      assertEquals(expectedMessage, expected.getMessage());
+      throw expected;
+    }
+  }
+  
+  @Test
+  public void testSetServerBindAddressToLocalHost() throws Exception {
+    String host = InetAddress.getLocalHost().getHostName();            
+    new Builder().setServerBindAddress(host);
+  }
+
+  @Test
+  public void testSetAndGetHostnameForClients() {
+    final Builder builder = new Builder();
+
+    assertNull(builder.getHostNameForClients());
+    assertSame(builder, builder.setHostNameForClients("Pegasus"));
+    assertEquals("Pegasus", builder.getHostNameForClients());
+    assertSame(builder, builder.setHostNameForClients(null));
+    assertNull(builder.getHostNameForClients());
+  }
+
+  @Test
+  public void testSetAndGetServerPort() {
+    Builder builder = new Builder();
+
+    assertEquals(ServerLauncher.DEFAULT_SERVER_PORT, builder.getServerPort());
+    assertSame(builder, builder.setServerPort(0));
+    assertEquals(0, builder.getServerPort().intValue());
+    assertSame(builder, builder.setServerPort(1));
+    assertEquals(1, builder.getServerPort().intValue());
+    assertSame(builder, builder.setServerPort(80));
+    assertEquals(80, builder.getServerPort().intValue());
+    assertSame(builder, builder.setServerPort(1024));
+    assertEquals(1024, builder.getServerPort().intValue());
+    assertSame(builder, builder.setServerPort(65535));
+    assertEquals(65535, builder.getServerPort().intValue());
+    assertSame(builder, builder.setServerPort(null));
+    assertEquals(ServerLauncher.DEFAULT_SERVER_PORT, builder.getServerPort());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetServerPortToOverflow() {
+    try {
+      new Builder().setServerPort(65536);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Server"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetServerPortToUnderflow() {
+    try {
+      new Builder().setServerPort(-1);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_INVALID_PORT_ERROR_MESSAGE.toLocalizedString("Server"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetCriticalHeapPercentage() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getCriticalHeapPercentage());
+    assertSame(builder, builder.setCriticalHeapPercentage(55.5f));
+    assertEquals(55.5f, builder.getCriticalHeapPercentage().floatValue(), 0.0f);
+    assertSame(builder, builder.setCriticalHeapPercentage(null));
+    assertNull(builder.getCriticalHeapPercentage());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetCriticalHeapPercentageToOverflow() {
+    try {
+      new Builder().setCriticalHeapPercentage(100.01f);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Critical heap percentage (100.01) must be between 0 and 100!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetCriticalHeapPercentageToUnderflow() {
+    try {
+      new Builder().setCriticalHeapPercentage(-0.01f);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Critical heap percentage (-0.01) must be between 0 and 100!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetEvictionHeapPercentage() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getEvictionHeapPercentage());
+    assertSame(builder, builder.setEvictionHeapPercentage(55.55f));
+    assertEquals(55.55f, builder.getEvictionHeapPercentage().floatValue(), 0.0f);
+    assertSame(builder, builder.setEvictionHeapPercentage(null));
+    assertNull(builder.getEvictionHeapPercentage());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetEvictionHeapPercentageToOverflow() {
+    try {
+      new Builder().setEvictionHeapPercentage(101.0f);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Eviction heap percentage (101.0) must be between 0 and 100!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetEvictionHeapPercentageToUnderflow() {
+    try {
+      new Builder().setEvictionHeapPercentage(-10.0f);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Eviction heap percentage (-10.0) must be between 0 and 100!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetMaxConnections() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMaxConnections());
+    assertSame(builder, builder.setMaxConnections(1000));
+    assertEquals(1000, builder.getMaxConnections().intValue());
+    assertSame(builder, builder.setMaxConnections(null));
+    assertNull(builder.getMaxConnections());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMaxConnectionsWithIllegalValue() {
+    try {
+      new Builder().setMaxConnections(-10);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Max Connections (-10) must be greater than 0!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetMaxMessageCount() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMaxMessageCount());
+    assertSame(builder, builder.setMaxMessageCount(50));
+    assertEquals(50, builder.getMaxMessageCount().intValue());
+    assertSame(builder, builder.setMaxMessageCount(null));
+    assertNull(builder.getMaxMessageCount());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMaxMessageCountWithIllegalValue() {
+    try {
+      new Builder().setMaxMessageCount(0);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Max Message Count (0) must be greater than 0!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetMaxThreads() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMaxThreads());
+    assertSame(builder, builder.setMaxThreads(16));
+    assertEquals(16, builder.getMaxThreads().intValue());
+    assertSame(builder, builder.setMaxThreads(null));
+    assertNull(builder.getMaxThreads());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMaxThreadsWithIllegalValue() {
+    try {
+      new Builder().setMaxThreads(-4);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Max Threads (-4) must be greater than 0!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetMessageTimeToLive() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getMessageTimeToLive());
+    assertSame(builder, builder.setMessageTimeToLive(30000));
+    assertEquals(30000, builder.getMessageTimeToLive().intValue());
+    assertSame(builder, builder.setMessageTimeToLive(null));
+    assertNull(builder.getMessageTimeToLive());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetMessageTimeToLiveWithIllegalValue() {
+    try {
+      new Builder().setMessageTimeToLive(0);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("Message Time To Live (0) must be greater than 0!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testSetAndGetSocketBufferSize() {
+    Builder builder = new Builder();
+
+    assertNull(builder.getSocketBufferSize());
+    assertSame(builder, builder.setSocketBufferSize(32768));
+    assertEquals(32768, builder.getSocketBufferSize().intValue());
+    assertSame(builder, builder.setSocketBufferSize(null));
+    assertNull(builder.getSocketBufferSize());
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void testSetSocketBufferSizeWithIllegalValue() {
+    try {
+      new Builder().setSocketBufferSize(-8192);
+    }
+    catch (IllegalArgumentException expected) {
+      assertEquals("The Server's Socket Buffer Size (-8192) must be greater than 0!", expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
+    ServerLauncher launcher = new Builder()
+      .setCommand(ServerLauncher.Command.START)
+      .setMemberName(null)
+      .set(DistributionConfig.NAME_NAME, "serverABC")
+      .build();
+
+    assertNotNull(launcher);
+    assertEquals(ServerLauncher.Command.START, launcher.getCommand());
+    assertNull(launcher.getMemberName());
+    assertEquals("serverABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
+  }
+
+  @Test
+  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "serverXYZ");
+
+    ServerLauncher launcher = new Builder()
+      .setCommand(ServerLauncher.Command.START)
+      .setMemberName(null)
+      .build();
+
+    assertNotNull(launcher);
+    assertEquals(ServerLauncher.Command.START, launcher.getCommand());
+    assertNull(launcher.getMemberName());
+  }
+
+  @Test(expected = IllegalStateException.class)
+  public void testBuildNoMemberNameOnStart() {
+    try {
+      new Builder().setCommand(Command.START).build();
+    }
+    catch (IllegalStateException expected) {
+      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Server"),
+        expected.getMessage());
+      throw expected;
+    }
+  }
+
+  @Test
+  public void testIsServing() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.singletonList(mockCacheServer)));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertTrue(serverLauncher.isServing(mockCache));
+  }
+
+  @Test
+  public void testIsServingWhenNoCacheServersExist() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertFalse(serverLauncher.isServing(mockCache));
+  }
+
+  @Test
+  public void reconnectedCacheIsDiscovered() throws Exception {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final Cache mockReconnectedCache = mockContext.mock(Cache.class, "ReconnectedCache");
+
+    mockContext.checking(new Expectations() {{
+      exactly(2).of(mockCache).isReconnecting();
+      will(returnValue(Boolean.FALSE));
+
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+
+      oneOf(mockCache).isReconnecting();
+      will(returnValue(Boolean.TRUE));
+
+      oneOf(mockCache).getReconnectedCache();
+      will(returnValue(mockReconnectedCache));
+
+      oneOf(mockReconnectedCache).close();
+
+    }});
+
+    final ServerLauncher serverLauncher =
+            new Builder()
+                    .setMemberName("serverOne")
+                    .setCache(mockCache)
+                    .build();
+
+    assertNotNull(serverLauncher);
+    serverLauncher.waitOnServer();
+  }
+
+  @Test
+  public void reconnectingDistributedSystemIsDisconnectedOnStop() throws Exception {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
+    final Cache mockReconnectedCache = mockContext.mock(Cache.class, "ReconnectedCache");
+
+    mockContext.checking(new Expectations() {{
+      exactly(1).of(mockCache).isReconnecting();
+      will(returnValue(Boolean.TRUE));
+
+      exactly(1).of(mockCache).getReconnectedCache();
+      will(returnValue(mockReconnectedCache));
+
+      exactly(2).of(mockReconnectedCache).isReconnecting();
+      will(returnValue(Boolean.TRUE));
+
+      exactly(1).of(mockReconnectedCache).getReconnectedCache();
+      will(returnValue(null));
+
+      oneOf(mockReconnectedCache).getDistributedSystem();
+      will(returnValue(mockDistributedSystem));
+
+      oneOf(mockDistributedSystem).stopReconnecting();
+
+      oneOf(mockReconnectedCache).close();
+    }});
+
+    final ServerLauncher serverLauncher =
+            new Builder()
+                    .setMemberName("serverOne")
+                    .setCache(mockCache)
+                    .build();
+
+    assertNotNull(serverLauncher);
+    serverLauncher.setIsRunningForTest();
+    serverLauncher.stop();
+  }
+
+  @Test
+  public void testIsWaiting() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getDistributedSystem();
+      will(returnValue(mockDistributedSystem));
+      oneOf(mockDistributedSystem).isConnected();
+      will(returnValue(true));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+
+    serverLauncher.running.set(true);
+
+    assertTrue(serverLauncher.isRunning());
+    assertTrue(serverLauncher.isWaiting(mockCache));
+  }
+
+  @Test
+  public void testIsWaitingWhenNotConnected() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getDistributedSystem();
+      will(returnValue(mockDistributedSystem));
+      oneOf(mockDistributedSystem).isConnected();
+      will(returnValue(false));
+      oneOf(mockCache).isReconnecting();
+      will(returnValue(Boolean.FALSE));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+
+    serverLauncher.running.set(true);
+
+    assertTrue(serverLauncher.isRunning());
+    assertFalse(serverLauncher.isWaiting(mockCache));
+  }
+
+  @Test
+  public void testIsWaitingWhenNotRunning() {
+    ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+
+    serverLauncher.running.set(false);
+
+    assertFalse(serverLauncher.isRunning());
+    assertFalse(serverLauncher.isWaiting(null));
+  }
+
+  @Test
+  public void testWaitOnServer() throws Throwable {
+    TestFramework.runOnce(new ServerWaitMultiThreadedTestCase());
+  }
+
+  @Test
+  public void testIsDefaultServerEnabled() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+    }});
+
+    ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertFalse(serverLauncher.isDisableDefaultServer());
+    assertTrue(serverLauncher.isDefaultServerEnabled(mockCache));
+  }
+
+  @Test
+  public void testIsDefaultServerEnabledWhenCacheServersExist() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.singletonList(mockCacheServer)));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertFalse(serverLauncher.isDisableDefaultServer());
+    assertFalse(serverLauncher.isDefaultServerEnabled(mockCache));
+  }
+  @Test
+  public void testIsDefaultServerEnabledWhenNoCacheServersExistAndDefaultServerDisabled() {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(true).build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertTrue(serverLauncher.isDisableDefaultServer());
+    assertFalse(serverLauncher.isDefaultServerEnabled(mockCache));
+  }
+
+  @Test
+  public void testStartCacheServer() throws IOException {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+      oneOf(mockCache).addCacheServer();
+      will(returnValue(mockCacheServer));
+      oneOf(mockCacheServer).setBindAddress(with(aNull(String.class)));
+      oneOf(mockCacheServer).setPort(with(equal(11235)));
+      oneOf(mockCacheServer).start();
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne")
+      .setServerBindAddress(null)
+      .setServerPort(11235)
+      .setDisableDefaultServer(false)
+      .build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertFalse(serverLauncher.isDisableDefaultServer());
+
+    serverLauncher.startCacheServer(mockCache);
+  }
+
+  @Test
+  public void testStartCacheServerWhenDefaultServerDisabled() throws IOException {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.emptyList()));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(true).build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertTrue(serverLauncher.isDisableDefaultServer());
+
+    serverLauncher.startCacheServer(mockCache);
+  }
+
+  @Test
+  public void testStartCacheServerWithExistingCacheServer() throws IOException {
+    final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+    final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
+
+    mockContext.checking(new Expectations() {{
+      oneOf(mockCache).getCacheServers();
+      will(returnValue(Collections.singletonList(mockCacheServer)));
+    }});
+
+    final ServerLauncher serverLauncher = new Builder().setMemberName("serverOne").setDisableDefaultServer(false).build();
+
+    assertNotNull(serverLauncher);
+    assertEquals("serverOne", serverLauncher.getMemberName());
+    assertFalse(serverLauncher.isDisableDefaultServer());
+
+    serverLauncher.startCacheServer(mockCache);
+  }
+  
+  public static void main(final String... args) {
+    System.err.printf("Thread (%1$s) is daemon (%2$s)%n", Thread.currentThread().getName(),
+      Thread.currentThread().isDaemon());
+    new Builder(args).setCommand(Command.START).build().run();
+  }
+
+  private final class ServerWaitMultiThreadedTestCase extends MultithreadedTestCase {
+
+    private final AtomicBoolean connectionStateHolder = new AtomicBoolean(true);
+
+    private ServerLauncher serverLauncher;
+
+    @Override
+    public void initialize() {
+      super.initialize();
+
+      final Cache mockCache = mockContext.mock(Cache.class, "Cache");
+
+      final DistributedSystem mockDistributedSystem = new DistributedSystemAdapter() {
+        @Override public boolean isConnected() {
+          return connectionStateHolder.get();
+        }
+      };
+
+      mockContext.checking(new Expectations() {{
+        allowing(mockCache).getDistributedSystem();
+        will(returnValue(mockDistributedSystem));
+        allowing(mockCache).isReconnecting();
+        will(returnValue(Boolean.FALSE));
+        allowing(mockCache).getCacheServers();
+        will(returnValue(Collections.emptyList()));
+        oneOf(mockCache).close();
+      }});
+
+      this.serverLauncher = new Builder().setMemberName("dataMember").setDisableDefaultServer(true)
+        .setCache(mockCache).build();
+
+      assertNotNull(this.serverLauncher);
+      assertEquals("dataMember", this.serverLauncher.getMemberName());
+      assertTrue(this.serverLauncher.isDisableDefaultServer());
+      assertTrue(connectionStateHolder.get());
+    }
+
+    public void thread1() {
+      assertTick(0);
+
+      Thread.currentThread().setName("GemFire Data Member 'main' Thread");
+      this.serverLauncher.running.set(true);
+
+      assertTrue(this.serverLauncher.isRunning());
+      assertFalse(this.serverLauncher.isServing(this.serverLauncher.getCache()));
+      assertTrue(this.serverLauncher.isWaiting(this.serverLauncher.getCache()));
+
+      this.serverLauncher.waitOnServer();
+
+      assertTick(1); // NOTE the tick does not advance when the other Thread terminates
+    }
+
+    public void thread2() {
+      waitForTick(1);
+
+      Thread.currentThread().setName("GemFire 'shutdown' Thread");
+
+      assertTrue(this.serverLauncher.isRunning());
+
+      this.connectionStateHolder.set(false);
+    }
+
+    @Override
+    public void finish() {
+      super.finish();
+      assertFalse(this.serverLauncher.isRunning());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderIntegrationTest.java
new file mode 100644
index 0000000..f04c7cf
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderIntegrationTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed;
+
+import static org.junit.Assert.*;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
+import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Extracted from ServerLauncherLocalIntegrationTest.
+ */
+@Category(IntegrationTest.class)
+public class ServerLauncherWithProviderIntegrationTest extends AbstractServerLauncherIntegrationTestCase {
+
+  @Before
+  public final void setUpServerLauncherWithSpringTest() throws Exception {
+    disconnectFromDS();
+    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
+  }
+
+  @After
+  public final void tearDownServerLauncherWithSpringTest() throws Exception {
+    MockServerLauncherCacheProvider.setCache(null);
+    disconnectFromDS();
+    
+  }
+
+  // NOTE make sure bugs like Trac #51201 never happen again!!!
+  @Test
+  public void testBootstrapGemFireServerWithProvider() throws Throwable {
+    Cache mockCache = Mockito.mock(Cache.class);
+    MockServerLauncherCacheProvider.setCache(mockCache);
+    this.launcher = new Builder()
+      .setDisableDefaultServer(true)
+      .setForce(true)
+      .setMemberName(getUniqueName())
+      .setSpringXmlLocation("spring/spring-gemfire-context.xml")
+      .set(DistributionConfig.MCAST_PORT_NAME, "0")
+      .build();
+
+    assertNotNull(this.launcher);
+
+    try {
+      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
+
+      waitForServerToStart(this.launcher);
+
+      Cache cache = this.launcher.getCache();
+
+      assertEquals(mockCache, cache);
+    }
+    catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    try {
+      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+      assertNull(this.launcher.getCache());
+    }
+    catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderJUnitTest.java
deleted file mode 100644
index 9728485..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherWithProviderJUnitTest.java
+++ /dev/null
@@ -1,90 +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 com.gemstone.gemfire.distributed;
-
-import static org.junit.Assert.*;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
-import com.gemstone.gemfire.distributed.ServerLauncher.Builder;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.process.ProcessType;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Extracted from ServerLauncherLocalJUnitTest.
- * 
- */
-@Category(IntegrationTest.class)
-public class ServerLauncherWithProviderJUnitTest extends AbstractServerLauncherJUnitTestCase {
-
-  @Before
-  public final void setUpServerLauncherWithSpringTest() throws Exception {
-    disconnectFromDS();
-    System.setProperty(ProcessType.TEST_PREFIX_PROPERTY, getUniqueName()+"-");
-  }
-
-  @After
-  public final void tearDownServerLauncherWithSpringTest() throws Exception {
-    MockServerLauncherCacheProvider.setCache(null);
-    disconnectFromDS();
-    
-  }
-
-  // NOTE make sure bugs like Trac #51201 never happen again!!!
-  @Test
-  public void testBootstrapGemFireServerWithProvider() throws Throwable {
-    Cache mockCache = Mockito.mock(Cache.class);
-    MockServerLauncherCacheProvider.setCache(mockCache);
-    this.launcher = new Builder()
-      .setDisableDefaultServer(true)
-      .setForce(true)
-      .setMemberName(getUniqueName())
-      .setSpringXmlLocation("spring/spring-gemfire-context.xml")
-      .set(DistributionConfig.MCAST_PORT_NAME, "0")
-      .build();
-
-    assertNotNull(this.launcher);
-
-    try {
-      assertEquals(Status.ONLINE, this.launcher.start().getStatus());
-
-      waitForServerToStart(this.launcher);
-
-      Cache cache = this.launcher.getCache();
-
-      assertEquals(mockCache, cache);
-    }
-    catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-
-    try {
-      assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
-      assertNull(this.launcher.getCache());
-    }
-    catch (Throwable e) {
-      this.errorCollector.addError(e);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/internal/process/FileProcessControllerIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/FileProcessControllerIntegrationJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/FileProcessControllerIntegrationJUnitTest.java
index 6255af1..660716c 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/FileProcessControllerIntegrationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/FileProcessControllerIntegrationJUnitTest.java
@@ -40,7 +40,6 @@ import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 
 import com.gemstone.gemfire.distributed.LocatorLauncher;
-import com.gemstone.gemfire.distributed.LocatorStateJUnitTest;
 import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
 import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.LocatorState;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
index d3e004b..84dc977 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/SharedConfigurationCommandsDUnitTest.java
@@ -16,7 +16,10 @@
  */
 package com.gemstone.gemfire.management.internal.cli.commands;
 
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
@@ -35,43 +38,45 @@ import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.CacheFactory;
 import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.ClassBuilder;
 import com.gemstone.gemfire.management.cli.Result;
 import com.gemstone.gemfire.management.cli.Result.Status;
-import com.gemstone.gemfire.management.internal.cli.CliUtil;
+import static com.gemstone.gemfire.management.internal.cli.CliUtil.*;
 import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
-import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import static com.gemstone.gemfire.management.internal.cli.i18n.CliStrings.*;
 import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
 import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationDUnitTest;
+import com.gemstone.gemfire.management.internal.configuration.SharedConfigurationTestUtils;
 import com.gemstone.gemfire.management.internal.configuration.domain.Configuration;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
-/***
+/**
  * DUnit test to test export and import of shared configuration.
  */
 @Category(DistributedTest.class)
-@SuppressWarnings("unchecked")
 public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
 
-  private static final long serialVersionUID = 1L;
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
 
-  File newDeployableJarFile = new File("DeployCommandsDUnit1.jar");
+  private File newDeployableJarFile = new File("DeployCommandsDUnit1.jar");
   private transient ClassBuilder classBuilder = new ClassBuilder();
 
+  @Override
+  public final void postTearDownCacheTestCase() throws Exception {
+    for (int i = 0; i < 4; i++) {
+      getHost(0).getVM(i).invoke(SharedConfigurationTestUtils.cleanupLocator);
+    }
+  }
+
   @Test
-  public void testExportImportSharedConfiguration() {
+  public void testExportImportSharedConfiguration() throws IOException {
     disconnectAllFromDS();
 
     final String region1Name = "r1";
@@ -81,15 +86,16 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
     final String deployedJarName = "DeployCommandsDUnit1.jar";
     final String logLevel = "info";
     final String startArchiveFileName = "stats.gfs";
-    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    final int[] ports = getRandomAvailableTCPPorts(3);
 
     // TODO Sourabh - the code below is similar to CliCommandTestBase.createDefaultSetup(..); we may want to consider
     // refactoring this and combine the duplicate code blocks using either the Template Method and/or Strategy design
     // patterns.  We can talk about this.
     // Start the Locator and wait for shared configuration to be available
+
     final int locator1Port = ports[0];
     final String locator1Name = "locator1-" + locator1Port;
-    VM locatorAndMgr = Host.getHost(0).getVM(3);
+    VM locatorAndMgr = getHost(0).getVM(3);
     Object[] result = (Object[]) locatorAndMgr.invoke(new SerializableCallable() {
       @Override
       public Object call() {
@@ -103,7 +109,7 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
           jmxHost = "localhost";
         }
 
-        final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+        final int[] ports = getRandomAvailableTCPPorts(2);
 
         jmxPort = ports[0];
         httpPort = ports[1];
@@ -111,19 +117,18 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
         final File locatorLogFile = new File("locator-" + locator1Port + ".log");
 
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, locator1Name);
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "config");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_START_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
-        locatorProps.setProperty(DistributionConfig.JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
-        locatorProps.setProperty(DistributionConfig.HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
+        locatorProps.setProperty(NAME_NAME, locator1Name);
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "config");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_START_NAME, "true");
+        locatorProps.setProperty(JMX_MANAGER_BIND_ADDRESS_NAME, String.valueOf(jmxHost));
+        locatorProps.setProperty(JMX_MANAGER_PORT_NAME, String.valueOf(jmxPort));
+        locatorProps.setProperty(HTTP_SERVICE_PORT_NAME, String.valueOf(httpPort));
 
         try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile,
-              null, locatorProps);
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
           WaitCriterion wc = new WaitCriterion() {
             @Override
             public boolean done() {
@@ -136,15 +141,15 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
             }
           };
           waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         }
 
         final Object[] result = new Object[4];
         result[0] = jmxHost;
         result[1] = jmxPort;
         result[2] = httpPort;
-        result[3] = CliUtil.getAllNormalMembers(CacheFactory.getAnyInstance());
+        result[3] = getAllNormalMembers(CacheFactory.getAnyInstance());
 
         return result;
       }
@@ -154,63 +159,60 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
     String jmxHost = (String) result[0];
     int jmxPort = (Integer) result[1];
     int httpPort = (Integer) result[2];
-    Set<DistributedMember> normalMembers1 = (Set<DistributedMember>) result[3];
+    Set<DistributedMember> normalMembers1 = (Set<DistributedMember>) result[3]; // TODO: never used
 
     shellConnect(jmxHost, jmxPort, httpPort, gfsh);
     // Create a cache in VM 1
-    VM dataMember = Host.getHost(0).getVM(1);
+    VM dataMember = getHost(0).getVM(1);
     normalMembers1 = (Set<DistributedMember>) dataMember.invoke(new SerializableCallable() {
       @Override
       public Object call() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, groupName);
-        localProps.setProperty(DistributionConfig.NAME_NAME, "DataMember");
+        localProps.setProperty(MCAST_PORT_NAME, "0");
+        localProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
+        localProps.setProperty(GROUPS_NAME, groupName);
+        localProps.setProperty(NAME_NAME, "DataMember");
         getSystem(localProps);
         Cache cache = getCache();
         assertNotNull(cache);
-        return CliUtil.getAllNormalMembers(cache);
+        return getAllNormalMembers(cache);
       }
     });
+
     // Create a JAR file
-    try {
-      this.classBuilder.writeJarFromName("DeployCommandsDUnitA", this.newDeployableJarFile);
-    } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
-    }
+    this.classBuilder.writeJarFromName("DeployCommandsDUnitA", this.newDeployableJarFile);
 
     // Deploy the JAR
     CommandResult cmdResult = executeCommand("deploy --jar=" + deployedJarName);
     assertEquals(Result.Status.OK, cmdResult.getStatus());
+
     //Create the region1 on the group
-    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, region1Name);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, "true");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__GROUP, groupName);
+    CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CREATE_REGION);
+    commandStringBuilder.addOption(CREATE_REGION__REGION, region1Name);
+    commandStringBuilder.addOption(CREATE_REGION__REGIONSHORTCUT, "REPLICATE");
+    commandStringBuilder.addOption(CREATE_REGION__STATISTICSENABLED, "true");
+    commandStringBuilder.addOption(CREATE_REGION__GROUP, groupName);
 
     cmdResult = executeCommand(commandStringBuilder.toString());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
-    commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_REGION);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGION, region2Name);
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, "PARTITION");
-    commandStringBuilder.addOption(CliStrings.CREATE_REGION__STATISTICSENABLED, "true");
+    commandStringBuilder = new CommandStringBuilder(CREATE_REGION);
+    commandStringBuilder.addOption(CREATE_REGION__REGION, region2Name);
+    commandStringBuilder.addOption(CREATE_REGION__REGIONSHORTCUT, "PARTITION");
+    commandStringBuilder.addOption(CREATE_REGION__STATISTICSENABLED, "true");
     cmdResult = executeCommand(commandStringBuilder.toString());
     assertEquals(Result.Status.OK, cmdResult.getStatus());
 
-    //Alter runtime configuration 
-    commandStringBuilder = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__LEVEL, logLevel);
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "120");
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, startArchiveFileName);
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
-    commandStringBuilder.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
+    //Alter runtime configuration
+    commandStringBuilder = new CommandStringBuilder(ALTER_RUNTIME_CONFIG);
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__LEVEL, logLevel);
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT, "32");
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT, "49");
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "120");
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, startArchiveFileName);
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
+    commandStringBuilder.addOption(ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
     cmdResult = executeCommand(commandStringBuilder.getCommandString());
     String resultString = commandResultToString(cmdResult);
 
@@ -218,15 +220,15 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
     getLogWriter().info(resultString);
     assertEquals(true, cmdResult.getStatus().equals(Status.OK));
 
-    commandStringBuilder = new CommandStringBuilder(CliStrings.STATUS_SHARED_CONFIG);
+    commandStringBuilder = new CommandStringBuilder(STATUS_SHARED_CONFIG);
     cmdResult = executeCommand(commandStringBuilder.getCommandString());
     resultString = commandResultToString(cmdResult);
     getLogWriter().info("#SB Result\n");
     getLogWriter().info(resultString);
     assertEquals(Status.OK, cmdResult.getStatus());
 
-    commandStringBuilder = new CommandStringBuilder(CliStrings.EXPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(CliStrings.EXPORT_SHARED_CONFIG__FILE, sharedConfigZipFileName);
+    commandStringBuilder = new CommandStringBuilder(EXPORT_SHARED_CONFIG);
+    commandStringBuilder.addOption(EXPORT_SHARED_CONFIG__FILE, sharedConfigZipFileName);
     cmdResult = executeCommand(commandStringBuilder.getCommandString());
     resultString = commandResultToString(cmdResult);
     getLogWriter().info("#SB Result\n");
@@ -234,8 +236,8 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
     assertEquals(Status.OK, cmdResult.getStatus());
 
     //Import into a running system should fail
-    commandStringBuilder = new CommandStringBuilder(CliStrings.IMPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(CliStrings.IMPORT_SHARED_CONFIG__ZIP, sharedConfigZipFileName);
+    commandStringBuilder = new CommandStringBuilder(IMPORT_SHARED_CONFIG);
+    commandStringBuilder.addOption(IMPORT_SHARED_CONFIG__ZIP, sharedConfigZipFileName);
     cmdResult = executeCommand(commandStringBuilder.getCommandString());
     assertEquals(Status.ERROR, cmdResult.getStatus());
 
@@ -263,15 +265,15 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
       }
     });
 
-    //Now execute import shared configuration 
+    //Now execute import shared configuration
     //Now import the shared configuration and it should succeed.
-    commandStringBuilder = new CommandStringBuilder(CliStrings.IMPORT_SHARED_CONFIG);
-    commandStringBuilder.addOption(CliStrings.IMPORT_SHARED_CONFIG__ZIP, sharedConfigZipFileName);
+    commandStringBuilder = new CommandStringBuilder(IMPORT_SHARED_CONFIG);
+    commandStringBuilder.addOption(IMPORT_SHARED_CONFIG__ZIP, sharedConfigZipFileName);
     cmdResult = executeCommand(commandStringBuilder.getCommandString());
     assertEquals(Status.OK, cmdResult.getStatus());
 
     //Start a new locator , test if it has all the imported shared configuration artifacts
-    VM newLocator = Host.getHost(0).getVM(2);
+    VM newLocator = getHost(0).getVM(2);
     final int locator2Port = ports[1];
     final String locator2Name = "Locator2-" + locator2Port;
 
@@ -280,22 +282,20 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
       public void run() {
         final File locatorLogFile = new File("locator-" + locator2Port + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, locator2Name);
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
+        locatorProps.setProperty(NAME_NAME, locator2Name);
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "fine");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
 
         try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port, locatorLogFile,
-              null, locatorProps);
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port, locatorLogFile, null, locatorProps);
 
           WaitCriterion wc = new WaitCriterion() {
             @Override
             public boolean done() {
               return locator.isSharedConfigurationRunning();
             }
-
             @Override
             public String description() {
               return "Waiting for shared configuration to be started";
@@ -313,29 +313,20 @@ public class SharedConfigurationCommandsDUnitTest extends CliCommandTestBase {
           assertNotNull(clusterConfig);
           assertTrue(clusterConfig.getCacheXmlContent().contains(region2Name));
           assertTrue(clusterConfig.getJarNames().contains(deployedJarName));
-          assertTrue(
-              clusterConfig.getGemfireProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME).equals(logLevel));
-          assertTrue(
-              clusterConfig.getGemfireProperties().getProperty(DistributionConfig.STATISTIC_ARCHIVE_FILE_NAME).equals(
-                  startArchiveFileName));
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+          assertTrue(clusterConfig.getGemfireProperties().getProperty(LOG_LEVEL_NAME).equals(logLevel));
+          assertTrue(clusterConfig.getGemfireProperties().getProperty(STATISTIC_ARCHIVE_FILE_NAME).equals(startArchiveFileName));
+
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         } catch (Exception e) {
           fail("Error occurred in cluster configuration service", e);
         }
       }
     });
 
-    //Clean up
+    //Clean up -- TODO: move to tearDown
     File sharedConfigZipFile = new File(sharedConfigZipFileName);
     FileUtils.deleteQuietly(sharedConfigZipFile);
     FileUtils.deleteQuietly(newDeployableJarFile);
   }
-
-  @Override
-  public final void postTearDownCacheTestCase() throws Exception {
-    for (int i = 0; i < 4; i++) {
-      Host.getHost(0).getVM(i).invoke(SharedConfigurationDUnitTest.locatorCleanup);
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/cd02af01/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
index 92fe1bc..0ef3c3f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationDUnitTest.java
@@ -16,6 +16,12 @@
  */
 package com.gemstone.gemfire.management.internal.configuration;
 
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePortHelper.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
+
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -27,112 +33,95 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.DiskStoreFactory;
 import com.gemstone.gemfire.cache.RegionFactory;
 import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache30.CacheTestCase;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DM;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalLocator;
 import com.gemstone.gemfire.distributed.internal.SharedConfiguration;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.tcpserver.TcpClient;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.xmlcache.CacheXml;
 import com.gemstone.gemfire.management.internal.configuration.domain.Configuration;
 import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity;
-import com.gemstone.gemfire.management.internal.configuration.domain.XmlEntity.XmlEntityBuilder;
 import com.gemstone.gemfire.management.internal.configuration.handlers.ConfigurationRequestHandler;
 import com.gemstone.gemfire.management.internal.configuration.messages.ConfigurationRequest;
 import com.gemstone.gemfire.management.internal.configuration.messages.ConfigurationResponse;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.SerializableCallable;
-import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
-/***
+/**
  * Tests the starting up of shared configuration, installation of {@link ConfigurationRequestHandler}
- * 
- *
  */
-public class SharedConfigurationDUnitTest extends CacheTestCase {
+@Category(DistributedTest.class)
+public class SharedConfigurationDUnitTest extends JUnit4CacheTestCase {
+
   private static final long serialVersionUID = 1L;
   private static final String REGION1 = "region1";
   private static final int TIMEOUT = 10000;
   private static final int INTERVAL = 500;
   private static final String DISKSTORENAME = "diskStore1";
 
-//  private static final VM locator1Vm = Host.getHost(0).getVM(1);
-//  private static final VM locator2Vm = Host.getHost(0).getVM(2);
-//  private static final VM dataMemberVm = Host.getHost(0).getVM(3);
+  @Override
+  public final void postSetUp() throws Exception {
+    disconnectAllFromDS();
+  }
 
-  public static final SerializableRunnable locatorCleanup = new SerializableRunnable() {
-    @Override
-    public void run() {
-      InternalLocator locator = InternalLocator.getLocator();
-      if (locator != null) {
-        SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-        if (sharedConfig != null) {
-          sharedConfig.destroySharedConfiguration();
-        }
-        locator.stop();
-      }
-      disconnectAllFromDS();
+  @Override
+  public final void postTearDownCacheTestCase() throws Exception {
+    for (int i=0; i<4; i++) {
+      getHost(0).getVM(i).invoke(SharedConfigurationTestUtils.cleanupLocator);
     }
-  };
-  
-  
-  public SharedConfigurationDUnitTest(String name) {
-    super(name);
   }
-  
-  public void testGetHostedLocatorsWithSharedConfiguration() {
-    disconnectAllFromDS();
-    final VM locator1Vm = Host.getHost(0).getVM(1);
-    final VM locator2Vm = Host.getHost(0).getVM(2);
+
+  @Test
+  public void testGetHostedLocatorsWithSharedConfiguration() throws Exception {
+    final VM locator1Vm = getHost(0).getVM(1);
+    final VM locator2Vm = getHost(0).getVM(2);
   
     final String testName = "testGetHostedLocatorsWithSharedConfiguration";
-//    final VM locator3Vm = Host.getHost(0).getVM(3);
-    
-    final int []ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+
+    final int[] ports = getRandomAvailableTCPPorts(3);
     
-    //final int locator1Port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     final int locator1Port = ports[0];
     final String locator1Name = "locator1" + locator1Port;
+
     locator1Vm.invoke(new SerializableCallable() {
       @Override
       public Object call() {
         final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, locator1Name);
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        try {
-          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null,
-              locatorProps);
+        locatorProps.setProperty(NAME_NAME, locator1Name);
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "fine");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
 
+        try {
+          final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null, locatorProps);
           WaitCriterion wc = new WaitCriterion() {
             @Override
             public boolean done() {
               return locator.isSharedConfigurationRunning();
             }
-
             @Override
             public String description() {
               return "Waiting for shared configuration to be started";
             }
           };
-          Wait.waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         }
+
         GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
         InternalDistributedMember me = cache.getMyId();
         DM dm = cache.getDistributionManager();
@@ -147,7 +136,6 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       }
     });
     
-    //final int locator2Port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     final int locator2Port = ports[1];
     final String locator2Name = "locator2" + locator2Port;
 
@@ -156,13 +144,12 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       public Object call() throws IOException {
         final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, locator2Name);
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "fine");
-        locatorProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port, locatorLogFile, null,
-            locatorProps);
+        locatorProps.setProperty(NAME_NAME, locator2Name);
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "fine");
+        locatorProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+        final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port, locatorLogFile, null, locatorProps);
 
         GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
         InternalDistributedMember me = cache.getMyId();
@@ -193,7 +180,7 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       public Object call() {
         InternalLocator locator = (InternalLocator) Locator.getLocator();
         SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-        sharedConfig.destroySharedConfiguration();
+        sharedConfig.destroySharedConfiguration_forTestsOnly();
         locator.stop();
         return null;
       }
@@ -216,32 +203,20 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
         return null;
       }
     });
-    
-//    locator2Vm.invoke(new SerializableCallable() {
-//      public Object call() {
-//        InternalLocator locator = (InternalLocator) Locator.getLocator();
-//        SharedConfiguration sharedConfig = locator.getSharedConfiguration();
-//        if (sharedConfig != null) {
-//          sharedConfig.destroySharedConfiguration();
-//        }
-//        locator.stop();
-//        return null;
-//      }
-//    });
   }
-  
-  public void testSharedConfigurationService() {
-    disconnectAllFromDS();
+
+  @Test
+  public void testSharedConfigurationService() throws Exception {
     // Start the Locator and wait for shared configuration to be available
     final String testGroup = "G1";
     final String clusterLogLevel = "error";
     final String groupLogLevel = "fine";
     final String testName = "testSharedConfigurationService";
     
-    final VM locator1Vm = Host.getHost(0).getVM(1);
-    final VM locator2Vm = Host.getHost(0).getVM(3);
-    final VM dataMemberVm = Host.getHost(0).getVM(2);
-    final int [] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
+    final VM locator1Vm = getHost(0).getVM(1);
+    final VM locator2Vm = getHost(0).getVM(3);
+    final VM dataMemberVm = getHost(0).getVM(2);
+    final int [] ports = getRandomAvailableTCPPorts(3);
     final int locator1Port = ports[0];
     
     locator1Vm.invoke(new SerializableCallable() {
@@ -249,10 +224,10 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       public Object call() {
         final File locatorLogFile = new File(testName + "-locator-" + locator1Port + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator1");
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(NAME_NAME, "Locator1");
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "info");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
         try {
           final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator1Port, locatorLogFile, null,
               locatorProps);
@@ -267,9 +242,9 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
               return "Waiting for shared configuration to be started";
             }
           };
-          Wait.waitForCriterion(wc, TIMEOUT, INTERVAL, true);
-        } catch (IOException ioex) {
-          fail("Unable to create a locator with a shared configuration");
+          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+        } catch (IOException e) {
+          fail("Unable to create a locator with a shared configuration", e);
         }
 
         return null;
@@ -280,9 +255,9 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       @Override
       public Object call() {
         Properties localProps = new Properties();
-        localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        localProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
-        localProps.setProperty(DistributionConfig.GROUPS_NAME, testGroup);
+        localProps.setProperty(MCAST_PORT_NAME, "0");
+        localProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
+        localProps.setProperty(GROUPS_NAME, testGroup);
         getSystem(localProps);
         Cache cache = getCache();
         assertNotNull(cache);
@@ -305,7 +280,7 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
         assertTrue(scw.addXmlEntity(xmlEntity, new String[] {testGroup}));
         //Modify property and cache attributes
         Properties clusterProperties = new Properties();
-        clusterProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME, clusterLogLevel);
+        clusterProperties.setProperty(LOG_LEVEL_NAME, clusterLogLevel);
         XmlEntity cacheEntity = XmlEntity.builder().withType(CacheXml.CACHE).build();
         Map<String, String> cacheAttributes = new HashMap<String, String>();
         cacheAttributes.put(CacheXml.COPY_ON_READ, "true");
@@ -313,7 +288,7 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
         //assertTrue(scw.modifyProperties(clusterProperties, null));
         assertTrue(scw.modifyPropertiesAndCacheAttributes(clusterProperties, cacheEntity, null));
 
-        clusterProperties.setProperty(DistributionConfig.LOG_LEVEL_NAME, groupLogLevel);
+        clusterProperties.setProperty(LOG_LEVEL_NAME, groupLogLevel);
         assertTrue(scw.modifyPropertiesAndCacheAttributes(clusterProperties, cacheEntity, new String[]{testGroup}));
 
         //Add a jar
@@ -338,11 +313,11 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
 
         final File locatorLogFile = new File(testName + "-locator-" + locator2Port + ".log");
         final Properties locatorProps = new Properties();
-        locatorProps.setProperty(DistributionConfig.NAME_NAME, "Locator2");
-        locatorProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-        locatorProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
-        locatorProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
-        locatorProps.setProperty(DistributionConfig.LOCATORS_NAME, "localhost:" + locator1Port);
+        locatorProps.setProperty(NAME_NAME, "Locator2");
+        locatorProps.setProperty(MCAST_PORT_NAME, "0");
+        locatorProps.setProperty(LOG_LEVEL_NAME, "info");
+        locatorProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "true");
+        locatorProps.setProperty(LOCATORS_NAME, "localhost:" + locator1Port);
         try {
           final InternalLocator locator = (InternalLocator) Locator.startLocatorAndDS(locator2Port, locatorLogFile, null,
               locatorProps);
@@ -358,7 +333,7 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
               return "Waiting for shared configuration to be started";
             }
           };
-          Wait.waitForCriterion(wc, TIMEOUT, INTERVAL, true);
+          waitForCriterion(wc, TIMEOUT, INTERVAL, true);
         } catch (IOException ioex) {
           fail("Unable to create a locator with a shared configuration");
         }
@@ -370,14 +345,14 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
         assertNotNull(clusterConfig);
         assertNotNull(clusterConfig.getJarNames());
         assertTrue(clusterConfig.getJarNames().contains("foo.jar"));
-        assertTrue(clusterConfig.getGemfireProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME).equals(clusterLogLevel));
+        assertTrue(clusterConfig.getGemfireProperties().getProperty(LOG_LEVEL_NAME).equals(clusterLogLevel));
         assertNotNull(clusterConfig.getCacheXmlContent());
         
         Configuration testGroupConfiguration = entireConfiguration.get(testGroup);
         assertNotNull(testGroupConfiguration);
         assertNotNull(testGroupConfiguration.getJarNames());
         assertTrue(testGroupConfiguration.getJarNames().contains("bar.jar"));
-        assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME).equals(groupLogLevel));
+        assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL_NAME).equals(groupLogLevel));
         assertNotNull(testGroupConfiguration.getCacheXmlContent());
         assertTrue(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
         
@@ -412,13 +387,13 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
         assertNull(configResponse.getJarNames());
         assertNull(configResponse.getJars());
         assertTrue(clusterConfiguration.getJarNames().isEmpty());
-        assertTrue(clusterConfiguration.getGemfireProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME).equals(clusterLogLevel));
+        assertTrue(clusterConfiguration.getGemfireProperties().getProperty(LOG_LEVEL_NAME).equals(clusterLogLevel));
         
         Configuration testGroupConfiguration = requestedConfiguration.get(testGroup);
         assertNotNull(testGroupConfiguration);
         assertFalse(testGroupConfiguration.getCacheXmlContent().contains(REGION1));
         assertTrue(testGroupConfiguration.getJarNames().isEmpty());
-        assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(DistributionConfig.LOG_LEVEL_NAME).equals(groupLogLevel));
+        assertTrue(testGroupConfiguration.getGemfireProperties().getProperty(LOG_LEVEL_NAME).equals(groupLogLevel));
         
         GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
         Map<InternalDistributedMember, Collection<String>> locatorsWithSharedConfiguration = cache.getDistributionManager().getAllHostedLocatorsWithSharedConfiguration();
@@ -432,11 +407,4 @@ public class SharedConfigurationDUnitTest extends CacheTestCase {
       }
     });
   }    
-  
-  @Override
-  public final void postTearDownCacheTestCase() throws Exception {
-    for (int i=0; i<4; i++) {
-      Host.getHost(0).getVM(i).invoke(SharedConfigurationDUnitTest.locatorCleanup);
-    }
-  }
 }
\ No newline at end of file