geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [10/50] [abbrv] incubator-geode git commit: GEODE-291: Prevent stderr noise from com.gemstone.gemfire.test.process
Date Mon, 21 Dec 2015 18:04:38 GMT
GEODE-291: Prevent stderr noise from com.gemstone.gemfire.test.process

Change classes in com.gemstone.gemfire.test.process package:

* Remove unused methods and variables..

* Change waitFor() to match the Process.waitFor(long, TimeUnit) method in
JDK 1.8. Pass in timeout parameters from ProcessWrapper instead of
hardcoding it.

* Separate waitFor() into waitFor(long, TimeUnit) and start(). Previously
waitFor() was performing both of these actions.

* Improve debugging by: 1) adding minor lifecycle to ProcessOutputReader,
2) include command string in stack trace of ProcessStreamReader. This
enabled identification of the source of unwanted stderr output.

Change DistributedSystem to enable testing:

* Change DistributedSystem to enable better unit testing by allowing tests
to provide different locations for gemfire.properties with
gemfirePropertyFile. Make same changes for gfsecurity.properties and
gemfireSecurityPropertyFile.

* Create unit and integration tests for DistributedSystem class.

Change tests that use com.gemstone.gemfire.test.process package:

* Use DistributedSystem.PROPERTIES_FILE_PROPERTY to override location of
gemfire.properties.

* Separate integration tests from UnitTest files to IntegrationTests.

* Add and use Catch-Exception for better unit testing.

* Remove unused code and class.


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

Branch: refs/heads/feature/GEODE-14
Commit: fe295940c2c61a97c84ae333574e80001962ba15
Parents: 5b35e43
Author: Kirk Lund <klund@pivotal.io>
Authored: Tue Sep 15 16:15:33 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Fri Dec 11 16:01:43 2015 -0800

----------------------------------------------------------------------
 build.gradle                                    |   4 +-
 .../gemfire/distributed/AbstractLauncher.java   |   2 +-
 .../gemfire/distributed/DistributedSystem.java  | 208 ++++++++++---
 .../AbstractLauncherIntegrationJUnitTest.java   |  71 +++++
 .../distributed/AbstractLauncherJUnitTest.java  |  39 +--
 .../distributed/CommonLauncherTestSuite.java    |  65 ----
 .../DistributedSystemIntegrationJUnitTest.java  |  91 ++++++
 .../distributed/DistributedSystemJUnitTest.java |  78 +++++
 .../LocatorLauncherIntegrationJUnitTest.java    | 248 +++++++++++++++
 .../distributed/LocatorLauncherJUnitTest.java   | 154 +--------
 .../ServerLauncherIntegrationJUnitTest.java     | 312 +++++++++++++++++++
 .../distributed/ServerLauncherJUnitTest.java    | 183 +----------
 .../test/process/ProcessOutputReader.java       | 101 +++---
 .../test/process/ProcessStreamReader.java       |  42 +--
 .../gemfire/test/process/ProcessWrapper.java    |  10 +-
 gradle/dependency-versions.properties           |   4 +-
 16 files changed, 1064 insertions(+), 548 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 9c8ac44..f464dc3 100755
