Mercurial > hg > thermostat
changeset 1587:41787389d6b2
Use + and - symbols for connectedness in shell prompt.
PR2057
Reviewed-by: omajid, jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-December/011929.html
author | Jie Kang <jkang@redhat.com> |
---|---|
date | Wed, 03 Dec 2014 12:21:09 -0500 |
parents | 67b1c0156c52 |
children | 57c56cfc884b |
files | client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellPrompt.java client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellPromptTest.java distribution/config/commands/shell.properties integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/IntegrationTest.java |
diffstat | 6 files changed, 30 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellPrompt.java Wed Dec 03 11:54:37 2014 -0500 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellPrompt.java Wed Dec 03 12:21:09 2014 -0500 @@ -38,9 +38,12 @@ public class ShellPrompt { - private static final String PROMPT_FORMAT = "Thermostat (%s) > "; + public static final String CONNECTED_TOKEN = "+"; + public static final String DISCONNECTED_TOKEN = "-"; - private String connectedToken = "D"; + private static final String PROMPT_FORMAT = "Thermostat %s > "; + + private String connectedToken = DISCONNECTED_TOKEN; //Default to disconnected public ShellPrompt() { } @@ -50,11 +53,11 @@ } public void storageConnected() { - connectedToken = "C"; + connectedToken = CONNECTED_TOKEN; } public void storageDisconnected() { - connectedToken = "D"; + connectedToken = DISCONNECTED_TOKEN; } }
--- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Wed Dec 03 11:54:37 2014 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Wed Dec 03 12:21:09 2014 -0500 @@ -70,7 +70,7 @@ static private final String VERSION = "Thermostat some version"; static private final String VERSION_OUTPUT = VERSION + "\n"; - static private final String PROMPT = "Thermostat (D) > "; + static private final String PROMPT = "Thermostat " + ShellPrompt.DISCONNECTED_TOKEN + " > "; private ShellCommand cmd;
--- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellPromptTest.java Wed Dec 03 11:54:37 2014 -0500 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellPromptTest.java Wed Dec 03 12:21:09 2014 -0500 @@ -54,7 +54,7 @@ public void testConnectedPrompt() { shellPrompt.storageConnected(); - String expected = "Thermostat (C) > "; + String expected = "Thermostat " + ShellPrompt.CONNECTED_TOKEN + " > "; assertEquals(expected, shellPrompt.getPrompt()); } @@ -62,7 +62,7 @@ public void testDisconnectedPrompt() { shellPrompt.storageDisconnected(); - String expected = "Thermostat (D) > "; + String expected = "Thermostat " + ShellPrompt.DISCONNECTED_TOKEN + " > "; assertEquals(expected, shellPrompt.getPrompt()); } }
--- a/distribution/config/commands/shell.properties Wed Dec 03 11:54:37 2014 -0500 +++ b/distribution/config/commands/shell.properties Wed Dec 03 12:21:09 2014 -0500 @@ -1,8 +1,7 @@ # ShellCommand is provided by the tools bundle, which is a bootstrap bundle, and requires no other bundles. bundles = com.redhat.thermostat.client.cli=${project.version} -description = launches the Thermostat interactive shell - +description = launches the Thermostat interactive shell. The prompt displays a "-" to indicate that it is disconnected or a "+" to indicate that it is connected to storage usage = shell # This command does not have any options
--- a/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java Wed Dec 03 11:54:37 2014 -0500 +++ b/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java Wed Dec 03 12:21:09 2014 -0500 @@ -183,13 +183,7 @@ shell.expectClose(); String stdOut = shell.getCurrentStandardOutContents(); - - String[] lines = stdOut.split("\n"); - String usage = lines[0]; - assertTrue(usage.matches("^usage: thermostat shell$")); - String description = lines[1]; - assertTrue(description.matches("^\\s+launches the Thermostat interactive shell$")); - assertTrue(lines[3].matches("thermostat shell")); + verifyShellHelpOutput(stdOut); } @Test @@ -198,13 +192,19 @@ shell.expectClose(); String stdOut = shell.getCurrentStandardOutContents(); + verifyShellHelpOutput(stdOut); + } - String[] lines = stdOut.split("\n"); - String usage = lines[0]; - assertTrue(usage.matches("^usage: thermostat shell$")); - String description = lines[1]; - assertTrue(description.matches("^\\s+launches the Thermostat interactive shell$")); - assertTrue(lines[3].matches("thermostat shell")); + private void verifyShellHelpOutput(String actual) { + String expected = "usage: thermostat shell\n" + + " launches the Thermostat interactive shell. The prompt displays\n" + + " a \"-\" to indicate that it is disconnected or a \"+\" to indicate\n" + + " that it is connected to storage\n" + + "\n" + + "thermostat shell\n" + + " --help show usage of command\n"; + + assertEquals(expected, actual); } @Test @@ -214,8 +214,9 @@ String stdOut = shell.getCurrentStandardOutContents(); String expectedOut = "Could not parse options: Unrecognized option: --foo\n" + "usage: thermostat shell\n" - + " launches the Thermostat interactive shell\n" - + "\n" + + " launches the Thermostat interactive shell. The prompt displays\n" + + " a \"-\" to indicate that it is disconnected or a \"+\" to indicate\n" + + " that it is connected to storage\n\n" + "thermostat shell\n" + " --help show usage of command\n"; assertEquals(expectedOut, stdOut);
--- a/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/IntegrationTest.java Wed Dec 03 11:54:37 2014 -0500 +++ b/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/IntegrationTest.java Wed Dec 03 12:21:09 2014 -0500 @@ -47,6 +47,7 @@ import java.util.ArrayList; import java.util.List; +import com.redhat.thermostat.client.cli.internal.ShellPrompt; import com.redhat.thermostat.common.utils.StreamUtils; import expectj.Executor; @@ -78,8 +79,8 @@ public static final long TIMEOUT_IN_SECONDS = 30; - public static final String SHELL_DISCONNECT_PROMPT = "Thermostat (D) >"; - public static final String SHELL_CONNECT_PROMPT = "Thermostat (C) >"; + public static final String SHELL_DISCONNECT_PROMPT = "Thermostat - >"; + public static final String SHELL_CONNECT_PROMPT = "Thermostat + >"; private static final String THERMOSTAT_HOME = "THERMOSTAT_HOME"; private static final String USER_THERMOSTAT_HOME = "USER_THERMOSTAT_HOME";