TelnetCommandDecoder { public static final CommandContext decode(String str) { CommandContext commandContext = null; if (!StringUtils.isBlank(str)) { String[] array = str.split("(?<![\\\\]) "); if (array.length > 0) { String name = array[0]; String[] targetArgs = new String[array.length - 1]; System.arraycopy(array, 1, targetArgs, 0, array.length - 1); commandContext = CommandContextFactory.newInstance( name, targetArgs,false); commandContext.setOriginRequest(str); } } return commandContext; }  static final CommandContext decode(String str);  }
@Test public void testDecode() throws Exception { CommandContext context = TelnetCommandDecoder.decode("test a b"); assertThat(context.getCommandName(), equalTo("test")); assertThat(context.isHttp(), is(false)); assertThat(context.getArgs(), arrayContaining("a", "b")); }