geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [10/12] incubator-geode git commit: Fixing tests
Date Mon, 02 May 2016 16:58:45 GMT
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);
+    }
+  }
+}



Mime
View raw message