Mercurial > hg > release > thermostat-1.2
changeset 1534:50c227cb0b02
Fix shell to treat multiple spaces as a single space
Reviewed-by: vanaltj
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-November/011410.html
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 04 Nov 2014 17:03:43 -0500 |
parents | d5a7cb4fab04 |
children | f380c0ac5d57 |
files | client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java Tue Oct 28 11:39:23 2014 -0600 +++ b/client/cli/src/main/java/com/redhat/thermostat/client/cli/internal/ShellCommand.java Tue Nov 04 17:03:43 2014 -0500 @@ -173,7 +173,7 @@ } private void launchCommand(String line) throws CommandException { - String[] parsed = line.split(" "); + String[] parsed = line.split(" +"); ServiceReference launcherRef = bundleContext.getServiceReference(Launcher.class.getName()); if (launcherRef != null) { Launcher launcher = (Launcher) bundleContext.getService(launcherRef);
--- a/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Tue Oct 28 11:39:23 2014 -0600 +++ b/client/cli/src/test/java/com/redhat/thermostat/client/cli/internal/ShellCommandTest.java Tue Nov 04 17:03:43 2014 -0500 @@ -110,6 +110,20 @@ } @Test + public void testExtraSpacesAreIgnored() throws CommandException { + ServiceReference ref = mock(ServiceReference.class); + when(bundleContext.getServiceReference(Launcher.class.getName())).thenReturn(ref); + Launcher launcher = mock(Launcher.class); + when(bundleContext.getService(ref)).thenReturn(launcher); + TestCommandContextFactory ctxFactory = new TestCommandContextFactory(bundleContext); + ctxFactory.setInput("foo bar\nexit\n"); + Arguments args = new SimpleArguments(); + CommandContext ctx = ctxFactory.createContext(args); + cmd.run(ctx); + verify(launcher).run(new String[]{"foo", "bar"}, true); + } + + @Test public void testQuitAlsoExits() throws CommandException { TestCommandContextFactory ctxFactory = new TestCommandContextFactory(); ctxFactory.setInput("quit\n");