CommandInterpreter { public ProxyCommand interpretCommand(ChannelBuffer buffer) throws Exception { return this.interpretCommand(new ChannelBufferInputStream(buffer), false); }  ProxyCommand readCommand(InputStream inputStream); ProxyCommand readCommand(MessageEvent event); ProxyCommand interpretCommand(ChannelBuffer buffer); void writeCommandExecutionResponse(ChannelHandlerContext ctx, ChannelEvent event, TaskResult result); void writeCommandExecutionResponse(OutputStream outputStream, TaskResult result); static final int MAX_COMMAND_INPUT; static final char LINE_FEED; }
@Test public void testInterpretCommand() { CommandInterpreter.ProxyCommand command; command = getCommand("testCommand\n"); assertTrue("Command parsing failed",command != null && command.getReadFailure() == null); assertTrue("Parsed command mismatch: "+command.getCommand(), "testCommand".equals(command.getCommand())); assertTrue("Command parameters not empty", command.getCommandParams().isEmpty()); assertTrue("Command data not empty", command.getCommandData() == null); command = getCommand("testCommand p1=v1 p2=v2\n"); assertTrue("Command parsing failed",command != null && command.getReadFailure() == null); assertTrue("Parsed command mismatch: "+command.getCommand(), "testCommand".equals(command.getCommand())); assertTrue("Command parameters mismatch: "+command.getCommandParams().size(), command.getCommandParams().size() == 2); assertTrue("Command data not empty", command.getCommandData() == null); command = getCommand("#testCommand#p1=v1#p2=v2\n"); assertTrue("Command parsing failed",command != null && command.getReadFailure() == null); assertTrue("Parsed command mismatch: "+command.getCommand(), "testCommand".equals(command.getCommand())); assertTrue("Command parameters mismatch: "+command.getCommandParams().size(), command.getCommandParams().size() == 2); assertTrue("Command data not empty", command.getCommandData() == null); command = getCommand("testCommand p1=v1 p2=v2 8\ntestData"); assertTrue("Command parsing failed",command != null && command.getReadFailure() == null); assertTrue("Parsed command mismatch: "+command.getCommand(), "testCommand".equals(command.getCommand())); assertTrue("Command parameters mismatch: "+command.getCommandParams().size(), command.getCommandParams().size() == 2); assertTrue("Command data mismatch: "+command.getCommandData(), "testData".equals(new String(command.getCommandData()))); command = getCommand("testCommand p1=v1 p2=v2"); assertTrue("Command parsing passed (which should not)", command != null && command.getReadFailure() != null); command = getCommand("testCommand p1=v1 p2=v2 10\ntestData"); assertTrue("Command parsing passed (which should not)", command != null && command.getReadFailure() != null); }