geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [13/37] incubator-geode git commit: GEODE-1255: Add test coverage for using a custom log4j2.xml with Geode
Date Fri, 06 May 2016 21:40:44 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/566fce96/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
new file mode 100644
index 0000000..2e84905
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration.CONFIG_LAYOUT_PREFIX;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemOutRule;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.logging.log4j.custom.CustomConfiguration;
+import com.gemstone.gemfire.internal.process.ProcessStreamReader;
+import com.gemstone.gemfire.internal.process.ProcessType;
+import com.gemstone.gemfire.internal.process.ProcessUtils;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests for launching a Locator in a forked process with custom logging configuration
+ */
+@Category(IntegrationTest.class)
+public class LocatorLauncherRemoteWithCustomLoggingIntegrationTest extends AbstractLocatorLauncherRemoteIntegrationTestCase {
+
+  private File customConfigFile;
+
+  @Rule
+  public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+  @Before
+  public void setUpLocatorLauncherRemoteWithCustomLoggingIntegrationTest() throws Exception {
+    this.customConfigFile = CustomConfiguration.createConfigFileIn(this.temporaryFolder.getRoot());
+  }
+
+  @Test
+  public void testStartUsesCustomLoggingConfiguration() throws Throwable {
+    // build and start the locator
+    final List<String> jvmArguments = getJvmArguments();
+
+    final List<String> command = new ArrayList<String>();
+    command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+    for (String jvmArgument : jvmArguments) {
+      command.add(jvmArgument);
+    }
+    command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "=" + this.customConfigFile.getCanonicalPath());
+    command.add("-cp");
+    command.add(System.getProperty("java.class.path"));
+    command.add(LocatorLauncher.class.getName());
+    command.add(LocatorLauncher.Command.START.getName());
+    command.add(getUniqueName());
+    command.add("--port=" + this.locatorPort);
+    command.add("--redirect-output");
+
+    this.process = new ProcessBuilder(command).directory(new File(this.workingDirectory)).start();
+    this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
+    this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
+
+    int pid = 0;
+    this.launcher = new LocatorLauncher.Builder()
+            .setWorkingDirectory(workingDirectory)
+            .build();
+    try {
+      waitForLocatorToStart(this.launcher);
+
+      // validate the pid file and its contents
+      this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+      assertTrue(this.pidFile.exists());
+      pid = readPid(this.pidFile);
+      assertTrue(pid > 0);
+      assertTrue(ProcessUtils.isProcessAlive(pid));
+
+      final String logFileName = getUniqueName()+".log";
+      assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+      // check the status
+      final LocatorLauncher.LocatorState locatorState = this.launcher.status();
+      assertNotNull(locatorState);
+      assertEquals(AbstractLauncher.Status.ONLINE, locatorState.getStatus());
+
+      assertThat(systemOutRule.getLog()).contains("log4j.configurationFile = " + this.customConfigFile.getCanonicalPath());
+      assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
+
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+
+    // stop the locator
+    try {
+      assertEquals(AbstractLauncher.Status.STOPPED, this.launcher.stop().getStatus());
+      waitForPidToStop(pid);
+    } catch (Throwable e) {
+      this.errorCollector.addError(e);
+    }
+  }
+
+  private static class ToSystemOut implements ProcessStreamReader.InputListener {
+    @Override
+    public void notifyInputLine(String line) {
+      System.out.println(line);
+    }
+  }
+
+}

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

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

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

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/566fce96/geode-core/src/test/java/com/gemstone/gemfire/distributed/MockServerLauncherCacheProvider.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/MockServerLauncherCacheProvider.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/MockServerLauncherCacheProvider.java
index c910832..aa7cd76 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/MockServerLauncherCacheProvider.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/MockServerLauncherCacheProvider.java
@@ -20,11 +20,10 @@ import java.util.Properties;
 
 import com.gemstone.gemfire.cache.Cache;
 
-public class MockServerLauncherCacheProvider
-    implements ServerLauncherCacheProvider {
+public class MockServerLauncherCacheProvider implements ServerLauncherCacheProvider {
+
   private static Cache cache;
 
-  
   public static Cache getCache() {
     return cache;
   }
@@ -34,8 +33,7 @@ public class MockServerLauncherCacheProvider
   }
 
   @Override
-  public Cache createCache(Properties gemfireProperties,
-      ServerLauncher serverLauncher) {
+  public Cache createCache(Properties gemfireProperties, ServerLauncher serverLauncher) {
     return cache;
   }
 

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

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


Mime
View raw message