RollingBuffer implements ReadableByteBuffer { @Override public void write(WritableByteChannel channel) throws IOException { write(channel, 0, this.length); } 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 testWriteOffsetNegative() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[2])), 1, 2); b.write(Channels.newChannel(new ByteArrayOutputStream()), -1, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void testWriteOffsetBeyondLength() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[2])), 1, 2); b.write(Channels.newChannel(new ByteArrayOutputStream()), 1, 1); }
@Test(expected = IndexOutOfBoundsException.class) public void testWriteLengthBeyondWindow() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[4])), 1, 2); b.write(Channels.newChannel(new ByteArrayOutputStream()), 0, 2); }