Repository: geode
Updated Branches:
  refs/heads/develop 9e5fad2e8 -> f41ca9d7d


http://git-wip-us.apache.org/repos/asf/geode/blob/f41ca9d7/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
index 409a96d..e2d40ec 100755
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java
@@ -30,7 +30,9 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
 import java.net.ServerSocket;
+import java.net.UnknownHostException;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -282,9 +284,17 @@ public abstract class LauncherIntegrationTestCase {
 
   private void givenPortInUse(final int port) {
     try {
+      givenPortInUse(port, InetAddress.getLocalHost());
+    } catch (UnknownHostException e) {
+      throw new UncheckedIOException(e);
+    }
+  }
+
+  private void givenPortInUse(final int port, InetAddress bindAddress) {
+    try {
       socket = SocketCreatorFactory
           .createNonDefaultInstance(false, false, null, null, 
System.getProperties())
-          .createServerSocket(port, 50, null, -1);
+          .createServerSocket(port, 50, bindAddress, -1);
       assertThat(socket.isBound()).isTrue();
       assertThat(socket.isClosed()).isFalse();
       assertThat(isPortAvailable(port, SOCKET)).isFalse();

http://git-wip-us.apache.org/repos/asf/geode/blob/f41ca9d7/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
index cc42a53..085e4da 100755
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
@@ -185,8 +185,8 @@ public class LocatorLauncherRemoteIntegrationTest extends 
LocatorLauncherRemoteI
     assertThat(locatorState.getStatus()).isEqualTo(NOT_RESPONDING);
     assertThat(locatorState.getClasspath()).isNull();
     
assertThat(locatorState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
-    assertThat(locatorState.getHost()).isNull();
-    assertThat(locatorState.getJavaVersion()).isNull();
+    
assertThat(locatorState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
+    
assertThat(locatorState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
     assertThat(locatorState.getLogFile()).isNull();
     assertThat(locatorState.getMemberName()).isNull();
     assertThat(locatorState.getPid()).isNull();

http://git-wip-us.apache.org/repos/asf/geode/blob/f41ca9d7/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
index 733a108..025ad5d 100755
--- 
a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
@@ -244,9 +244,9 @@ public class ServerLauncherRemoteIntegrationTest extends 
ServerLauncherRemoteInt
     
assertThat(serverState.getWorkingDirectory()).isEqualTo(getWorkingDirectoryPath());
     assertThat(serverState.getClasspath()).isNull();
     
assertThat(serverState.getGemFireVersion()).isEqualTo(GemFireVersion.getGemFireVersion());
-    assertThat(serverState.getJavaVersion()).isNull();
+    
assertThat(serverState.getJavaVersion()).isEqualTo(System.getProperty("java.version"));
     assertThat(serverState.getLogFile()).isNull();
-    assertThat(serverState.getHost()).isNull();
+    
assertThat(serverState.getHost()).isEqualTo(InetAddress.getLocalHost().getCanonicalHostName());
     assertThat(serverState.getMemberName()).isNull();
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f41ca9d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
index dd5841f..8537777 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/lifecycle/GfshStatusCommandsIntegrationTest.java
@@ -19,13 +19,13 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.io.File;
 
 import org.junit.Before;
-import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 
+import org.apache.geode.internal.DistributionLocator;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.GfshShellConnectionRule;
 import org.apache.geode.test.dunit.rules.LocatorStarterRule;
@@ -33,8 +33,7 @@ import org.apache.geode.test.junit.categories.IntegrationTest;
 
 @Category(IntegrationTest.class)
 public class GfshStatusCommandsIntegrationTest {
-  final private static String LOCATOR_NAME = "locator1";
-  // private int port;
+  private static final String LOCATOR_NAME = "locator1";
 
   @Rule
   public LocatorStarterRule locator =
@@ -52,37 +51,48 @@ public class GfshStatusCommandsIntegrationTest {
 
   @Before
   public void connect() throws Exception {
-    // port = getRandomAvailablePort(SOCKET);
     gfsh.connectAndVerify(locator);
   }
 
   @Test
-  public void statusLocatorWithBadPortReportsNotResponding() throws Exception {
-    CommandResult result = gfsh.executeCommand("status locator 
--host=localhost --port="
-        + String.valueOf(locator.getLocator().getPort() - 1));
+  public void statusLocatorWithBadPort_statusNotResponding() throws Exception {
+    String wrongPort = String.valueOf(locator.getLocator().getPort() - 1);
+    CommandResult result =
+        gfsh.executeCommand("status locator --host=localhost --port=" + 
wrongPort);
+    
assertThat(result.getContent().getString("message")).doesNotContain("null");
     assertThat(result.getContent().getString("message")).contains("not 
responding");
+    assertThat(result.getContent().getString("message")).contains(wrongPort);
   }
 
   @Test
-  public void statusLocatorWithActivePortReportsOnline() throws Exception {
+  public void 
statusLocatorDefault_LocatorOnNonDefaultPort_statusNotResponding() throws 
Exception {
+    CommandResult result = gfsh.executeCommand("status locator 
--host=localhost");
+    
assertThat(result.getContent().getString("message")).doesNotContain("null");
+    assertThat(result.getContent().getString("message")).contains("not 
responding");
+    assertThat(result.getContent().getString("message"))
+        .contains(String.valueOf(DistributionLocator.DEFAULT_LOCATOR_PORT));
+  }
+
+  @Test
+  public void statusLocatorWithActivePort_statusOnline() throws Exception {
     CommandResult result = gfsh.executeCommand(
         "status locator --host=localhost --port=" + 
String.valueOf(locator.getLocator().getPort()));
     assertThat(result.getContent().getString("message")).contains("is 
currently online");
   }
 
   @Test
-  public void statusServerWithWithNoOptions() throws Exception {
-    File serverDir = new File(temporaryFolder.getRoot(), "serverDir");
-    serverDir.mkdirs();
+  public void statusServerNoServer_statusNotResponding() throws Exception {
     CommandResult result = gfsh.executeCommand("status server");
+    
assertThat(result.getContent().getString("message")).doesNotContain("null");
     assertThat(result.getContent().getString("message")).contains("not 
responding");
   }
 
   @Test
-  public void statusServerWithInvalidDirReturnsMeangingfulMessage() throws 
Exception {
+  public void statusServerWithEmptyDir_statusNotResponding() throws Exception {
     File serverDir = new File(temporaryFolder.getRoot(), "serverDir");
     serverDir.mkdirs();
     CommandResult result = gfsh.executeCommand("status server --dir=" + 
serverDir.toString());
+    
assertThat(result.getContent().getString("message")).doesNotContain("null");
     assertThat(result.getContent().getString("message")).contains("not 
responding");
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/f41ca9d7/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
----------------------------------------------------------------------
diff --git 
a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
 
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
index e7f17ef..dc17d03 100644
--- 
a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
+++ 
b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/GfshShellConnectionRule.java
@@ -44,12 +44,12 @@ import 
org.apache.geode.test.junit.rules.DescribedExternalResource;
  *
  * you can use this as Rule
  * 
- * @Rule GfshShellConnectionRule rule = new GfshSheelConnectionRule(); then 
after you connect to a
+ * @Rule GfshShellConnectionRule rule = new GfshShellConnectionRule(); then 
after you connect to a
  *       locator, you don't have to call disconnect() or close() at all, since 
the rule's after
  *       takes care of it for you.
  *
  *       Or as a ClassRule
- * @ClassRule GfshShellConnectionRule rule = new GfshSheelConnectionRule(); 
When using as a
+ * @ClassRule GfshShellConnectionRule rule = new GfshShellConnectionRule(); 
When using as a
  *            ClassRule, if you call connect in a test, you will need to call 
disconnect after the
  *            test as well. See NetstatDUnitTest for example.
  *

Reply via email to