public void testLoadFromFile() throws Exception {
   IDMigrator migrator = new FileIDMigrator(testFile);
   long dogAsLong = migrator.toLongID("dog");
   long cowAsLong = migrator.toLongID("cow");
   long donkeyAsLong = migrator.toLongID("donkey");
   assertEquals("dog", migrator.toStringID(dogAsLong));
   assertEquals("cow", migrator.toStringID(cowAsLong));
   assertNull(migrator.toStringID(donkeyAsLong));
 }
  public void testRefreshAfterFileUpdate() throws Exception {
    IDMigrator migrator = new FileIDMigrator(testFile, 0L);

    /* call a method to make sure the original file is loaded */
    long dogAsLong = migrator.toLongID("dog");
    migrator.toStringID(dogAsLong);

    /* change the underlying file,
     * we have to wait at least a second to see the change in the file's lastModified timestamp */
    Thread.sleep(2000L);
    writeLines(testFile, UPDATED_STRING_IDS);

    migrator.refresh(null);

    long cowAsLong = migrator.toLongID("cow");
    long donkeyAsLong = migrator.toLongID("donkey");
    assertEquals("dog", migrator.toStringID(dogAsLong));
    assertEquals("cow", migrator.toStringID(cowAsLong));
    assertEquals("donkey", migrator.toStringID(donkeyAsLong));
  }