RetrievalWorker implements Runnable { public Map<String, String> retrieveFile() { return retrieveFile(null); } RetrievalWorker(ContentItem contentItem,
                           RetrievalSource source,
                           File contentDir,
                           boolean overwrite,
                           OutputWriter outWriter,
                           boolean createSpaceDir,
                           boolean applyTimestamps); void run(); Map<String, String> retrieveFile(); Map<String, String> retrieveFile(RetrievalListener listener); File getLocalFile();  }
@Test public void testRetrieveFile() throws Exception { RetrievalWorker worker = createRetrievalWorker(true); File localFile = worker.getLocalFile(); assertFalse(localFile.exists()); StatusManager status = StatusManager.getInstance(); status.reset(); Map<String, String> props; props = worker.retrieveFile(); checkFile(localFile, contentValue); checkStatus(status, 1, 0, 0); assertNotNull(props); props = worker.retrieveFile(); checkFile(localFile, contentValue); checkStatus(status, 0, 1, 0); assertNotNull(props); String newValue = "new-value"; FileUtils.writeStringToFile(localFile, newValue); props = worker.retrieveFile(); checkFile(localFile, contentValue); checkStatus(status, 1, 0, 0); File copyFile = new File(localFile.getAbsolutePath() + "-copy"); assertFalse(copyFile.exists()); assertNotNull(props); worker = createRetrievalWorker(false); FileUtils.writeStringToFile(localFile, newValue); props = worker.retrieveFile(); checkFile(localFile, contentValue); checkStatus(status, 1, 0, 0); assertTrue(copyFile.exists()); checkFile(copyFile, newValue); assertNotNull(props); }