### Question:
ReadOnlyByteBuffer extends AbstractBuffer { @Override public int capacity() { return buffer.capacity(); } ReadOnlyByteBuffer(ByteBuffer buffer); @Override int capacity(); @Override Buffer capacity(int newCapacity); @Override int maxCapacity(); @Override int writableBytes(); @Override int maxWritableBytes(); @Override Buffer ensureWritable(int minWritableBytes); @Override int ensureWritable(int minWritableBytes, boolean force); @Override Buffer getBytes(int index, Buffer dst, int dstIndex, int length); @Override Buffer getBytes(int index, byte[] dst, int dstIndex, int length); @Override Buffer getBytes(int index, ByteBuffer dst); @Override Buffer setBoolean(int index, boolean value); @Override Buffer setByte(int index, int value); @Override Buffer setShort(int index, int value); @Override Buffer setShortLE(int index, int value); @Override Buffer setMedium(int index, int value); @Override Buffer setMediumLE(int index, int value); @Override Buffer setInt(int index, int value); @Override Buffer setIntLE(int index, int value); @Override Buffer setLong(int index, long value); @Override Buffer setLongLE(int index, long value); @Override Buffer setChar(int index, int value); @Override Buffer setFloat(int index, float value); @Override Buffer setDouble(int index, double value); @Override Buffer setBytes(int index, Buffer src); @Override Buffer setBytes(int index, Buffer src, int length); @Override Buffer setBytes(int index, Buffer src, int srcIndex, int length); @Override Buffer setBytes(int index, byte[] src); @Override Buffer setBytes(int index, byte[] src, int srcIndex, int length); @Override Buffer setBytes(int index, ByteBuffer src); @Override int setBytes(int index, InputStream src, int length); @Override int setBytesUntilEndStream(int index, InputStream src, int chunkSize); @Override Buffer writeBoolean(boolean value); @Override Buffer writeByte(int value); @Override Buffer writeShort(int value); @Override Buffer writeShortLE(int value); @Override Buffer writeMedium(int value); @Override Buffer writeMediumLE(int value); @Override Buffer writeInt(int value); @Override Buffer writeIntLE(int value); @Override Buffer writeLong(long value); @Override Buffer writeLongLE(long value); @Override Buffer writeChar(int value); @Override Buffer writeFloat(float value); @Override Buffer writeDouble(double value); @Override Buffer writeBytes(Buffer src); @Override Buffer writeBytes(Buffer src, int length); @Override Buffer writeBytes(Buffer src, int srcIndex, int length); @Override Buffer writeBytes(byte[] src); @Override Buffer writeBytes(byte[] src, int srcIndex, int length); @Override Buffer writeBytes(ByteBuffer src); @Override int writeBytes(InputStream src, int length); @Override int writeBytesUntilEndStream(InputStream src, int chunkSize); @Override Buffer writeAscii(CharSequence seq); @Override Buffer writeUtf8(CharSequence seq); @Override Buffer writeUtf8(CharSequence seq, int ensureWritable); @Override Buffer readSlice(int length); @Override Buffer readBytes(int length); @Override Buffer copy(int index, int length); @Override Buffer slice(int index, int length); @Override Buffer duplicate(); @Override int nioBufferCount(); @Override ByteBuffer toNioBuffer(); @Override ByteBuffer toNioBuffer(int index, int length); @Override ByteBuffer[] toNioBuffers(int index, int length); @Override boolean isReadOnly(); @Override Buffer asReadOnly(); @Override boolean isDirect(); @Override boolean hasArray(); @Override byte[] array(); @Override int arrayOffset(); @Override String toString(int index, int length, Charset charset);  }### Answer:
@Test(expected = IndexOutOfBoundsException.class) public void setWriterIndexHigherThanCapacity() { Buffer buffer = DEFAULT_RO_ALLOCATOR.fromAscii("test"); buffer.writerIndex(buffer.capacity() + 1); }