RollingBuffer implements ReadableByteBuffer { @Override public byte get(int i) { if (i < 0 || i >= this.length) { throw new IndexOutOfBoundsException(); } return this.buffer.get(this.buffer.position() + i); } RollingBuffer(ReadableByteChannel channel, int windowSize, int bufferSize); boolean advance(int bytes); @Override int length(); @Override byte get(int i); @Override void write(WritableByteChannel channel); @Override void write(WritableByteChannel channel, int offset, int length);  }
@Test(expected = IndexOutOfBoundsException.class) public void testGetIndexNegative() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[2])), 1, 2); b.get(-1); }
@Test(expected = IndexOutOfBoundsException.class) public void testGetIndexBeyondLength() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[2])), 1, 2); b.get(2); }