Search in sources :

Example 16 with CacheKey

use of ddf.catalog.cache.impl.CacheKey in project ddf by codice.

the class CacheKeyTest method testKeyUniquenessProperty.

/**
     * Tests the key will be unique if given a different property in the ResourceRequest.
     */
@Test
public void testKeyUniquenessProperty() {
    Map<String, Serializable> propertyMap = new HashMap<>();
    propertyMap.put(ResourceRequest.OPTION_ARGUMENT, "pdf");
    CacheKey cacheKey1 = new CacheKey(getMetacardStub("sampleId1", "source1"), getResourceRequestStub(propertyMap));
    CacheKey cacheKey2 = new CacheKey(getMetacardStub("sampleId1", "source1"), getResourceRequestStub());
    String key1 = cacheKey1.generateKey();
    String key2 = cacheKey2.generateKey();
    assertThat("Keys must be different.", key1, not(equalTo(key2)));
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) CacheKey(ddf.catalog.cache.impl.CacheKey) Test(org.junit.Test)

Example 17 with CacheKey

use of ddf.catalog.cache.impl.CacheKey in project ddf by codice.

the class CacheKeyTest method testKeyUniquenessFromSourcesAndIds.

@Test
public void testKeyUniquenessFromSourcesAndIds() {
    CacheKey cacheKey1 = new CacheKey(getMetacardStub("sampleId1", "source1"), getResourceRequestStub());
    CacheKey cacheKey2 = new CacheKey(getMetacardStub("sampleId2", "source2"), getResourceRequestStub());
    String key1 = cacheKey1.generateKey();
    String key2 = cacheKey2.generateKey();
    assertThat("Keys must be different.", key1, not(equalTo(key2)));
}
Also used : CacheKey(ddf.catalog.cache.impl.CacheKey) Test(org.junit.Test)

Example 18 with CacheKey

use of ddf.catalog.cache.impl.CacheKey in project ddf by codice.

the class CacheKeyTest method testKeyUniquenessFromSourcesWithoutResourceRequest.

@Test
public void testKeyUniquenessFromSourcesWithoutResourceRequest() {
    CacheKey cacheKey1 = new CacheKey(getMetacardStub("sampleId", "source1"));
    CacheKey cacheKey2 = new CacheKey(getMetacardStub("sampleId", "source2"));
    String key1 = cacheKey1.generateKey();
    String key2 = cacheKey2.generateKey();
    assertThat("Keys must be different.", key1, not(equalTo(key2)));
}
Also used : CacheKey(ddf.catalog.cache.impl.CacheKey) Test(org.junit.Test)

Example 19 with CacheKey

use of ddf.catalog.cache.impl.CacheKey in project ddf by codice.

the class CacheKeyTest method testKeyConsistencyWithoutResourceRequest.

@Test
public void testKeyConsistencyWithoutResourceRequest() {
    CacheKey cacheKey1 = new CacheKey(getMetacardStub("sampleId1", "source1"));
    CacheKey cacheKey2 = new CacheKey(getMetacardStub("sampleId1", "source1"));
    String key1 = cacheKey1.generateKey();
    String key2 = cacheKey2.generateKey();
    assertThat("The same input to cache key should generate the same output.", key1, equalTo(key2));
}
Also used : CacheKey(ddf.catalog.cache.impl.CacheKey) Test(org.junit.Test)

Example 20 with CacheKey

use of ddf.catalog.cache.impl.CacheKey in project ddf by codice.

the class CacheKeyTest method testKeyConsistency.

@Test
public void testKeyConsistency() {
    Map<String, Serializable> propertyMap = new HashMap<>();
    propertyMap.put("pdf", "sample.pdf");
    CacheKey cacheKey1 = new CacheKey(getMetacardStub("sampleId1", "source1"), getResourceRequestStub(propertyMap));
    CacheKey cacheKey2 = new CacheKey(getMetacardStub("sampleId1", "source1"), getResourceRequestStub(propertyMap));
    String key1 = cacheKey1.generateKey();
    String key2 = cacheKey2.generateKey();
    assertThat("The same input to cache key should generate the same output.", key1, equalTo(key2));
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) CacheKey(ddf.catalog.cache.impl.CacheKey) Test(org.junit.Test)

Aggregations

CacheKey (ddf.catalog.cache.impl.CacheKey)20 Test (org.junit.Test)17 Metacard (ddf.catalog.data.Metacard)7 MockInputStream (ddf.catalog.cache.MockInputStream)6 ResourceRetriever (ddf.catalog.resourceretriever.ResourceRetriever)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 ReliableResource (ddf.catalog.resource.data.ReliableResource)4 Ignore (org.junit.Ignore)4 Serializable (java.io.Serializable)3 HashMap (java.util.HashMap)3 ResourceResponseImpl (ddf.catalog.operation.impl.ResourceResponseImpl)2 Resource (ddf.catalog.resource.Resource)2 IOException (java.io.IOException)2 CountingOutputStream (com.google.common.io.CountingOutputStream)1 FileBackedOutputStream (com.google.common.io.FileBackedOutputStream)1 Attribute (ddf.catalog.data.Attribute)1 Result (ddf.catalog.data.Result)1 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 ResourceRequest (ddf.catalog.operation.ResourceRequest)1 ResourceResponse (ddf.catalog.operation.ResourceResponse)1