Ejemplo n.º 1
0
  public void testFileChange() throws Exception {
    LocalHistoryTestStore store = createStore();
    LogHandler lh = new LogHandler("copied file", LogHandler.Compare.STARTS_WITH);

    long ts = System.currentTimeMillis();

    // create file in store
    File file = new File(dataDir, "file1");
    createFile(store, file, ts, "data");

    File storefile = store.getStoreFile(file, ts, false);
    // change file with same ts
    // XXX
    //        if(store.lastModified(file) != ts) {
    //            changeFile(store, file, ts, "data2");
    //        }
    // check that nothing changed
    assertFile(file, store, ts, storefile.lastModified(), 1, 1, "data", TOUCHED);

    // change file with new ts
    ts = System.currentTimeMillis();
    lh.reset();
    changeFile(store, file, ts, "data2");
    lh.waitUntilDone();

    // check the change
    assertFile(file, store, ts, -1, 2, 1, "data2", TOUCHED);
  }
Ejemplo n.º 2
0
  public void testFileDelete() throws Exception {
    cleanUpDataFolder();
    LocalHistoryTestStore store = createStore();
    long ts = System.currentTimeMillis();

    // create file in store
    File file = new File(dataDir, "file1");
    createFile(store, file, ts, "data");

    store.fileDelete(file, ts);
    // check
    File storefile = store.getStoreFile(file, ts, false);
    assertFile(file, store, ts, storefile.lastModified(), 1, 1, "data", DELETED);

    file = new File(dataDir, "file2");
    createFile(store, file, ts, "data");

    store.fileDelete(file, ts);
    // check
    storefile = store.getStoreFile(file, ts, false);
    assertFile(file, store, ts, storefile.lastModified(), 1, 1, "data", DELETED);
  }
Ejemplo n.º 3
0
  public void testWrite2StoreVsCleanUp() throws Exception {
    LocalHistoryTestStore store = createStore();
    long ts = System.currentTimeMillis();

    File file = new File(dataDir, "crapfile");

    File storefile = store.getStoreFile(file, ts, true);
    assertTrue(storefile.getParentFile().exists());
    assertFalse(storefile.exists());

    store.cleanUp(ts); // shouldn't remove the storefiles parent even if it's still empty
    assertTrue(storefile.getParentFile().exists());

    OutputStream os1 = StoreEntry.createStoreFileOutputStream(storefile);
  }