You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by je...@apache.org on 2016/04/21 00:26:15 UTC

incubator-geode git commit: GEODE-1215: Error running gfsh history

Repository: incubator-geode
Updated Branches:
  refs/heads/develop ea97a536e -> 06e920ede


GEODE-1215: Error running gfsh history

- Issue probably surfaced with new jline library.


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

Branch: refs/heads/develop
Commit: 06e920ede5618c89f4bc5837c8f85724e229ae1b
Parents: ea97a53
Author: Jens Deppe <jd...@pivotal.io>
Authored: Fri Apr 15 10:18:55 2016 -0700
Committer: Jens Deppe <jd...@pivotal.io>
Committed: Wed Apr 20 15:25:54 2016 -0700

----------------------------------------------------------------------
 .../internal/cli/commands/ShellCommands.java    |  2 +-
 .../cli/commands/ShellCommandsDUnitTest.java    | 45 +++++++++++++++++++-
 2 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/06e920ed/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
index daffa80..951a4b6 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommands.java
@@ -859,7 +859,7 @@ private void configureHttpsURLConnection(Map<String, String> sslConfigProps) thr
       long lineNumber = 0;
 
       while (it.hasNext()) {
-        String line = (String) it.next();
+        String line = it.next().toString();
         if (line.isEmpty() == false) {
           if (flagForLineNumbers) {
             lineNumber++;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/06e920ed/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
index 6ee11e6..86f6dc8 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/commands/ShellCommandsDUnitTest.java
@@ -291,7 +291,7 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
   }
 
   @Test
-  public void testHistory() {
+  public void testHistoryWithEntry() {
     Gfsh gfshInstance = Gfsh.getCurrentInstance();
 
     if (gfshInstance == null) {
@@ -299,9 +299,39 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
     }
 
     gfshInstance.setDebug(false);
+
+    // Generate a line of history
+    executeCommand("help");
+    executeCommand("connect");
+
+    String command = "history";
+    CommandResult cmdResult = executeCommand(command);
+    String result = printCommandOutput(cmdResult);
+
+    assertEquals("  1  0: help\n  2  1: connect\n\n\n", result);
+
+    if (cmdResult != null) {
+      assertEquals(Result.Status.OK, cmdResult.getStatus());
+    } else {
+      fail("testHistory failed");
+    }
+  }
+
+  @Test
+  public void testEmptyHistory() {
+    Gfsh gfshInstance = Gfsh.getCurrentInstance();
+
+    if (gfshInstance == null) {
+      fail("In testHistory command gfshInstance is null");
+    }
+
+    gfshInstance.setDebug(false);
+
     String command = "history";
     CommandResult cmdResult = executeCommand(command);
     printCommandOutput(cmdResult);
+    cmdResult.resetToFirstLine();
+    assertEquals("", cmdResult.nextLine());
 
     if (cmdResult != null) {
       assertEquals(Result.Status.OK, cmdResult.getStatus());
@@ -318,8 +348,12 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
       fail("In testHistory command gfshInstance is null");
     }
 
+    // Generate a line of history
+    executeCommand("help");
+
     String historyFileName = gfshInstance.getGfshConfig().getHistoryFileName();
     File historyFile = new File(historyFileName);
+    historyFile.deleteOnExit();
     String fileName = historyFile.getParent();
     fileName = fileName + File.separator + getClass().getSimpleName() + "_" + getName() + "-exported.history";
 
@@ -332,6 +366,8 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
     } else {
       fail("testHistory failed");
     }
+    assertTrue(historyFile.exists());
+    assertTrue(0L != historyFile.length());
   }
 
   @Test
@@ -343,6 +379,10 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
     }
 
     gfshInstance.setDebug(false);
+
+    // Generate a line of history
+    executeCommand("help");
+
     String command = "history --clear";
     CommandResult cmdResult = executeCommand(command);
     printCommandOutput(cmdResult);
@@ -359,7 +399,7 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
     }
   }
 
-  private static void printCommandOutput(CommandResult cmdResult) {
+  private static String printCommandOutput(CommandResult cmdResult) {
     assertNotNull(cmdResult);
     getLogWriter().info("Command Output : ");
     StringBuilder sb = new StringBuilder();
@@ -369,6 +409,7 @@ public class ShellCommandsDUnitTest extends CliCommandTestBase {
     }
     getLogWriter().info(sb.toString());
     getLogWriter().info("");
+    return sb.toString();
   }
 
   private void printAllEnvs(Gfsh gfsh) {