Repository: geode
Updated Branches:
  refs/heads/develop 8a10c1aac -> d5bde9fb6


GEODE-2933: Add jmx-manager-hostname-for-clients for startLocator


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

Branch: refs/heads/develop
Commit: d5bde9fb69ab511de1a6c98ce7a16aae0a143326
Parents: 0ef7f56
Author: Jared Stewart <jstew...@pivotal.io>
Authored: Mon Jun 5 10:54:13 2017 -0700
Committer: Jared Stewart <jstew...@pivotal.io>
Committed: Fri Jun 9 15:17:11 2017 -0700

----------------------------------------------------------------------
 .../cli/commands/LauncherLifecycleCommands.java | 95 ++++++++++---------
 .../internal/cli/i18n/CliStrings.java           |  6 ++
 .../cli/GfshParserAutoCompletionTest.java       | 24 ++---
 .../internal/cli/GfshParserParsingTest.java     |  9 +-
 .../commands/LauncherLifecycleCommandsTest.java | 97 +++++++++++++++++---
 5 files changed, 157 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/d5bde9fb/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 89a236b..45fbf1b 100755
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -22,6 +22,7 @@ import static 
org.apache.geode.distributed.ConfigurationProperties.ENABLE_TIME_S
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static 
org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_BIND_ADDRESS;
 import static 
org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static 
org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS;
 import static 
org.apache.geode.distributed.ConfigurationProperties.LOAD_CLUSTER_CONFIGURATION_FROM_DIR;
 import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
 import static 
org.apache.geode.distributed.ConfigurationProperties.LOCATOR_WAIT_TIME;
@@ -48,6 +49,7 @@ import org.apache.commons.lang.ArrayUtils;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.server.CacheServer;
 import org.apache.geode.distributed.AbstractLauncher;
+import org.apache.geode.distributed.ConfigurationProperties;
 import org.apache.geode.distributed.LocatorLauncher;
 import org.apache.geode.distributed.LocatorLauncher.LocatorState;
 import org.apache.geode.distributed.ServerLauncher;
@@ -170,6 +172,8 @@ public class LauncherLifecycleCommands implements 
GfshCommand {
           help = CliStrings.START_LOCATOR__GROUP__HELP) final String group,
       @CliOption(key = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS,
           help = CliStrings.START_LOCATOR__HOSTNAME_FOR_CLIENTS__HELP) final 
String hostnameForClients,
+      @CliOption(key = 
ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS,
+          help = 
CliStrings.START_LOCATOR__JMX_MANAGER_HOSTNAME_FOR_CLIENTS__HELP) final String 
jmxManagerHostnameForClients,
       @CliOption(key = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH,
           specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
           help = CliStrings.START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH__HELP) 
final Boolean includeSystemClasspath,
@@ -246,20 +250,20 @@ public class LauncherLifecycleCommands implements 
GfshCommand {
 
       Properties gemfireProperties = new Properties();
 
-      gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group));
-      gemfireProperties.setProperty(LOCATORS, 
StringUtils.defaultString(locators));
-      gemfireProperties.setProperty(LOG_LEVEL, 
StringUtils.defaultString(logLevel));
-      gemfireProperties.setProperty(MCAST_ADDRESS, 
StringUtils.defaultString(mcastBindAddress));
-      gemfireProperties.setProperty(MCAST_PORT, 
StringUtils.defaultString(mcastPort));
-      gemfireProperties.setProperty(ENABLE_CLUSTER_CONFIGURATION,
-          StringUtils.defaultString(enableSharedConfiguration));
-      gemfireProperties.setProperty(LOAD_CLUSTER_CONFIGURATION_FROM_DIR,
-          StringUtils.defaultString(loadSharedConfigurationFromDirectory));
-      gemfireProperties.setProperty(CLUSTER_CONFIGURATION_DIR,
-          StringUtils.defaultString(clusterConfigDir));
-      gemfireProperties.setProperty(HTTP_SERVICE_PORT, 
StringUtils.defaultString(httpServicePort));
-      gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,
-          StringUtils.defaultString(httpServiceBindAddress));
+      setPropertyIfNotNull(gemfireProperties, GROUPS, group);
+      setPropertyIfNotNull(gemfireProperties, LOCATORS, locators);
+      setPropertyIfNotNull(gemfireProperties, LOG_LEVEL, logLevel);
+      setPropertyIfNotNull(gemfireProperties, MCAST_ADDRESS, mcastBindAddress);
+      setPropertyIfNotNull(gemfireProperties, MCAST_PORT, mcastPort);
+      setPropertyIfNotNull(gemfireProperties, ENABLE_CLUSTER_CONFIGURATION,
+          enableSharedConfiguration);
+      setPropertyIfNotNull(gemfireProperties, 
LOAD_CLUSTER_CONFIGURATION_FROM_DIR,
+          loadSharedConfigurationFromDirectory);
+      setPropertyIfNotNull(gemfireProperties, CLUSTER_CONFIGURATION_DIR, 
clusterConfigDir);
+      setPropertyIfNotNull(gemfireProperties, HTTP_SERVICE_PORT, 
httpServicePort);
+      setPropertyIfNotNull(gemfireProperties, HTTP_SERVICE_BIND_ADDRESS, 
httpServiceBindAddress);
+      setPropertyIfNotNull(gemfireProperties, JMX_MANAGER_HOSTNAME_FOR_CLIENTS,
+          jmxManagerHostnameForClients);
 
 
       // read the OSProcess enable redirect system property here -- TODO: 
