@Test
public void testFlush()
{

    String location = "./target/nameindex-store";
    Helper.removeDir(new File(location));
    NameIndex index = new NameIndex(new RAMDirectory(location, true)).create(1000);
    long pointer = index.put("test");
    index.flush();
    index.close();
    index = new NameIndex(new RAMDirectory(location, true));
    assertTrue(index.loadExisting());
    assertEquals("test", index.get(pointer));
    // make sure bytePointer is correctly set after loadExisting
    long newPointer = index.put("testing");
    assertEquals(newPointer + ">" + pointer, pointer + "test".getBytes().length + 1, newPointer);
    index.close();
    Helper.removeDir(new File(location));
}