FileTriggerTracker { synchronized protected void takeFullSnapshot(DirectorySnapshot snapshot) { FileAlterationObserver observer = new FileAlterationObserver(fileTriggerRouter.getFileTrigger().getBaseDir(), fileTriggerRouter .getFileTrigger().createIOFileFilter()); observer.addListener(new SnapshotUpdater(snapshot)); observer.checkAndNotify(); } FileTriggerTracker(FileTriggerRouter fileTriggerRouter, DirectorySnapshot lastSnapshot, ProcessInfo processInfo,
            boolean useCrc, ISymmetricEngine engine); synchronized DirectorySnapshot trackChanges();  }
@Test public void testTakeFullSnapshotRecursive() throws Exception { FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), true, null, null); Router router = new Router(); FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router); FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null); DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter); tracker.takeFullSnapshot(snapshot); assertEquals(4, snapshot.size()); }
@Test public void testTakeFullSnapshotNonRecursive() throws Exception { FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, null, null); Router router = new Router(); FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router); FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null); DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter); tracker.takeFullSnapshot(snapshot); assertEquals(2, snapshot.size()); }
@Test public void testTakeFullSnapshotIncludes() throws Exception { FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, "*.txt", null); Router router = new Router(); FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router); FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null); DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter); tracker.takeFullSnapshot(snapshot); assertEquals(1, snapshot.size()); assertEquals(snapshot.get(0).getFileName(), FileSyncUtils.getRelativePath(fileInDirectory1, directory)); }
@Test public void testTakeFullSnapshotExcludes() throws Exception { FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, null, "*.txt"); Router router = new Router(); FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router); FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null); DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter); tracker.takeFullSnapshot(snapshot); assertEquals(1, snapshot.size()); assertEquals(snapshot.get(0).getFileName(), FileSyncUtils.getRelativePath(fileInDirectory2, directory)); }