@Test
public void testCheckpoint() throws IOException {

    File file = new File(dir, "checkpoint.qdb");
    file.delete();
    MessageFile mf = new MessageFile(file, 0, 1000000);
    append(mf, System.currentTimeMillis(), "", "oink".getBytes("UTF8"));
    mf.checkpoint(false);
    mf.close();
    DataInputStream ins = new DataInputStream(new FileInputStream(file));
    int expectedLength = (int) file.length();
    ins.skip(2 + 2 + 4);
    assertEquals(expectedLength, ins.readInt());
    ins.close();
    FileOutputStream out = new FileOutputStream(file, true);
    out.write("junk".getBytes("UTF8"));
    out.close();
    assertEquals(expectedLength + 4, file.length());
    new MessageFile(file, 0, 1000000).close();
    assertEquals(expectedLength, file.length());
}