SyncManager implements ChangeHandler { public SyncManager(List<File> watchDirs, SyncEndpoint endpoint, int threads, long frequency) { logger.info("Starting Sync Manager with " + threads + " threads"); this.watchDirs = watchDirs; this.endpoint = endpoint; changeWatcher = new ChangeWatcher(ChangedList.getInstance(), this, frequency); watcherPool = Executors.newFixedThreadPool(1); workerPool = new ThreadPoolExecutor(threads, threads, Long.MAX_VALUE, TimeUnit.NANOSECONDS, new SynchronousQueue(), new ThreadPoolExecutor.AbortPolicy()); workerList = new ArrayList<SyncWorker>(); } SyncManager(List<File> watchDirs,
                       SyncEndpoint endpoint,
                       int threads,
                       long frequency); void beginSync(); void endSync(); void terminateSync(); synchronized boolean handleChangedFile(ChangedFile changedFile); synchronized List<MonitoredFile> getFilesInTransfer();  }
@Test public void testSyncManager() throws Exception { File tempDir = new File(System.getProperty("java.io.tmpdir")); List<File> watchDirs = new ArrayList<File>(); watchDirs.add(tempDir); SyncManager syncManager = new SyncManager(watchDirs, new TestEndpoint(), 2, 100); syncManager.beginSync(); int changedFiles = 10; for (int i = 0; i < changedFiles; i++) { changedList.addChangedFile(new File(tempDir, "test-file-" + i)); } Thread.sleep(2000); assertEquals(changedFiles, handledFiles); syncManager.endSync(); }