Search in sources :

Example 71 with MimeType

use of javax.activation.MimeType in project ddf by codice.

the class ResourceMetacardTransformerTest method testFrameworkThrowsResourceNotFoundException.

@Test
public void testFrameworkThrowsResourceNotFoundException() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    thrown.expect(CatalogTransformerException.class);
    thrown.expectMessage("Unable to retrieve resource.");
    thrown.expectMessage("Metacard id: " + TEST_ID);
    thrown.expectMessage("Uri: " + uri);
    thrown.expectMessage("Source: " + TEST_SITE);
    boolean expectSuccess = false;
    MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
    CatalogFramework framework = getFrameworkException(new ResourceNotFoundException("Test Resource Not Found Exception"));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) ResourceNotFoundException(ddf.catalog.resource.ResourceNotFoundException) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 72 with MimeType

use of javax.activation.MimeType in project ddf by codice.

the class ResourceMetacardTransformerTest method testNullResourceResponse.

@Test
public void testNullResourceResponse() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    thrown.expect(CatalogTransformerException.class);
    thrown.expectMessage("Unable to retrieve resource.");
    thrown.expectMessage("Metacard id: " + TEST_ID);
    thrown.expectMessage("Uri: " + uri);
    thrown.expectMessage("Source: " + TEST_SITE);
    boolean expectSuccess = false;
    MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
    CatalogFramework framework = getFramework(null);
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 73 with MimeType

use of javax.activation.MimeType in project ddf by codice.

the class ResourceMetacardTransformerTest method testGetResourceTransportStream.

@Test
public void testGetResourceTransportStream() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + TS_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    boolean expectSuccess = true;
    MimeType mimeType = getMimeType(VIDEO_MIME_TYPE);
    CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 74 with MimeType

use of javax.activation.MimeType in project ddf by codice.

the class ResourceMetacardTransformerTest method testFrameworkThrowsResourceNotSupportedException.

@Test
public void testFrameworkThrowsResourceNotSupportedException() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    thrown.expect(CatalogTransformerException.class);
    thrown.expectMessage("Unable to retrieve resource.");
    thrown.expectMessage("Metacard id: " + TEST_ID);
    thrown.expectMessage("Uri: " + uri);
    thrown.expectMessage("Source: " + TEST_SITE);
    boolean expectSuccess = false;
    MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
    CatalogFramework framework = getFrameworkException(new ResourceNotSupportedException("Test Resource Not Supported Exception"));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) ResourceNotSupportedException(ddf.catalog.resource.ResourceNotSupportedException) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Example 75 with MimeType

use of javax.activation.MimeType in project ddf by codice.

the class ResourceMetacardTransformerTest method testGetResourceJpeg.

@Test
public void testGetResourceJpeg() throws Exception {
    String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
    URI uri = getUri(filePath);
    Metacard metacard = getMockMetacard(uri);
    boolean expectSuccess = true;
    MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
    CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
    testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
Also used : Metacard(ddf.catalog.data.Metacard) CatalogFramework(ddf.catalog.CatalogFramework) URI(java.net.URI) MimeType(javax.activation.MimeType) Test(org.junit.Test)

Aggregations

MimeType (javax.activation.MimeType)146 Test (org.junit.Test)74 Metacard (ddf.catalog.data.Metacard)36 MimeTypeParseException (javax.activation.MimeTypeParseException)34 URI (java.net.URI)28 MimeTypeToTransformerMapper (ddf.mime.MimeTypeToTransformerMapper)25 HashMap (java.util.HashMap)25 BundleContext (org.osgi.framework.BundleContext)25 ServiceReference (org.osgi.framework.ServiceReference)25 CatalogFramework (ddf.catalog.CatalogFramework)20 Serializable (java.io.Serializable)16 ResourceResponse (ddf.catalog.operation.ResourceResponse)15 IOException (java.io.IOException)14 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)11 InputStream (java.io.InputStream)10 StringWriter (java.io.StringWriter)10 MetacardCreationException (ddf.catalog.data.MetacardCreationException)9 Resource (ddf.catalog.resource.Resource)9 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)9 File (java.io.File)9