NettyReadable implements ReadableBuffer { @Override public int getInt() { return buffer.readInt(); } NettyReadable(ByteBuf buffer); ByteBuf getByteBuf(); @Override byte get(); @Override int getInt(); @Override long getLong(); @Override short getShort(); @Override float getFloat(); @Override double getDouble(); @Override ReadableBuffer get(byte[] data, int offset, int length); @Override ReadableBuffer get(byte[] data); @Override ReadableBuffer position(int position); @Override ReadableBuffer slice(); @Override ReadableBuffer flip(); @Override ReadableBuffer limit(int limit); @Override int limit(); @Override int remaining(); @Override int position(); @Override boolean hasRemaining(); @Override ReadableBuffer duplicate(); @Override ByteBuffer byteBuffer(); @Override String readUTF8(); @Override byte[] array(); @Override int arrayOffset(); @Override int capacity(); @Override ReadableBuffer clear(); @Override ReadableBuffer reclaimRead(); @Override byte get(int index); @Override boolean hasArray(); @Override ReadableBuffer mark(); @Override String readString(CharsetDecoder decoder); @Override ReadableBuffer reset(); @Override ReadableBuffer rewind(); @Override ReadableBuffer get(WritableBuffer target); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other);  }
@Test public void testGetInt() { byte[] data = new byte[] {0, 0, 0, 1}; ByteBuf byteBuffer = Unpooled.wrappedBuffer(data); NettyReadable buffer = new NettyReadable(byteBuffer); assertEquals(1, buffer.getInt()); assertFalse(buffer.hasRemaining()); try { buffer.getInt(); fail("Should throw an IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException ioe) { } }