@Test(expected = ReadOnlyBufferException.class)
public void testSetBytesWithChannel() throws IOException {

    ByteBuf buf = newBuffer(wrappedBuffer(new byte[8]));
    try {
        buf.setBytes(0, new ScatteringByteChannel() {
            @Override
            public long read(ByteBuffer[] dsts, int offset, int length) {
                return 0;
            }
            @Override
            public long read(ByteBuffer[] dsts) {
                return 0;
            }
            @Override
            public int read(ByteBuffer dst) {
                return 0;
            }
            @Override
            public boolean isOpen() {
                return true;
            }
            @Override
            public void close() {
            }
        }, 4);
    } finally {
        buf.release();
    }
}