Search in sources :

Example 21 with ResourceRetriever

use of ddf.catalog.resourceretriever.ResourceRetriever in project ddf by codice.

the class ReliableResourceDownloadManagerTest method testClientCancelProductDownloadCachingContinues.

/**
     * Tests that if user/client cancels a product retrieval that is in progress and
     * actively being cached, and the admin has configured caching to continue,
     * that the caching continues and cached file is placed in the cache map.
     *
     * @throws Exception
     */
@Test
@Ignore
public void testClientCancelProductDownloadCachingContinues() throws Exception {
    mis = new MockInputStream(productInputFilename);
    Metacard metacard = getMockMetacard(EXPECTED_METACARD_ID, EXPECTED_METACARD_SOURCE_ID);
    resourceResponse = getMockResourceResponse();
    ResourceRetriever retriever = getMockResourceRetrieverWithRetryCapability(RetryType.CLIENT_CANCELS_DOWNLOAD);
    int chunkSize = 50;
    startDownload(true, chunkSize, true, metacard, retriever);
    // On second read of ReliableResourceInputStream, client will close the stream simulating a cancel
    // of the product download
    clientRead(chunkSize, productInputStream, 2);
    // Captures the ReliableResource object that should have been put in the ResourceCacheImpl's map
    ArgumentCaptor<ReliableResource> argument = ArgumentCaptor.forClass(ReliableResource.class);
    verify(resourceCache, timeout(3000)).put(argument.capture());
    verifyCaching(argument.getValue(), EXPECTED_CACHE_KEY);
    cleanup();
}
Also used : MockInputStream(ddf.catalog.cache.MockInputStream) Metacard(ddf.catalog.data.Metacard) ResourceRetriever(ddf.catalog.resourceretriever.ResourceRetriever) ReliableResource(ddf.catalog.resource.data.ReliableResource) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ResourceRetriever (ddf.catalog.resourceretriever.ResourceRetriever)21 Test (org.junit.Test)19 Metacard (ddf.catalog.data.Metacard)18 MockInputStream (ddf.catalog.cache.MockInputStream)13 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 Ignore (org.junit.Ignore)8 CacheKey (ddf.catalog.cache.impl.CacheKey)6 ReliableResource (ddf.catalog.resource.data.ReliableResource)6 ResourceRequest (ddf.catalog.operation.ResourceRequest)5 ResourceResponse (ddf.catalog.operation.ResourceResponse)3 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)2 IOException (java.io.IOException)2 DownloadStatusInfoImpl (ddf.catalog.event.retrievestatus.DownloadStatusInfoImpl)1 ResourceNotSupportedException (ddf.catalog.resource.ResourceNotSupportedException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CancellationException (java.util.concurrent.CancellationException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MimeType (javax.activation.MimeType)1 MimeTypeParseException (javax.activation.MimeTypeParseException)1