replace with new GFSH
@@ -424,6 +428,12 @@ public class LauncherLifecycleCommands implements 
GfshCommand {
     }
   }
 
+  private void setPropertyIfNotNull(Properties properties, String key, Object 
value) {
+    if (key != null && value != null) {
+      properties.setProperty(key, value.toString());
+    }
+  }
+
   protected String[] createStartLocatorCommandLine(final LocatorLauncher 
launcher,
       final String gemfirePropertiesPathname, final String 
gemfireSecurityPropertiesPathname,
       final Properties gemfireProperties, final String userClasspath,
@@ -868,6 +878,8 @@ public class LauncherLifecycleCommands implements 
GfshCommand {
           help = CliStrings.START_SERVER__GROUP__HELP) final String group,
       @CliOption(key = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS,
           help = CliStrings.START_SERVER__HOSTNAME__FOR__CLIENTS__HELP) final 
String hostNameForClients,
+      @CliOption(key = 
ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS,
+          help = 
CliStrings.START_SERVER__JMX_MANAGER_HOSTNAME_FOR_CLIENTS__HELP) final String 
jmxManagerHostnameForClients,
       @CliOption(key = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH,
           specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
           help = CliStrings.START_SERVER__INCLUDE_SYSTEM_CLASSPATH__HELP) 
final Boolean includeSystemClasspath,
@@ -1001,36 +1013,31 @@ public class LauncherLifecycleCommands implements 
GfshCommand {
 
       Properties gemfireProperties = new Properties();
 
-      gemfireProperties.setProperty(BIND_ADDRESS, 
StringUtils.defaultString(bindAddress));
-      gemfireProperties.setProperty(CACHE_XML_FILE, 
StringUtils.defaultString(cacheXmlPathname));
-      gemfireProperties.setProperty(ENABLE_TIME_STATISTICS,
-          StringUtils.defaultString(enableTimeStatistics));
-      gemfireProperties.setProperty(GROUPS, StringUtils.defaultString(group));
-      gemfireProperties.setProperty(LOCATORS, 
StringUtils.defaultString(locators));
-      gemfireProperties.setProperty(LOCATOR_WAIT_TIME, 
StringUtils.defaultString(locatorWaitTime));
-      gemfireProperties.setProperty(LOG_LEVEL, 
StringUtils.defaultString(logLevel));
-      gemfireProperties.setProperty(MCAST_ADDRESS, 
StringUtils.defaultString(mcastBindAddress));
-      gemfireProperties.setProperty(MCAST_PORT, 
StringUtils.defaultString(mcastPort));
-      gemfireProperties.setProperty(MEMCACHED_PORT, 
StringUtils.defaultString(memcachedPort));
-      gemfireProperties.setProperty(MEMCACHED_PROTOCOL,
-          StringUtils.defaultString(memcachedProtocol));
-      gemfireProperties.setProperty(MEMCACHED_BIND_ADDRESS,
-          StringUtils.defaultString(memcachedBindAddress));
-      gemfireProperties.setProperty(REDIS_PORT, 
StringUtils.defaultString(redisPort));
-      gemfireProperties.setProperty(REDIS_BIND_ADDRESS,
-          StringUtils.defaultString(redisBindAddress));
-      gemfireProperties.setProperty(REDIS_PASSWORD, 
StringUtils.defaultString(redisPassword));
-      gemfireProperties.setProperty(STATISTIC_ARCHIVE_FILE,
-          StringUtils.defaultString(statisticsArchivePathname));
-      gemfireProperties.setProperty(USE_CLUSTER_CONFIGURATION,
-          StringUtils.defaultString(requestSharedConfiguration, 
Boolean.TRUE.toString()));
-      gemfireProperties.setProperty(LOCK_MEMORY, 
StringUtils.defaultString(lockMemory));
-      gemfireProperties.setProperty(OFF_HEAP_MEMORY_SIZE,
-          StringUtils.defaultString(offHeapMemorySize));
-      gemfireProperties.setProperty(START_DEV_REST_API, 
StringUtils.defaultString(startRestApi));
-      gemfireProperties.setProperty(HTTP_SERVICE_PORT, 
StringUtils.defaultString(httpServicePort));
-      gemfireProperties.setProperty(HTTP_SERVICE_BIND_ADDRESS,
-          StringUtils.defaultString(httpServiceBindAddress));
+      setPropertyIfNotNull(gemfireProperties, BIND_ADDRESS, bindAddress);
+      setPropertyIfNotNull(gemfireProperties, CACHE_XML_FILE, 
cacheXmlPathname);
+      setPropertyIfNotNull(gemfireProperties, ENABLE_TIME_STATISTICS, 
enableTimeStatistics);
+      setPropertyIfNotNull(gemfireProperties, GROUPS, group);
+      setPropertyIfNotNull(gemfireProperties, JMX_MANAGER_HOSTNAME_FOR_CLIENTS,
+          jmxManagerHostnameForClients);
+      setPropertyIfNotNull(gemfireProperties, LOCATORS, locators);
+      setPropertyIfNotNull(gemfireProperties, LOCATOR_WAIT_TIME, 
locatorWaitTime);
+      setPropertyIfNotNull(gemfireProperties, LOG_LEVEL, logLevel);
+      setPropertyIfNotNull(gemfireProperties, MCAST_ADDRESS, mcastBindAddress);
+      setPropertyIfNotNull(gemfireProperties, MCAST_PORT, mcastPort);
+      setPropertyIfNotNull(gemfireProperties, MEMCACHED_PORT, memcachedPort);
+      setPropertyIfNotNull(gemfireProperties, MEMCACHED_PROTOCOL, 
memcachedProtocol);
+      setPropertyIfNotNull(gemfireProperties, MEMCACHED_BIND_ADDRESS, 
memcachedBindAddress);
+      setPropertyIfNotNull(gemfireProperties, REDIS_PORT, redisPort);
+      setPropertyIfNotNull(gemfireProperties, REDIS_BIND_ADDRESS, 
redisBindAddress);
+      setPropertyIfNotNull(gemfireProperties, REDIS_PASSWORD, redisPassword);
+      setPropertyIfNotNull(gemfireProperties, STATISTIC_ARCHIVE_FILE, 
statisticsArchivePathname);
+      setPropertyIfNotNull(gemfireProperties, USE_CLUSTER_CONFIGURATION,
+          requestSharedConfiguration);
+      setPropertyIfNotNull(gemfireProperties, LOCK_MEMORY, lockMemory);
+      setPropertyIfNotNull(gemfireProperties, OFF_HEAP_MEMORY_SIZE, 
offHeapMemorySize);
+      setPropertyIfNotNull(gemfireProperties, START_DEV_REST_API, 
startRestApi);
+      setPropertyIfNotNull(gemfireProperties, HTTP_SERVICE_PORT, 
httpServicePort);
+      setPropertyIfNotNull(gemfireProperties, HTTP_SERVICE_BIND_ADDRESS, 
httpServiceBindAddress);
       // if username is specified in the command line, it will overwrite 
what's set in the
       // properties file
       if (StringUtils.isNotBlank(userName)) {

http://git-wip-us.apache.org/repos/asf/geode/blob/d5bde9fb/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index a7a3742..2758429 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -2366,6 +2366,9 @@ public class CliStrings {
   public static final String START_LOCATOR__GROUP = "group";
   public static final String START_LOCATOR__GROUP__HELP = "Group(s) the 
Locator will be a part of.";
   public static final String START_LOCATOR__HOSTNAME_FOR_CLIENTS = 
"hostname-for-clients";
+
+  public static final String 
START_LOCATOR__JMX_MANAGER_HOSTNAME_FOR_CLIENTS__HELP =
+      "Hostname provided to clients by the locator for the location of a JMX 
Manager.";
   public static final String START_LOCATOR__HOSTNAME_FOR_CLIENTS__HELP =
       "Hostname or IP address that will be sent to clients so they can connect 
to this Locator. The default is the bind-address of the Locator.";
   public static final String START_LOCATOR__INCLUDE_SYSTEM_CLASSPATH = 
"include-system-classpath";
@@ -2514,6 +2517,9 @@ public class CliStrings {
   public static final String START_SERVER__INITIAL_HEAP = "initial-heap";
   public static final String START_SERVER__INITIAL_HEAP__HELP =
       "Initial size of the heap in the same format as the JVM -Xms parameter.";
+  public static final String 
START_SERVER__JMX_MANAGER_HOSTNAME_FOR_CLIENTS__HELP =
+      "Hostname provided to clients by the server for the location of a JMX 
Manager.";
+
   public static final String START_SERVER__J = "J";
   public static final String START_SERVER__J__HELP =
       "Argument passed to the JVM on which the server will run. For example, 
--J=-Dfoo.bar=true will set the system property \"foo.bar\" to \"true\".";

http://git-wip-us.apache.org/repos/asf/geode/blob/d5bde9fb/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
index aa97795..a2946d4 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
@@ -122,7 +122,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1 --";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
-    assertThat(candidate.size()).isEqualTo(50);
+    assertThat(candidate.size()).isEqualTo(51);
     assertTrue(candidate.getCandidates().contains(new 
Completion("--properties-file")));
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "J");
   }
@@ -132,7 +132,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1 ";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 1);
-    assertThat(candidate.size()).isEqualTo(50);
+    assertThat(candidate.size()).isEqualTo(51);
     assertTrue(candidate.getCandidates().contains(new Completion(" 
--properties-file")));
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + "--J");
   }
@@ -142,7 +142,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(50);
+    assertThat(candidate.size()).isEqualTo(51);
     assertTrue(candidate.getCandidates().contains(new Completion(" 
--properties-file")));
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " --J");
   }
@@ -151,23 +151,23 @@ public class GfshParserAutoCompletionTest {
   public void testCompleteJ() throws Exception {
     buffer = "start server --name=name1 --J=";
     candidate = parser.complete(buffer);
-    assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(0);
+    assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 3);
+    assertThat(candidate.size()).isEqualTo(1);
   }
 
   @Test
   public void testCompleteWithValue() throws Exception {
     buffer = "start server --name=name1 --J";
     candidate = parser.complete(buffer);
-    assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(0);
+    assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 3);
+    assertThat(candidate.size()).isEqualTo(1);
   }
 
   @Test
   public void testCompleteWithDash() throws Exception {
     buffer = "start server --name=name1 --J=-Dfoo.bar --";
     candidate = parser.complete(buffer);
-    assertThat(candidate.size()).isEqualTo(49);
+    assertThat(candidate.size()).isEqualTo(50);
   }
 
   @Test
@@ -185,7 +185,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1 --J=-Dtest=test1 --J=-Dfoo=bar";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(49);
+    assertThat(candidate.size()).isEqualTo(50);
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " 
--assign-buckets");
   }
 
@@ -194,7 +194,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --J=-Dtest=test1 --J=-Dfoo=bar --name=name1";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(49);
+    assertThat(candidate.size()).isEqualTo(50);
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " 
--assign-buckets");
   }
 
@@ -203,7 +203,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1 --locators=localhost --J=-Dfoo=bar";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length());
-    assertThat(candidate.size()).isEqualTo(48);
+    assertThat(candidate.size()).isEqualTo(49);
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + " 
--assign-buckets");
   }
 
