SyncWorker implements Runnable { public void run() { SyncResultType result; start = new Date(); File file = syncFile.getFile(); String filePath = (null != file ? file.getAbsolutePath() : "null"); try { result = syncEndpoint.syncFileAndReturnDetailedResult(monitoredFile, watchDir); stop = new Date(); } catch (Exception e) { logger.error("Exception syncing file " + filePath + " was " + e.getMessage(), e); result = SyncResultType.FAILED; } try { if (result != SyncResultType.FAILED) { SyncSummary summary = new SyncSummary(file, start, stop, result, ""); statusManager.successfulCompletion(summary); } else { retryOnFailure(); } } catch (Throwable e) { logger.error("Unexpected error: " + e.getMessage() + " - sync result = " + result + "; file=" + filePath, e); } this.syncFile.remove(); complete = true; } SyncWorker(ChangedFile file, File watchDir, SyncEndpoint endpoint); void run(); boolean isComplete(); MonitoredFile getMonitoredFile();  }
@Test public void testDuracloud1131() { assertEquals(0, ChangedList.getInstance().getListSizeIncludingReservedFiles()); ChangedList.getInstance().addChangedFile(new File("path")); assertEquals(1, ChangedList.getInstance().getListSizeIncludingReservedFiles()); ChangedFile changedFile = ChangedList.getInstance().reserve(); assertEquals(0, ChangedList.getInstance().getListSize()); assertEquals(1, ChangedList.getInstance().getListSizeIncludingReservedFiles()); File watchDir = createMock(File.class); SyncEndpoint endpoint = createMock(SyncEndpoint.class); expect(endpoint.syncFileAndReturnDetailedResult(isA(MonitoredFile.class), isA(File.class))) .andReturn(SyncResultType.FAILED); replayAll(); SyncWorker worker = new SyncWorker(changedFile, watchDir, endpoint); worker.run(); assertEquals(1, ChangedList.getInstance().getListSizeIncludingReservedFiles()); }