@Test
    public void testSliceBuffer() {
        ByteBuffer buffer = ByteBuffer.allocate(10);

        for (int i = 0; i < buffer.capacity(); ++i) {
            buffer.put((byte) i);
        }

        int sliceStart = 3;
        int sliceEnd = 7;
        buffer.position(sliceStart);
        buffer.limit(sliceEnd);

        ByteBuffer slice = buffer.slice();

        for (int i = 0; i < slice.capacity(); ++i) {
            byte b = slice.get(i);
            b *= 11;
            slice.put(i, b);
        }

        buffer.position(0);
        buffer.limit(buffer.capacity());

        while (buffer.remaining() > 0) {
            int pos = buffer.position();
            byte b = buffer.get();
            System.out.println(pos + " " + b);
            if (pos < sliceStart || pos >= sliceEnd) {
                assertEquals(pos, b);
            } else {
                assertEquals(pos * 11, b);
            }
        }
    }