Search in sources :

Example 41 with ReliableResource

use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.

the class ResourceCacheImplTest method testContainsTrueValid.

@Test
public void testContainsTrueValid() throws URISyntaxException {
    MetacardImpl cachedMetacard = generateMetacard();
    MetacardImpl latestMetacard = generateMetacard();
    String cacheKey = "cacheKey1";
    resourceCache.put(new ReliableResource(cacheKey, "", null, "name", cachedMetacard));
    assertFalse("cache should be noop", resourceCache.containsValid(cacheKey, latestMetacard));
}
Also used : MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ReliableResource(ddf.catalog.resource.data.ReliableResource) Test(org.junit.Test)

Example 42 with ReliableResource

use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.

the class ResourceCacheImplTest method getSpecificResourceInCache.

@Test
public void getSpecificResourceInCache() {
    ReliableResource cachedResource = createCachedResource(cachedMetacard);
    resourceCache.put(cachedResource);
    Optional<Resource> optionalResource = newResourceCache.get(cachedMetacard, new ResourceRequestById(METACARD_ID));
    assertFalse("cache should be noop", optionalResource.isPresent());
}
Also used : ReliableResource(ddf.catalog.resource.data.ReliableResource) Resource(ddf.catalog.resource.Resource) ResourceRequestById(ddf.catalog.operation.impl.ResourceRequestById) ReliableResource(ddf.catalog.resource.data.ReliableResource) Test(org.junit.Test)

Example 43 with ReliableResource

use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.

the class ResourceCacheImplTest method testContainsTrueInvalid2CantFindFile.

@Test
public void testContainsTrueInvalid2CantFindFile() throws URISyntaxException {
    MetacardImpl cachedMetacard = generateMetacard();
    cachedMetacard.setId("different-id");
    MetacardImpl latestMetacard = generateMetacard();
    String cacheKey = "cacheKey1";
    resourceCache.put(new ReliableResource(cacheKey, "", null, "name", cachedMetacard));
    assertFalse(resourceCache.containsValid(cacheKey, latestMetacard));
}
Also used : MetacardImpl(ddf.catalog.data.impl.MetacardImpl) ReliableResource(ddf.catalog.resource.data.ReliableResource) Test(org.junit.Test)

Example 44 with ReliableResource

use of ddf.catalog.resource.data.ReliableResource in project ddf by codice.

the class ResourceCacheImplTest method createCachedResource.

private ReliableResource createCachedResource(Metacard metacard) {
    String fileName = "15bytes.txt";
    String productLocation = this.getClass().getResource("/" + fileName).getFile();
    File rrCachedFile = new File(productLocation);
    return new ReliableResource(CACHED_RESOURCE_KEY, rrCachedFile.getAbsolutePath(), new MimeType(), fileName, metacard);
}
Also used : File(java.io.File) ReliableResource(ddf.catalog.resource.data.ReliableResource) MimeType(javax.activation.MimeType)

Aggregations

ReliableResource (ddf.catalog.resource.data.ReliableResource)44 Test (org.junit.Test)32 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)15 Metacard (ddf.catalog.data.Metacard)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 Attribute (ddf.catalog.data.Attribute)7 Result (ddf.catalog.data.Result)7 File (java.io.File)7 MockInputStream (ddf.catalog.cache.MockInputStream)6 ResourceCacheInterface (ddf.catalog.cache.ResourceCacheInterface)6 ResultImpl (ddf.catalog.data.impl.ResultImpl)6 QueryResponse (ddf.catalog.operation.QueryResponse)6 ResourceRetriever (ddf.catalog.resourceretriever.ResourceRetriever)6 ArrayList (java.util.ArrayList)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 CacheKey (ddf.catalog.cache.impl.CacheKey)4 ResourceRequestById (ddf.catalog.operation.impl.ResourceRequestById)3 Resource (ddf.catalog.resource.Resource)3 MimeType (javax.activation.MimeType)3 Ignore (org.junit.Ignore)3