--- a/build.gradle
+++ b/build.gradle
@@ -325,9 +325,11 @@ subprojects {
     compile 'org.springframework:spring-webmvc:' + project.'springframework.version'
     compile 'com.github.stephenc.findbugs:findbugs-annotations:' + project.'stephenc-findbugs.version'
 
-    testCompile 'com.jayway.awaitility:awaitility:' + project.'awaitility.version'
     testCompile 'com.github.stefanbirkner:system-rules:' + project.'system-rules.version'
+    testCompile 'com.jayway.awaitility:awaitility:' + project.'awaitility.version'
     testCompile 'edu.umd.cs.mtc:multithreadedtc:' + project.'multithreadedtc.version'
+    testCompile 'eu.codearte.catch-exception:catch-exception:' + project.'catch-exception.version'
+    testCompile 'eu.codearte.catch-exception:catch-throwable:' + project.'catch-throwable.version'
     testCompile 'junit:junit:' + project.'junit.version'
     testCompile 'org.assertj:assertj-core:' + project.'assertj-core.version'
     testCompile 'org.mockito:mockito-core:' + project.'mockito-core.version'

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/AbstractLauncher.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/AbstractLauncher.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/AbstractLauncher.java
index bfd3de7..205f501 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/AbstractLauncher.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/AbstractLauncher.java
@@ -170,7 +170,7 @@ public abstract class AbstractLauncher<T extends Comparable<T>> implements Runna
       catch (Exception e) {
         try {
           // not in the file system, try the classpath
-          properties.load(AbstractLauncher.class.getResourceAsStream(DistributedSystem.PROPERTY_FILE));
+          properties.load(AbstractLauncher.class.getResourceAsStream(DistributedSystem.getPropertiesFile()));
         }
         catch (Exception ignore) {
           // not in the file system or the classpath; gemfire.properties does not exist

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
index e2fccd9..159db86 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/DistributedSystem.java
@@ -1943,26 +1943,59 @@ public abstract class DistributedSystem implements StatisticsFactory {
    */
   public abstract String getName();
 
-//   /**
-//    * Fires an "informational" <code>SystemMembershipEvent</code> that
-//    * is delivered to all {@link
-//    * com.gemstone.gemfire.admin.SystemMembershipListener}s.
-//    *
-//    * @param callback
-//    *        A user-specified object that is delivered with the {@link
-//    *        com.gemstone.gemfire.admin.SystemMembershipEvent}
-//    *        triggered by invoking this method.
-//    *
-//    * @see com.gemstone.gemfire.admin.SystemMembershipListener#memberInfo
-//    *
-//    * @since 4.0
-//    */
-//   public abstract void fireInfoEvent(Object callback);
+  /**
+   * The <code>PROPERTIES_FILE_PROPERTY</code> is the system property
+   * that can be used to specify the name of the properties file that the 
+   * connect method will check for when it looks for a properties file. Unless
+   * the value specifies the fully qualified path to the file, the file will 
+   * be searched for, in order, in the following directories:
+   * <ol>
+   * <li> the current directory
+   * <li> the home directory
+   * <li> the class path
+   * </ol>
+   * Only the first file found will be used.
+   * <p>
+   * The default value is {@link #PROPERTIES_FILE_DEFAULT}. However 
+   * if the <code>PROPERTIES_FILE_PROPERTY</code> is set then its value 
+   * will be used instead of the default. If this value is a relative file
+   * system path then the above search is done.  If it is an absolute
+   * file system path then that file must exist; no search for it is
+   * done.
+   * 
+   * @see #PROPERTIES_FILE_DEFAULT
+   * @see #getPropertiesFile()
+   * @since 9.0
+   */
+  public static final String PROPERTIES_FILE_PROPERTY = "gemfirePropertyFile";
+  
+  /** 
+   * The default value of <code>PROPERTIES_FILE_PROPERTY</code> is
+   * <code>"gemfire.properties"</code>. The location of the file will be 
+   * resolved during connect as described for {@link #PROPERTIES_FILE_PROPERTY}.
+   * 
+   * @see #PROPERTIES_FILE_PROPERTY
+   * @see #getPropertiesFile()
+   * @since 9.0
+   */
+  public static final String PROPERTIES_FILE_DEFAULT = "gemfire.properties";
 
   /**
+   * Returns the current value of {@link #PROPERTIES_FILE_PROPERTY} system 
+   * property if set or the default value {@link #PROPERTIES_FILE_DEFAULT}.
+   * 
+   * @see #PROPERTIES_FILE_PROPERTY
+   * @see #PROPERTIES_FILE_DEFAULT
+   * @since 9.0
+   */
+  public static String getPropertiesFile() {
+	return System.getProperty(PROPERTIES_FILE_PROPERTY, PROPERTIES_FILE_DEFAULT);
+  }
+  
+  /**
    * The <code>PROPERTY_FILE</code> is the name of the
-   * property file that the connect method will check for when
-   * it looks for a property file.
+   * properties file that the connect method will check for when
+   * it looks for a properties file.
    * The file will be searched for, in order, in the following directories:
    * <ol>
    * <li> the current directory
@@ -1978,60 +2011,139 @@ public abstract class DistributedSystem implements StatisticsFactory {
    * system path then the above search is done.  If it is an absolute
    * file system path then that file must exist; no search for it is
    * done.
+   * 
+   * @see #getPropertiesFile()
    * @since 5.0
-   *  */
-  public static final String PROPERTY_FILE = System.getProperty("gemfirePropertyFile", "gemfire.properties");
+   * @deprecated As of 9.0, please use {@link #getPropertiesFile()} instead. 
+   */
+  public static String PROPERTY_FILE = getPropertiesFile();
+
+  /**
+   * The <code>SECURITY_PROPERTIES_FILE_PROPERTY</code> is the system property
+   * that can be used to specify the name of the property file that the 
+   * connect method will check for when it looks for a property file. Unless
+   * the value specifies the fully qualified path to the file, the file will 
+   * be searched for, in order, in the following directories:
+   * <ol>
+   * <li> the current directory
+   * <li> the home directory
+   * <li> the class path
+   * </ol>
+   * Only the first file found will be used.
+   * <p>
+   * The default value is {@link #SECURITY_PROPERTIES_FILE_DEFAULT}. However 
+   * if the <code>SECURITY_PROPERTIES_FILE_PROPERTY</code> is set then its value 
+   * will be used instead of the default. If this value is a relative file
+   * system path then the above search is done.  If it is an absolute
+   * file system path then that file must exist; no search for it is
+   * done.
+   * 
+   * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+   * @see #getSecurityPropertiesFile()
+   * @since 9.0
+   */
+  public static final String SECURITY_PROPERTIES_FILE_PROPERTY = "gemfireSecurityPropertyFile";
+  
+  /** 
+   * The default value of <code>SECURITY_PROPERTIES_FILE_PROPERTY</code> is
+   * <code>"gfsecurity.properties"</code>. The location of the file will be 
+   * resolved during connect as described for {@link #SECURITY_PROPERTIES_FILE_PROPERTY}.
+   * 
+   * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+   * @see #getSecurityPropertiesFile()
+   * @since 9.0
+   */
+  public static final String SECURITY_PROPERTIES_FILE_DEFAULT = "gfsecurity.properties";
 
   /**
+   * Returns the current value of {@link #SECURITY_PROPERTIES_FILE_PROPERTY} system 
+   * property if set or the default value {@link #SECURITY_PROPERTIES_FILE_DEFAULT}.
+   * 
+   * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+   * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+   * @since 9.0
+   */
+  public static String getSecurityPropertiesFile() {
+	return System.getProperty(SECURITY_PROPERTIES_FILE_PROPERTY, SECURITY_PROPERTIES_FILE_DEFAULT);
+  }
+  
+  /**
    * The <code>SECURITY_PROPERTY_FILE</code> is the name of the
-     * property file that the connect method will check for when
-     * it looks for a security property file.
-     * The file will be searched for, in order, in the following directories:
-     * <ol>
-     * <li> the current directory
-     * <li> the home directory
-     * <li> the class path
-     * </ol>
-     * Only the first file found will be used.
-     * <p>
-     * The default value of SECURITY_PROPERTY_FILE is
-     * <code>"gfsecurity.properties"</code>.  However if the
-     * "gemfireSecurityPropertyFile" system property is set then its value is
-     * the value of SECURITY_PROPERTY_FILE. If this value is a relative file
-     * system path then the above search is done.  If it is an absolute
-     * file system path then that file must exist; no search for it is
-     * done.
-     * @since 6.6.2
+   * property file that the connect method will check for when
+   * it looks for a security property file.
+   * The file will be searched for, in order, in the following directories:
+   * <ol>
+   * <li> the current directory
+   * <li> the home directory
+   * <li> the class path
+   * </ol>
+   * Only the first file found will be used.
+   * <p>
+   * The default value of SECURITY_PROPERTY_FILE is
+   * <code>"gfsecurity.properties"</code>.  However if the
+   * "gemfireSecurityPropertyFile" system property is set then its value is
+   * the value of SECURITY_PROPERTY_FILE. If this value is a relative file
+   * system path then the above search is done.  If it is an absolute
+   * file system path then that file must exist; no search for it is
+   * done.
+   * 
+   * @see #getSecurityPropertiesFile()
+   * @since 6.6.2
+   * @deprecated As of 9.0, please use {@link #getSecurityPropertiesFile()} instead. 
    */
-  public static final String SECURITY_PROPERTY_FILE = System.getProperty("gemfireSecurityPropertyFile",
-    "gfsecurity.properties");
+  public static String SECURITY_PROPERTY_FILE = getSecurityPropertiesFile();
+
+  /**
+   * Gets an <code>URL</code> for the properties file, if one can be found,
+   * that the connect method will use as its properties file.
+   * <p>
+   * See {@link #PROPERTIES_FILE_PROPERTY} for information on the name of
+   * the properties file and what locations it will be looked for in.
+   * 
+   * @return a <code>URL</code> that names the GemFire property file.
+   *    Null is returned if no property file was found.
+   * @see #PROPERTIES_FILE_PROPERTY
+   * @see #PROPERTIES_FILE_DEFAULT
+   * @see #getPropertiesFile()
+   * @since 9.0
+   */
+  public static URL getPropertiesFileURL() {
+    return getFileURL(getPropertiesFile());
+  }
 
   /**
    * Gets an <code>URL</code> for the property file, if one can be found,
    * that the connect method will use as its property file.
    * <p>
-   * See {@link #PROPERTY_FILE} for information on the name of
+   * See {@link #PROPERTIES_FILE_PROPERTY} for information on the name of
    * the property file and what locations it will be looked for in.
+   * 
    * @return a <code>URL</code> that names the GemFire property file.
    *    Null is returned if no property file was found.
+   * @see #getPropertiesFileURL()
    * @since 5.0
+   * @deprecated As of 9.0, please use {@link #getPropertiesFileURL()}
    */
   public static URL getPropertyFileURL() {
-    return getFileURL(PROPERTY_FILE);
+    return getPropertiesFileURL();
   }
 
   /**
-   * Gets an <code>URL</code> for the security property file, if one can be found,
-   * that the connect method will use as its property file.
+   * Gets an <code>URL</code> for the security properties file, if one can be found,
+   * that the connect method will use as its properties file.
    * <p>
-   * See {@link #SECURITY_PROPERTY_FILE} for information on the name of
-   * the property file and what locations it will be looked for in.
-   * @return a <code>URL</code> that names the GemFire security property file.
-   *    Null is returned if no property file was found.
+   * See {@link #SECURITY_PROPERTIES_FILE_PROPERTY} for information on the name of
+   * the properties file and what locations it will be looked for in.
+   * 
+   * @return a <code>URL</code> that names the GemFire security properties file.
+   *    Null is returned if no properties file was found.
+   * @see #SECURITY_PROPERTIES_FILE_PROPERTY
+   * @see #SECURITY_PROPERTIES_FILE_DEFAULT
+   * @see #getSecurityPropertiesFile()
    * @since 6.6.2
    */
   public static URL getSecurityPropertiesFileURL() {
-    return getFileURL(SECURITY_PROPERTY_FILE);
+    return getFileURL(getSecurityPropertiesFile());
   }
 
   private static URL getFileURL(String fileName) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..745090d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherIntegrationJUnitTest.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 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/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
index 399c78f..7b8a6bb 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/AbstractLauncherJUnitTest.java
@@ -18,8 +18,6 @@ package com.gemstone.gemfire.distributed;
 
 import static org.junit.Assert.*;
 
-import java.io.File;
-import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Properties;
@@ -45,10 +43,10 @@ import org.junit.experimental.categories.Category;
  * @since 7.0
  */
 @Category(UnitTest.class)
-public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
+public class AbstractLauncherJUnitTest {
 
   protected AbstractLauncher<?> createAbstractLauncher(final String memberName, final String memberId) {
-    return new TestServiceLauncher(memberName, memberId);
+    return new FakeServiceLauncher(memberName, memberId);
   }
 
   @Test
@@ -111,26 +109,6 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testLoadGemFirePropertiesFromFile() throws IOException {
-    final Properties expectedGemfireProperties = new Properties();
-
-    expectedGemfireProperties.setProperty(DistributionConfig.NAME_NAME, "memberOne");
-    expectedGemfireProperties.setProperty(DistributionConfig.GROUPS_NAME, "groupOne, groupTwo");
-
-    final File gemfirePropertiesFile = writeGemFirePropertiesToFile(expectedGemfireProperties, "gemfire.properties",
-      "Test gemfire.properties file for AbstractLauncherJUnitTest.testLoadGemFirePropertiesFromFile");
-
-    assertNotNull(gemfirePropertiesFile);
-    assertTrue(gemfirePropertiesFile.isFile());
-
-    final Properties actualGemFireProperties = AbstractLauncher.loadGemFireProperties(
-      gemfirePropertiesFile.toURI().toURL());
-
-    assertNotNull(actualGemFireProperties);
-    assertEquals(expectedGemfireProperties, actualGemFireProperties);
-  }
-
-  @Test
   public void testGetDistributedSystemProperties() {
     AbstractLauncher<?> launcher = createAbstractLauncher("memberOne", "1");
 
@@ -274,12 +252,12 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
       TimeUnit.DAYS.toMillis(2) + TimeUnit.HOURS.toMillis(1) + TimeUnit.MINUTES.toMillis(30) + TimeUnit.SECONDS.toMillis(1)));
   }
 
-  protected static final class TestServiceLauncher extends AbstractLauncher<String> {
+  protected static final class FakeServiceLauncher extends AbstractLauncher<String> {
 
     private final String memberId;
     private final String memberName;
 
-    public TestServiceLauncher(final String memberName, final String memberId) {
+    public FakeServiceLauncher(final String memberName, final String memberId) {
       this.memberId = memberId;
       this.memberName = memberName;
     }
@@ -289,6 +267,7 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
       return false;
     }
 
+    @Override
     public String getLogFileName() {
       throw new UnsupportedOperationException("Not Implemented!");
     }
@@ -298,22 +277,22 @@ public class AbstractLauncherJUnitTest extends CommonLauncherTestSuite {
       return memberId;
     }
 
+    @Override
     public String getMemberName() {
       return memberName;
     }
 
+    @Override
     public Integer getPid() {
       throw new UnsupportedOperationException("Not Implemented!");
     }
 
+    @Override
     public String getServiceName() {
       return "TestService";
     }
 
-    public String getId() {
-      throw new UnsupportedOperationException("Not Implemented!");
-    }
-
+    @Override
     public void run() {
       throw new UnsupportedOperationException("Not Implemented!");
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
deleted file mode 100644
index 94ba320..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/CommonLauncherTestSuite.java
+++ /dev/null
@@ -1,65 +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.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Properties;
-
-import org.junit.Rule;
-import org.junit.contrib.java.lang.system.RestoreSystemProperties;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-
-/**
- * The CommonLauncherTestSuite is a base class for encapsulating reusable functionality across the various, specific
- * launcher test suites.
- * </p>
- * @author John Blum
- * @see com.gemstone.gemfire.distributed.AbstractLauncherJUnitTest
- * @see com.gemstone.gemfire.distributed.LocatorLauncherJUnitTest
- * @see com.gemstone.gemfire.distributed.ServerLauncherJUnitTest
- * @since 7.0
- */
-public abstract class CommonLauncherTestSuite {
-
-  @Rule
-  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
-  
-  @Rule
-  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
-  
-  @Rule
-  public final TestName testName = new TestName();
-  
-  protected File writeGemFirePropertiesToFile(final Properties gemfireProperties,
-                                              final String filename,
-                                              final String comment)
-  {
-    try {
-      final File gemfirePropertiesFile = this.temporaryFolder.newFile(filename);
-      gemfireProperties.store(new FileWriter(gemfirePropertiesFile, false), comment);
-      return gemfirePropertiesFile;
-    }
-    catch (IOException e) {
-      return null;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemIntegrationJUnitTest.java
new file mode 100755
index 0000000..d54dfd0
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemIntegrationJUnitTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.net.URL;
+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.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for DistributedSystem class. These tests require file system I/O.
+ */
+@Category(IntegrationTest.class)
+public class DistributedSystemIntegrationJUnitTest {
+
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TemporaryFolder temporaryFolder = new TemporaryFolder();
+  
+  @Rule
+  public final TestName testName = new TestName();
+  
+  @Test
+  public void getPropertiesFileShouldUsePathInSystemProperty() throws Exception {
+    File propertiesFile = this.temporaryFolder.newFile("test.properties");
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    Properties properties = new Properties();
+    properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+
+    assertThat(DistributedSystem.getPropertiesFile()).isEqualTo(propertiesFile.getCanonicalPath());
+  }
+  
+  @Test
+  public void getPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
+    File propertiesFile = this.temporaryFolder.newFile("test.properties");
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    Properties properties = new Properties();
+    properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+
+    URL propertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
+    assertThat(DistributedSystem.getPropertiesFileURL()).isEqualTo(propertiesURL);
+  }
+  
+  @Test
+  public void getSecurityPropertiesFileShouldUsePathInSystemProperty() throws Exception {
+    File propertiesFile = this.temporaryFolder.newFile("testsecurity.properties");
+    System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    Properties properties = new Properties();
+    properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+
+    assertThat(DistributedSystem.getSecurityPropertiesFile()).isEqualTo(propertiesFile.getCanonicalPath());
+  }
+  
+  @Test
+  public void getSecurityPropertiesFileUrlShouldUsePathInSystemProperty() throws Exception {
+    File propertiesFile = this.temporaryFolder.newFile("testsecurity.properties");
+    System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFile.getCanonicalPath());
+    Properties properties = new Properties();
+    properties.store(new FileWriter(propertiesFile, false), this.testName.getMethodName());
+
+    URL propertiesURL = propertiesFile.getCanonicalFile().toURI().toURL();
+    assertThat(DistributedSystem.getSecurityPropertiesFileURL()).isEqualTo(propertiesURL);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemJUnitTest.java
new file mode 100755
index 0000000..56a9646
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/DistributedSystemJUnitTest.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+
+/**
+ * Unit tests for DistributedSystem class.
+ */
+@Category(UnitTest.class)
+public class DistributedSystemJUnitTest {
+  
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Test
+  public void getPropertiesFileShouldUseDefault() throws Exception {
+    assertThat(DistributedSystem.getPropertiesFile()).isEqualTo(DistributedSystem.PROPERTIES_FILE_DEFAULT);
+  }
+  
+  @Test
+  public void getPropertiesFileShouldUseSystemProperty() throws Exception {
+    String propertiesFileName = "test.properties";
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFileName);
+    
+    assertThat(DistributedSystem.getPropertiesFile()).isEqualTo(propertiesFileName);
+  }
+  
+  @Test
+  public void getPropertiesFileShouldUseSystemPropertyPath() throws Exception {
+    String propertiesFileName = "/home/test.properties";
+    System.setProperty(DistributedSystem.PROPERTIES_FILE_PROPERTY, propertiesFileName);
+    
+    assertThat(DistributedSystem.getPropertiesFile()).isEqualTo(propertiesFileName);
+  }
+  
+  @Test
+  public void getSecurityPropertiesFileShouldUseDefault() throws Exception {
+    assertThat(DistributedSystem.getSecurityPropertiesFile()).isEqualTo(DistributedSystem.SECURITY_PROPERTIES_FILE_DEFAULT);
+  }
+  
+  @Test
+  public void getSecurityPropertiesFileShouldUseSystemProperty() throws Exception {
+    String propertiesFileName = "testsecurity.properties";
+    System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFileName);
+    
+    assertThat(DistributedSystem.getSecurityPropertiesFile()).isEqualTo(propertiesFileName);
+  }
+  
+  @Test
+  public void getSecurityPropertiesFileShouldUseSystemPropertyPath() throws Exception {
+    String propertiesFileName = "/home/testsecurity.properties";
+    System.setProperty(DistributedSystem.SECURITY_PROPERTIES_FILE_PROPERTY, propertiesFileName);
+    
+    assertThat(DistributedSystem.getSecurityPropertiesFile()).isEqualTo(propertiesFileName);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..3b56554
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherIntegrationJUnitTest.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 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/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
index 003a098..c1b6ed0 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherJUnitTest.java
@@ -17,14 +17,9 @@
 package com.gemstone.gemfire.distributed;
 
 import static org.junit.Assert.*;
-import static org.junit.Assume.*;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
-import java.util.Properties;
 
 import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
 import com.gemstone.gemfire.distributed.LocatorLauncher.Command;
@@ -34,8 +29,11 @@ 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
@@ -52,46 +50,13 @@ import org.junit.experimental.categories.Category;
  * @since 7.0
  */
 @Category(UnitTest.class)
-public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
+public class LocatorLauncherJUnitTest {
 
-  @Test
-  public void testBuilderParseArguments() throws Exception {
-    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    Builder builder = new Builder();
-
-    builder.parseArguments("start", "memberOne", "--bind-address", InetAddress.getLocalHost().getHostAddress(),
-      "--dir", expectedWorkingDirectory, "--hostname-for-clients", "Tucows", "--pid", "1234", "--port", "11235",
-        "--redirect-output", "--force", "--debug");
-
-    assertEquals(Command.START, builder.getCommand());
-    assertEquals(InetAddress.getLocalHost(), builder.getBindAddress());
-    assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
-    assertEquals("Tucows", builder.getHostnameForClients());
-    assertEquals(1234, builder.getPid().intValue());
-    assertEquals(11235, builder.getPort().intValue());
-    assertTrue(builder.getRedirectOutput());
-    assertTrue(builder.getForce());
-    assertTrue(builder.getDebug());
-  }
-
-  @Test
-  public void testBuilderParseArgumentsWithCommandInArguments() throws Exception {
-    String expectedWorkingDirectory = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    Builder builder = new Builder();
-
-    builder.parseArguments("start", "--dir=" + expectedWorkingDirectory, "--port", "12345", "memberOne");
-
-    assertEquals(Command.START, builder.getCommand());
-    assertFalse(Boolean.TRUE.equals(builder.getDebug()));
-    assertFalse(Boolean.TRUE.equals(builder.getForce()));
-    assertFalse(Boolean.TRUE.equals(builder.getHelp()));
-    assertNull(builder.getBindAddress());
-    assertNull(builder.getHostnameForClients());
-    assertEquals("12345", builder.getMemberName());
-    assertNull(builder.getPid());
-    assertEquals(expectedWorkingDirectory, builder.getWorkingDirectory());
-    assertEquals(12345, builder.getPort().intValue());
-  }
+  @Rule
+  public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+  
+  @Rule
+  public final TestName testName = new TestName();
 
   @Test(expected = IllegalArgumentException.class)
   public void testBuilderParseArgumentsWithNonNumericPort() {
@@ -307,59 +272,6 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testSetAndGetWorkingDirectory() throws Exception {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    Builder builder = new Builder();
-
-    assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(null));
-    assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(""));
-    assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory("  "));
-    assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(rootFolder));
-    assertEquals(rootFolder, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(null));
-    assertEquals(AbstractLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetWorkingDirectoryToFile() throws IOException {
-    File tmpFile = File.createTempFile("tmp", "file");
-
-    assertNotNull(tmpFile);
-    assertTrue(tmpFile.isFile());
-
-    tmpFile.deleteOnExit();
-
-    try {
-      new Builder().setWorkingDirectory(tmpFile.getCanonicalPath());
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
-        .toLocalizedString("Locator"), expected.getMessage());
-      assertTrue(expected.getCause() instanceof FileNotFoundException);
-      assertEquals(tmpFile.getCanonicalPath(), expected.getCause().getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetWorkingDirectoryToNonExistingDirectory() {
-    try {
-      new Builder().setWorkingDirectory("/path/to/non_existing/directory");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
-        .toLocalizedString("Locator"), expected.getMessage());
-      assertTrue(expected.getCause() instanceof FileNotFoundException);
-      assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
   public void testBuild() throws Exception {
     Builder builder = new Builder();
 
@@ -396,26 +308,6 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testBuildWithMemberNameSetInGemfirePropertiesOnStart() throws Exception {
-    System.setProperty("user.dir", this.temporaryFolder.getRoot().getCanonicalPath());
-    
-    Properties gemfireProperties = new Properties();
-    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "locator123");
-    File gemfirePropertiesFile = writeGemFirePropertiesToFile(gemfireProperties, "gemfire.properties",
-      String.format("Test gemfire.properties file for %1$s.%2$s.", getClass().getSimpleName(),
-        "testBuildWithMemberNameSetInGemfirePropertiesOnStart"));
-
-    assertNotNull(gemfirePropertiesFile);
-    assertTrue(gemfirePropertiesFile.isFile());
-
-    LocatorLauncher launcher = new Builder().setCommand(Command.START).setMemberName(null).build();
-
-    assertNotNull(launcher);
-    assertEquals(Command.START, launcher.getCommand());
-    assertNull(launcher.getMemberName());
-  }
-
-  @Test
   public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
     System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "locatorXYZ");
 
@@ -428,32 +320,4 @@ public class LocatorLauncherJUnitTest extends CommonLauncherTestSuite {
     assertEquals(LocatorLauncher.Command.START, launcher.getCommand());
     assertNull(launcher.getMemberName());
   }
-
-  @Test(expected = IllegalStateException.class)
-  public void testBuildWithNoMemberNameOnStart() throws Exception {
-    System.setProperty("user.dir", this.temporaryFolder.getRoot().getCanonicalPath());
-    try {
-      new Builder().setCommand(Command.START).build();
-    }
-    catch (IllegalStateException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_MEMBER_NAME_VALIDATION_ERROR_MESSAGE.toLocalizedString("Locator"),
-        expected.getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalStateException.class)
-  public void testBuildWithMismatchingCurrentAndWorkingDirectoryOnStart() throws Exception {
-    try {
-      new Builder().setCommand(Command.START)
-        .setMemberName("memberOne")
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath().toString())
-        .build();
-    }
-    catch (IllegalStateException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
-        .toLocalizedString("Locator"), expected.getMessage());
-      throw expected;
-    }
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.java
new file mode 100755
index 0000000..b61f89d
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherIntegrationJUnitTest.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 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/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
index 6884e58..802df9f 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/ServerLauncherJUnitTest.java
@@ -46,8 +46,11 @@ 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
@@ -65,10 +68,16 @@ import org.junit.experimental.categories.Category;
  */
 @SuppressWarnings({"deprecation", "unused"})
 @Category(UnitTest.class)
-public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
+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() {{
@@ -84,31 +93,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testParseArguments() throws Exception {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    Builder builder = new Builder();
-
-    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");
-
-    assertEquals(Command.START, builder.getCommand());
-    assertEquals("serverOne", builder.getMemberName());
-    assertEquals("192.168.99.100", builder.getHostNameForClients());
-    assertTrue(builder.getAssignBuckets());
-    assertTrue(builder.getDisableDefaultServer());
-    assertTrue(builder.getDebug());
-    assertTrue(builder.getForce());
-    assertFalse(Boolean.TRUE.equals(builder.getHelp()));
-    assertTrue(builder.getRebalance());
-    assertTrue(builder.getRedirectOutput());
-    assertEquals(rootFolder, builder.getWorkingDirectory());
-    assertEquals(1234, builder.getPid().intValue());
-    assertEquals(InetAddress.getLocalHost(), builder.getServerBindAddress());
-    assertEquals(11235, builder.getServerPort().intValue());
-  }
-
-  @Test
   public void testParseCommand() {
     Builder builder = new Builder();
 
@@ -323,57 +307,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testSetAndGetWorkingDirectory() throws Exception {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    Builder builder = new Builder();
-
-    assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(rootFolder));
-    assertEquals(rootFolder, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory("  "));
-    assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(""));
-    assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-    assertSame(builder, builder.setWorkingDirectory(null));
-    assertEquals(ServerLauncher.DEFAULT_WORKING_DIRECTORY, builder.getWorkingDirectory());
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetWorkingDirectoryToNonExistingDirectory() {
-    try {
-      new Builder().setWorkingDirectory("/path/to/non_existing/directory");
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
-        .toLocalizedString("Server"), expected.getMessage());
-      assertTrue(expected.getCause() instanceof FileNotFoundException);
-      assertEquals("/path/to/non_existing/directory", expected.getCause().getMessage());
-      throw expected;
-    }
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void testSetWorkingDirectoryToFile() throws IOException {
-    File tmpFile = File.createTempFile("tmp", "file");
-
-    assertNotNull(tmpFile);
-    assertTrue(tmpFile.isFile());
-
-    tmpFile.deleteOnExit();
-
-    try {
-      new Builder().setWorkingDirectory(tmpFile.getAbsolutePath());
-    }
-    catch (IllegalArgumentException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
-        .toLocalizedString("Server"), expected.getMessage());
-      assertTrue(expected.getCause() instanceof FileNotFoundException);
-      assertEquals(tmpFile.getAbsolutePath(), expected.getCause().getMessage());
-      throw expected;
-    }
-  }
-
-  @Test
   public void testSetAndGetCriticalHeapPercentage() {
     Builder builder = new Builder();
 
@@ -550,50 +483,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
   }
 
   @Test
-  public void testBuild() throws Exception {
-    String rootFolder = this.temporaryFolder.getRoot().getCanonicalPath().toString();
-    
-    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();
-
-    assertNotNull(launcher);
-    assertTrue(launcher.isAssignBuckets());
-    assertFalse(launcher.isDebugging());
-    assertFalse(launcher.isDisableDefaultServer());
-    assertTrue(launcher.isForcing());
-    assertFalse(launcher.isHelping());
-    assertTrue(launcher.isRebalancing());
-    assertFalse(launcher.isRunning());
-    assertEquals(Command.STOP, launcher.getCommand());
-    assertEquals("serverOne", launcher.getMemberName());
-    assertEquals(InetAddress.getLocalHost(), launcher.getServerBindAddress());
-    assertEquals(11235, launcher.getServerPort().intValue());
-    assertEquals(rootFolder, launcher.getWorkingDirectory());
-    assertEquals(90.0f, launcher.getCriticalHeapPercentage().floatValue(), 0.0f);
-    assertEquals(75.0f, launcher.getEvictionHeapPercentage().floatValue(), 0.0f);
-    assertEquals(100, launcher.getMaxConnections().intValue());
-    assertEquals(512, launcher.getMaxMessageCount().intValue());
-    assertEquals(8, launcher.getMaxThreads().intValue());
-    assertEquals(120000, launcher.getMessageTimeToLive().intValue());
-    assertEquals(32768, launcher.getSocketBufferSize().intValue());
-  }
-
-  @Test
   public void testBuildWithMemberNameSetInApiPropertiesOnStart() {
     ServerLauncher launcher = new Builder()
       .setCommand(ServerLauncher.Command.START)
@@ -607,24 +496,10 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
     assertEquals("serverABC", launcher.getProperties().getProperty(DistributionConfig.NAME_NAME));
   }
 
-  @Ignore("GEODE-69: We need to change DistributedSystem to not use static final for gemfirePropertyFile")
   @Test
-  public void testBuildWithMemberNameSetInGemFirePropertiesOnStart() {
-    Properties gemfireProperties = new Properties();
-
-    gemfireProperties.setProperty(DistributionConfig.NAME_NAME, "server123");
-
-    File gemfirePropertiesFile = writeGemFirePropertiesToFile(
-        gemfireProperties, 
-        "gemfire.properties",
-        String.format("Test gemfire.properties file for %1$s.%2$s.", getClass().getSimpleName(), this.testName.getMethodName()));
-
-    assertNotNull(gemfirePropertiesFile);
-    assertTrue(gemfirePropertiesFile.isFile());
+  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
+    System.setProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME, "serverXYZ");
 
-    System.setProperty("gemfirePropertyFile", gemfirePropertiesFile.getAbsolutePath());
-    System.out.println("gemfirePropertiesFile.getAbsolutePath()=" + gemfirePropertiesFile.getAbsolutePath());
-    
     ServerLauncher launcher = new Builder()
       .setCommand(ServerLauncher.Command.START)
       .setMemberName(null)
@@ -635,25 +510,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
     assertNull(launcher.getMemberName());
   }
 
-  @Test
-  public void testBuildWithMemberNameSetInSystemPropertiesOnStart() {
-    try {
-      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());
-    }
-    finally {
-      System.clearProperty(DistributionConfig.GEMFIRE_PREFIX + DistributionConfig.NAME_NAME);
-    }
-  }
-
   @Test(expected = IllegalStateException.class)
   public void testBuildNoMemberNameOnStart() {
     try {
@@ -666,21 +522,6 @@ public class ServerLauncherJUnitTest extends CommonLauncherTestSuite {
     }
   }
 
-  @Test(expected = IllegalStateException.class)
-  public void testBuildWithInvalidWorkingDirectoryOnStart() throws Exception {
-    try {
-      new Builder().setCommand(Command.START)
-        .setMemberName("serverOne")
-        .setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath().toString())
-        .build();
-    }
-    catch (IllegalStateException expected) {
-      assertEquals(LocalizedStrings.Launcher_Builder_WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
-        .toLocalizedString("Server"), expected.getMessage());
-      throw expected;
-    }
-  }
-
   @Test
   public void testIsServing() {
     final Cache mockCache = mockContext.mock(Cache.class, "Cache");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
index e99dceb..a2f02c4 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessOutputReader.java
@@ -16,83 +16,74 @@
  */
 package com.gemstone.gemfire.test.process;
 
-import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 /**
- * Reads the stdout and stderr from a running process and stores then for test 
- * validation. Also provides a mechanism to waitFor the process to terminate. 
+ * Starts the stdout and stderr reader threads for a running process. Provides
+ * a mechanism to waitFor the process to terminate.
+ * </p>
  * Extracted from ProcessWrapper.
  * 
  * @author Kirk Lund
  */
 public class ProcessOutputReader {
 
-  private static final long PROCESS_TIMEOUT_MILLIS = 10 * 60 * 1000L; // 10 minutes
-
-  private int exitCode;
+  private boolean started;
   
-  private final Process p;
+  private final Process process;
   private final ProcessStreamReader stdout;
   private final ProcessStreamReader stderr;
-  private final List<String> lines;
   
-  public ProcessOutputReader(final Process p, final ProcessStreamReader stdout, final ProcessStreamReader stderr, final List<String> lines) {
-    this.p = p;
+  public ProcessOutputReader(final Process process, final ProcessStreamReader stdout, final ProcessStreamReader stderr) {
+    this.process = process;
     this.stdout = stdout;
     this.stderr = stderr;
-    this.lines = lines;
   }
-  
-  public void waitFor() {
-    stdout.start();
-    stderr.start();
 
-    long startMillis = System.currentTimeMillis();
-    try {
-      stderr.join(PROCESS_TIMEOUT_MILLIS);
-    } catch (Exception ignore) {
+  public void start() {
+    synchronized(this) {
+      this.stdout.start();
+      this.stderr.start();
+      this.started = true;
     }
-
-    long timeLeft = System.currentTimeMillis() + PROCESS_TIMEOUT_MILLIS - startMillis;
-    try {
-      stdout.join(timeLeft);
-    } catch (Exception ignore) {
+  }
+  
+  public boolean waitFor(final long timeout, final TimeUnit unit) throws InterruptedException {
+    synchronized(this) {
+      if (!this.started) {
+        throw new IllegalStateException("Must be started before waitFor");
+      }
     }
+    
+    final long startTime = System.nanoTime();
+    
+    long millisToJoin = unit.toMillis(timeout);
+    this.stderr.join(millisToJoin);
 
-    this.exitCode = 0;
-    int retryCount = 9;
-    while (retryCount > 0) {
-      retryCount--;
+    long nanosRemaining = unit.toNanos(timeout) - (System.nanoTime() - startTime);
+    millisToJoin = unit.toMillis(nanosRemaining);
+    this.stdout.join(millisToJoin);
+
+    nanosRemaining = unit.toNanos(timeout) - (System.nanoTime() - startTime);
+    return waitForProcess(nanosRemaining, unit);
+  }
+
+  private boolean waitForProcess(final long timeout, final TimeUnit unit) throws InterruptedException {
+    long startTime = System.nanoTime();
+    long nanosRemaining = unit.toNanos(timeout);
+
+    while (nanosRemaining > 0) {
       try {
-        exitCode = p.exitValue();
-        break;
-      } catch (IllegalThreadStateException e) {
-        // due to bugs in Process we may not be able to get
-        // a process's exit value.
-        // We can't use Process.waitFor() because it can hang forever
-        if (retryCount == 0) {
-          if (stderr.linecount > 0) {
-            // The process wrote to stderr so manufacture
-            // an error exist code
-            synchronized (lines) {
-              lines.add("Failed to get exit status and it wrote"
-                  + " to stderr so setting exit status to 1.");
-            }
-            exitCode = 1;
-          }
-        } else {
-          // We need to wait around to give a chance for
-          // the child to be reaped.See bug 19682
-          try {
-            Thread.sleep(1000);
-          } catch (InterruptedException ignore) {
-          }
+        this.process.exitValue();
+        return true;
+      } catch(IllegalThreadStateException ex) {
+        if (nanosRemaining > 0) {
+          long millisToSleep =Math.min(TimeUnit.NANOSECONDS.toMillis(nanosRemaining) + 1, 100);
+          Thread.sleep(millisToSleep);
         }
       }
+      nanosRemaining = unit.toNanos(timeout) - (System.nanoTime() - startTime);
     }
-  }
-
-  public int getExitCode() {
-    return exitCode;
+    return false;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fe295940/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessStreamReader.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessStreamReader.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessStreamReader.java
index f99f5f9..de546b5 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessStreamReader.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/process/ProcessStreamReader.java
@@ -17,20 +17,23 @@
 package com.gemstone.gemfire.test.process;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.List;
 import java.util.Queue;
 
 /**
- * Reads the output from a stream and stores it for test validation. Extracted
- * from ProcessWrapper.
+ * Reads the output from a process stream and stores it for test validation. 
+ * </p>
+ * Extracted from ProcessWrapper.
  * 
  * @author Kirk Lund
  */
 public class ProcessStreamReader extends Thread {
   
-  private volatile Throwable startStack;
+  private volatile RuntimeException startStack;
+  
   private final String command;
   private final BufferedReader reader;
   private final Queue<String> lineBuffer;
@@ -38,28 +41,16 @@ public class ProcessStreamReader extends Thread {
 
   public int linecount = 0;
 
-  public ProcessStreamReader(String command, InputStream stream, Queue<String> lineBuffer, List<String> allLines) {
+  public ProcessStreamReader(final String command, final InputStream stream, final Queue<String> lineBuffer, final List<String> allLines) {
     this.command = command;
     this.reader = new BufferedReader(new InputStreamReader(stream));
     this.lineBuffer = lineBuffer;
     this.allLines = allLines;
   }
 
-  public Throwable getStart() {
-    return this.startStack;
-  }
-  
-  public Throwable getFailure() {
-    if (this.startStack.getCause() != null) {
-      return this.startStack.getCause();
-    } else {
-      return null;
-    }
-  }
-  
   @Override
   public void start() {
-    this.startStack = new Throwable();
+    this.startStack = new RuntimeException(this.command);
     super.start();
   }
   
@@ -67,18 +58,17 @@ public class ProcessStreamReader extends Thread {
   public void run() {
     try {
       String line;
-      while ((line = reader.readLine()) != null) {
-        linecount++;
-        lineBuffer.offer(line);
-        allLines.add(line);
+      while ((line = this.reader.readLine()) != null) {
+        this.linecount++;
+        this.lineBuffer.offer(line);
+        this.allLines.add(line);
       }
 
       // EOF
-      reader.close();
-    } catch (Exception cause) {
-      this.startStack.initCause(cause);
-      System.err.println("ProcessStreamReader: Failure while reading from child process: " + this.command + " " + this.startStack.getMessage());
-      this.startStack.printStackTrace();
+      this.reader.close();
+    } catch (IOException streamClosed) {
+      this.startStack.initCause(streamClosed);
+      throw this.startStack;
     }
   }
 }



Mime
View raw message