RollingBuffer implements ReadableByteBuffer { @Override public int length() { return 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 public void testLength() throws IOException { final RollingBuffer b = new RollingBuffer(newChannel(new ByteArrayInputStream(new byte[2])), 1, 2); assertEquals(1, b.length()); }