use of javax.activation.MimeType in project ddf by codice.
the class TestResourceMetacardTransformer 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);
}
use of javax.activation.MimeType in project ddf by codice.
the class TestResourceMetacardTransformer method testNullMetacardId.
@Test
public void testNullMetacardId() throws Exception {
thrown.expect(CatalogTransformerException.class);
thrown.expectMessage("Could not transform metacard to a resource because the metacard is not valid.");
String filePath = ABSOLUTE_PATH + TEST_PATH + TS_FILE_NAME_1;
URI uri = getUri(filePath);
Metacard metacard = getMockMetacard(uri);
when(metacard.getId()).thenReturn(null);
boolean expectSuccess = false;
MimeType mimeType = getMimeType(VIDEO_MIME_TYPE);
CatalogFramework framework = getFramework(getResourceResponse(getResource(mimeType, uri)));
testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
use of javax.activation.MimeType in project ddf by codice.
the class TestResourceMetacardTransformer method testFrameworkThrowsIoException.
@Test
public void testFrameworkThrowsIoException() 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 IOException("Test IO Exception"));
testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
use of javax.activation.MimeType in project ddf by codice.
the class TestResourceMetacardTransformer method testResourceHasNullMimeType.
@Test
public void testResourceHasNullMimeType() 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(DEFAULT_MIME_TYPE);
CatalogFramework framework = getFramework(getResourceResponse(getResource(null, uri)));
testGetResource(metacard, filePath, mimeType, framework, expectSuccess);
}
use of javax.activation.MimeType in project ddf by codice.
the class TestResourceMetacardTransformer method testGetResourceJpegFromFedSource.
/**
* Tests that the metacard source name is passed to the {@link CatalogFramework}
*
* @throws Exception
*/
@Test
public void testGetResourceJpegFromFedSource() throws Exception {
// given
String filePath = ABSOLUTE_PATH + TEST_PATH + JPEG_FILE_NAME_1;
String federatedSourceId = "fedSourceId";
URI uri = getUri(filePath);
Metacard metacard = getMockMetacard(uri, federatedSourceId);
MimeType mimeType = getMimeType(JPEG_MIME_TYPE);
ArgumentCapture capture = new ArgumentCapture(getResourceResponse(getResource(mimeType, uri)));
CatalogFramework framework = givenFramework(capture);
ResourceMetacardTransformer resourceTransformer = new ResourceMetacardTransformer(framework);
// when
resourceTransformer.transform(metacard, new HashMap<String, Serializable>());
// then
assertEquals(federatedSourceId, capture.inputArgs[1]);
}
Aggregations