use of ddf.catalog.resourceretriever.LocalResourceRetriever in project ddf by codice.
the class DownloadsStatusEventListenerTest method testGetDownloadStatus.
@Test
public void testGetDownloadStatus() throws URISyntaxException, DownloadException, InterruptedException {
File downloadFile = new File(System.getProperty("user.dir") + "/src/test/resources/125bytes.txt");
MetacardImpl testMetacard = new MetacardImpl();
testMetacard.setId("easyas123");
testMetacard.setResourceURI(downloadFile.toURI());
testMetacard.setResourceSize("125");
testMetacard.setType(BasicTypes.BASIC_METACARD);
URLResourceReader testURLResourceReader = new URLResourceReader();
testURLResourceReader.setRootResourceDirectories(new HashSet<String>(Arrays.asList(new String[] { System.getProperty("user.dir") })));
List<ResourceReader> testResourceReaderList = Collections.singletonList((ResourceReader) testURLResourceReader);
Map<String, Serializable> tmpMap = Collections.emptyMap();
Map<String, Integer> idToBytes = new HashMap<String, Integer>();
testGetDownloadStatusHelper(null, null, null);
testDownloadManager.download(mock(ResourceRequest.class), testMetacard, new LocalResourceRetriever(testResourceReaderList, testMetacard.getResourceURI(), tmpMap));
TimeUnit.SECONDS.sleep(2);
testGetDownloadStatusHelper(idToBytes, DownloadManagerState.DownloadState.COMPLETED.name(), downloadFile.getName());
}
Aggregations