@Test
public void testCleanup() throws IOException {

    File bd = mkdir("cleanup");
    PersistentMessageBuffer b = new PersistentMessageBuffer(bd);
    b.setSegmentLength(8192 + MessageFile.FILE_HEADER_SIZE);
    append(b, 0, "", 8192);
    append(b, 0, "", 8192);
    append(b, 0, "", 8192);
    append(b, 0, "", 8192);
    expect(bd.list(),
            "0000000000000000-0000000000000000-1.qdb", "0000000000002000-0000000000000000-1.qdb",
            "0000000000004000-0000000000000000-1.qdb", "0000000000006000-0000000000000000-0.qdb");
    b.setMaxSize((8192 + MessageFile.FILE_HEADER_SIZE) * 2);
    b.cleanup();
    assertEquals(0x4000, b.getOldestId());
    expect(bd.list(), "0000000000004000-0000000000000000-1.qdb", "0000000000006000-0000000000000000-0.qdb");
    b.setMaxSize(1);  // can't get rid of last file
    b.cleanup();
    expect(bd.list(), "0000000000006000-0000000000000000-0.qdb");
    b.close();
}