@Test
public void testAppend() throws IOException {

    PersistentMessageBuffer b = new PersistentMessageBuffer(mkdir("append"));
    assertTrue(b.toString().contains("append"));
    assertTrue(b.getCreationTime() >= System.currentTimeMillis());
    b.setSegmentLength(10000 + MessageFile.FILE_HEADER_SIZE);
    assertEquals(0, b.getFileCount());
    assertEquals(0L, b.getSize());
    assertEquals(10000 + MessageFile.FILE_HEADER_SIZE, b.getSegmentLength());
    long ts = System.currentTimeMillis();
    assertEquals(0L, append(b, ts, "", 5000));
    assertEquals(5000L, append(b, ts, "", 5000));
    assertEquals(1, b.getFileCount());
    assertEquals(10000L + MessageFile.FILE_HEADER_SIZE, b.getSize());
    assertEquals(10000L, append(b, ts, "", 5000));
    assertEquals(2, b.getFileCount());
    assertEquals(15000L + MessageFile.FILE_HEADER_SIZE * 2, b.getSize());
    assertEquals(15000L, append(b, ts, "", 5000));
    assertEquals(2, b.getFileCount());
    assertEquals(20000L + MessageFile.FILE_HEADER_SIZE * 2, b.getSize());
    b.close();
}