RedisStreamReader implements Closeable { public byte[] read(int length) throws IOException { if (length == -1) { return null; } final byte[] bytes = new byte[length]; inputStream.read(bytes); inputStream.read(new byte[2]); return bytes; } RedisStreamReader(InputStream inputStream); byte readByte(); String readString(); int readInt(); byte[] read(int length); @Override void close(); static final int BUFFER_SIZE; }
@Test public void read() throws IOException { final byte theByte = '*'; final byte[] bytes = {theByte}; setupInputStreamRead(bytes, SIZE); byte[] actualBytes = reader.read(1); assertArrayEquals(bytes, actualBytes); }
@Test public void readNull() throws IOException { assertArrayEquals(null, reader.read(-1)); }