@Test
public void testMark() {

    ByteBuffer bb1 = ByteBuffer.allocate(4);
    bb1.put("0123".getBytes());
    bb1.flip();
    ByteBuffer bb2 = ByteBuffer.allocate(4);
    bb2.put("4567".getBytes());
    bb2.flip();
    IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
    ioBuffer.position(3);
    ioBuffer.mark();
    // check that we are at the right position
    byte b = ioBuffer.get();
    assertEquals(b, '3');
    b = ioBuffer.get();
    assertEquals(b, '4');
    // Now reset to the mark
    ioBuffer.reset();
    b = ioBuffer.get();
    assertEquals(b, '3');
    ioBuffer.position(6);
    ioBuffer.reset();
    ioBuffer.position(6);
    ioBuffer.mark();
    // we go backward, the mark should be discarded
    ioBuffer.position(3);
    try {
        ioBuffer.reset();
        fail("An InvalidMarkException should have been thrown");
    } catch (InvalidMarkException ime) {
        //
    }
}