@Test public void buildACommand() throws IOException { PipedInputStream pis = new PipedInputStream(); BufferedInputStream bis = new BufferedInputStream(pis); PipedOutputStream pos = new PipedOutputStream(pis); RedisOutputStream ros = new RedisOutputStream(pos); Protocol.sendCommand(ros, Protocol.Command.GET, "SOMEKEY".getBytes(Protocol.CHARSET)); ros.flush(); pos.close(); String expectedCommand = "*2\r\n$3\r\nGET\r\n$7\r\nSOMEKEY\r\n"; int b; StringBuilder sb = new StringBuilder(); while ((b = bis.read()) != -1) { sb.append((char) b); } assertEquals(expectedCommand, sb.toString()); }
protected Connection sendCommand(final Command cmd, final byte[]... args) { connect(); protocol.sendCommand(outputStream, cmd, args); pipelinedCommands++; return this; }
protected Connection sendCommand(final Command cmd) { connect(); protocol.sendCommand(outputStream, cmd, new byte[0][]); pipelinedCommands++; return this; }
public void sendCommand(final RedisOutputStream os, final Command command, final byte[]... args) { sendCommand(os, command.raw, args); }