@Test
public void endsWith() throws BufferException {

    ByteBuffer buffer = createCircledByteBuffer(TEST_BYTES1.length);
    buffer.add(TEST_BYTES1);
    //byte[] tmpbuf = buffer.toArray();
    //String tmpstr = createDebugString(tmpbuf);
    //logger.debug("buffer currently contains=" + tmpstr);
    Assert.assertEquals(false, buffer.endsWith(TEST_H));
    Assert.assertEquals(false, buffer.endsWith(TEST_HELLO));
    Assert.assertEquals(true, buffer.endsWith(TEST_WORLD));
    buffer.clear();
    buffer.add(TEST_WORLD);
    //byte[] tmpbuf2 = buffer.toArray();
    //String tmpstr2 = createDebugString(tmpbuf2);
    //logger.debug("buffer currently contains=" + tmpstr2);
    Assert.assertEquals(true, buffer.endsWith(TEST_D));
    Assert.assertEquals(false, buffer.endsWith(TEST_HELLO));
    Assert.assertEquals(true, buffer.endsWith(TEST_WORLD));
    Assert.assertEquals(false, buffer.endsWith(TEST_W));
    buffer.clear();
    buffer.add(TEST_HELLO);
    Assert.assertEquals(false, buffer.endsWith(TEST_H));
    Assert.assertEquals(true, buffer.endsWith(TEST_HELLO));
    // test a longer buffer that does start with the same buffer
    Assert.assertEquals(false, buffer.endsWith(TEST_BYTES1));
}