@@ -212,7 +212,7 @@ public class GfshParserAutoCompletionTest {
     buffer = "start server --name=name1 --locators=localhost  --J=-Dfoo=bar 
--";
     candidate = parser.complete(buffer);
     assertThat(candidate.getCursor()).isEqualTo(buffer.length() - 2);
-    assertThat(candidate.size()).isEqualTo(48);
+    assertThat(candidate.size()).isEqualTo(49);
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + 
"assign-buckets");
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/d5bde9fb/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
index 0c2af1d..47d150d 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java
@@ -81,8 +81,9 @@ public class GfshParserParsingTest {
     GfshParseResult result = parser.parse(buffer);
     assertThat(result).isNotNull();
     Object[] arguments = result.getArguments();
-    // the 17th argument is the jvmarguments;
-    String[] jvmArgs = (String[]) arguments[17];
+    int indexOfJvmArgumentsParameterInStartLocator = 18;
+
+    String[] jvmArgs = (String[]) 
arguments[indexOfJvmArgumentsParameterInStartLocator];
     assertThat(jvmArgs).hasSize(2);
 
     // make sure the resulting jvm arguments do not have quotes (either single 
or double) around
@@ -99,8 +100,8 @@ public class GfshParserParsingTest {
     GfshParseResult result = parser.parse(buffer);
     assertThat(result).isNotNull();
     Object[] arguments = result.getArguments();
-    // the 18th argument is the jvmarguments;
-    String[] jvmArgs = (String[]) arguments[18];
+    int indexOfJvmArgumentsParameterInStartServer = 19;
+    String[] jvmArgs = (String[]) 
arguments[indexOfJvmArgumentsParameterInStartServer];
     assertThat(jvmArgs).hasSize(2);
 
     // make sure the resulting jvm arguments do not have quotes (either single 
or double) around

