Esempio n. 1
0
 public void testLoadFromFile() {
   IDMigrator migrator = new FileIDMigrator(testFile);
   long dogAslong = migrator.tolongID("dog");
   long cowAslong = migrator.tolongID("cow");
   long donkeyAslong = migrator.tolongID("donkey");
   Assert.AreEqual("dog", migrator.toStringID(dogAslong));
   Assert.AreEqual("cow", migrator.toStringID(cowAslong));
   Assert.IsNull(migrator.toStringID(donkeyAslong));
 }
        public void testLoadFromFile()
        {
            IDMigrator migrator     = new FileIDMigrator(testFile);
            long       dogAslong    = migrator.tolongID("dog");
            long       cowAslong    = migrator.tolongID("cow");
            long       donkeyAslong = migrator.tolongID("donkey");

            Assert.AreEqual("dog", migrator.toStringID(dogAslong));
            Assert.AreEqual("cow", migrator.toStringID(cowAslong));
            Assert.IsNull(migrator.toStringID(donkeyAslong));
        }
Esempio n. 3
0
  public void testNoRefreshAfterFileUpdate() {
    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);

    /// we shouldn't see any changes in the data as we have not yet refreshed 
    long cowAslong = migrator.tolongID("cow");
    long donkeyAslong = migrator.tolongID("donkey");
    Assert.AreEqual("dog", migrator.toStringID(dogAslong));
    Assert.AreEqual("cow", migrator.toStringID(cowAslong));
    Assert.IsNull(migrator.toStringID(donkeyAslong));
  }
        public void testNoRefreshAfterFileUpdate()
        {
            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);

            /// we shouldn't see any changes in the data as we have not yet refreshed
            long cowAslong    = migrator.tolongID("cow");
            long donkeyAslong = migrator.tolongID("donkey");

            Assert.AreEqual("dog", migrator.toStringID(dogAslong));
            Assert.AreEqual("cow", migrator.toStringID(cowAslong));
            Assert.IsNull(migrator.toStringID(donkeyAslong));
        }