AbstractBuffer extends BaseBuffer { @Override public int capacity() { return this.upperBoundary - this.lowerBoundary; } protected  AbstractBuffer(final int readerIndex, final int lowerBoundary, final int upperBoundary,
            final int writerIndex); @Override abstract Buffer clone(); @Override int getLowerBoundary(); @Override int getUpperBoundary(); @Override int getReaderIndex(); @Override int getWriterIndex(); @Override void setWriterIndex(final int index); @Override void setReaderIndex(final int index); @Override int capacity(); @Override int getWritableBytes(); @Override void markReaderIndex(); @Override Buffer slice(final int stop); @Override Buffer slice(); @Override int getReadableBytes(); @Override void resetReaderIndex(); @Override final short readUnsignedByte(); @Override boolean hasWriteSupport(); @Override void write(final byte b); @Override void write(final String s); @Override void write(final String s, final String charset); @Override abstract boolean equals(Object other); @Override abstract int hashCode();  }
@Test public void testRead() throws Exception { final Buffer buffer = createBuffer(RawData.rawEthernetFrame); for (int i = 0; i < 5; ++i) { final Buffer hundred = buffer.readBytes(100); assertThat(hundred.capacity(), is(100)); for (int k = 0; k < 100; ++k) { assertThat(hundred.getByte(k), is(RawData.rawEthernetFrame[k + i * 100])); } } final Buffer theRest = buffer.readBytes(47); assertThat(theRest.capacity(), is(47)); for (int k = 0; k < 47; ++k) { assertThat(theRest.getByte(k), is(RawData.rawEthernetFrame[k + 500])); } }