http://git-wip-us.apache.org/repos/asf/geode/blob/d5bde9fb/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
index 9b38d86..30a9a61 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommandsTest.java
@@ -15,37 +15,106 @@
 
 package org.apache.geode.management.internal.cli.commands;
 
+import static 
org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static 
org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_HOSTNAME_FOR_CLIENTS;
+import static 
org.apache.geode.distributed.ConfigurationProperties.USE_CLUSTER_CONFIGURATION;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
-import org.apache.geode.management.internal.cli.GfshParseResult;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.test.dunit.rules.GfshParserRule;
-import org.junit.ClassRule;
+import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
 import org.mockito.ArgumentCaptor;
-import org.springframework.util.ReflectionUtils;
 
 import java.util.Properties;
 
+@Category(IntegrationTest.class)
 public class LauncherLifecycleCommandsTest {
-  @ClassRule
-  public static GfshParserRule commandRule = new GfshParserRule();
+  private static final String FAKE_HOSTNAME = "someFakeHostname";
+
+  @Rule
+  public GfshParserRule commandRule = new GfshParserRule();
+
+  @Rule
+  public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   @Test
-  public void getLauncherLifecycleCommand() throws Exception {
-    LauncherLifecycleCommands spy = commandRule.spyCommand("start locator");
-    doReturn(mock(Gfsh.class)).when(spy).getGfsh();
+  public void startLocatorWorksWithNoOptions() throws Exception {
+    LauncherLifecycleCommands spy = spyOnCommand("start locator");
     commandRule.executeLastCommandWithInstance(spy);
 
-    ArgumentCaptor<Properties> propsCaptor = 
ArgumentCaptor.forClass(Properties.class);
-    verify(spy).createStartLocatorCommandLine(any(), any(), any(), 
propsCaptor.capture(), any(),
-        any(), any(), any(), any());
+    ArgumentCaptor<Properties> gemfirePropertiesCaptor = 
ArgumentCaptor.forClass(Properties.class);
+    verify(spy).createStartLocatorCommandLine(any(), any(), any(),
+        gemfirePropertiesCaptor.capture(), any(), any(), any(), any(), any());
+
+    Properties gemfireProperties = gemfirePropertiesCaptor.getValue();
+    assertThat(gemfireProperties).containsKey(ENABLE_CLUSTER_CONFIGURATION);
+    
assertThat(gemfireProperties.get(ENABLE_CLUSTER_CONFIGURATION)).isEqualTo("true");
+  }
+
+  @Test
+  public void startServerWorksWithNoOptions() throws Exception {
+    LauncherLifecycleCommands spy = spyOnCommand("start server");
+    commandRule.executeLastCommandWithInstance(spy);
+
+    ArgumentCaptor<Properties> gemfirePropertiesCaptor = 
ArgumentCaptor.forClass(Properties.class);
+    verify(spy).createStartServerCommandLine(any(), any(), any(), 
gemfirePropertiesCaptor.capture(),
+        any(), any(), any(), any(), any(), any());
+
+    Properties gemfireProperties = gemfirePropertiesCaptor.getValue();
+    assertThat(gemfireProperties).containsKey(USE_CLUSTER_CONFIGURATION);
+    
assertThat(gemfireProperties.get(USE_CLUSTER_CONFIGURATION)).isEqualTo("true");
+  }
+
+  @Test
+  public void startLocatorRespectsJmxManagerHostnameForClients() throws 
Exception {
+    String startLocatorCommand = new CommandStringBuilder("start locator")
+        .addOption(JMX_MANAGER_HOSTNAME_FOR_CLIENTS, FAKE_HOSTNAME).toString();
+
+    LauncherLifecycleCommands spyCommand = spyOnCommand(startLocatorCommand);
+    commandRule.executeLastCommandWithInstance(spyCommand);
+
+    ArgumentCaptor<Properties> gemfirePropertiesCaptor = 
ArgumentCaptor.forClass(Properties.class);
+    verify(spyCommand).createStartLocatorCommandLine(any(), any(), any(),
+        gemfirePropertiesCaptor.capture(), any(), any(), any(), any(), any());
+
+    Properties gemfireProperties = gemfirePropertiesCaptor.getValue();
+    
assertThat(gemfireProperties).containsKey(JMX_MANAGER_HOSTNAME_FOR_CLIENTS);
+    
assertThat(gemfireProperties.get(JMX_MANAGER_HOSTNAME_FOR_CLIENTS)).isEqualTo(FAKE_HOSTNAME);
+  }
+
+  @Test
+  public void startServerRespectsJmxManagerHostnameForClients() throws 
Exception {
+    String startServerCommand = new CommandStringBuilder("start server")
+        .addOption(JMX_MANAGER_HOSTNAME_FOR_CLIENTS, FAKE_HOSTNAME).toString();
+
+    LauncherLifecycleCommands commandSpy = spyOnCommand(startServerCommand);
+
+    commandRule.executeLastCommandWithInstance(commandSpy);
+
+    ArgumentCaptor<Properties> gemfirePropertiesCaptor = 
ArgumentCaptor.forClass(Properties.class);
+    verify(commandSpy).createStartServerCommandLine(any(), any(), any(),
+        gemfirePropertiesCaptor.capture(), any(), any(), any(), any(), any(), 
any());
+
+    Properties gemfireProperties = gemfirePropertiesCaptor.getValue();
+    
assertThat(gemfireProperties).containsKey(JMX_MANAGER_HOSTNAME_FOR_CLIENTS);
+    
assertThat(gemfireProperties.get(JMX_MANAGER_HOSTNAME_FOR_CLIENTS)).isEqualTo(FAKE_HOSTNAME);
+  }
+
+  private LauncherLifecycleCommands spyOnCommand(String command) {
+    LauncherLifecycleCommands spy = commandRule.spyCommand(command);
+    doReturn(mock(Gfsh.class)).when(spy).getGfsh();
+    
doReturn(temporaryFolder.getRoot().getAbsolutePath()).when(spy).resolveWorkingDir(any(),
 any());
 
-    Properties properties = propsCaptor.getValue();
-    System.out.println();
+    return spy;
   }
 }

Reply via email to