Search in sources :

Example 1 with LocalResourceRetriever

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());
}
Also used : URLResourceReader(ddf.catalog.resource.impl.URLResourceReader) ResourceReader(ddf.catalog.resource.ResourceReader) Serializable(java.io.Serializable) HashMap(java.util.HashMap) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) URLResourceReader(ddf.catalog.resource.impl.URLResourceReader) LocalResourceRetriever(ddf.catalog.resourceretriever.LocalResourceRetriever) ResourceRequest(ddf.catalog.operation.ResourceRequest) File(java.io.File) Test(org.junit.Test)

Aggregations

MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 ResourceRequest (ddf.catalog.operation.ResourceRequest)1 ResourceReader (ddf.catalog.resource.ResourceReader)1 URLResourceReader (ddf.catalog.resource.impl.URLResourceReader)1 LocalResourceRetriever (ddf.catalog.resourceretriever.LocalResourceRetriever)1 File (java.io.File)1 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1