use of ddf.catalog.data.Metacard in project ddf by codice.
the class TikaInputTransformerTest method testCommentedJpeg.
@Test
public void testCommentedJpeg() throws Exception {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testJPEG_commented.jpg");
/*
* The dates in testJPEG_commented.jpg do not contain timezones. If no timezone is specified,
* the Tika input transformer assumes the local time zone. Set the system timezone to UTC
* so we can do assertions.
*/
TimeZone defaultTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
Metacard metacard = transform(stream);
assertNotNull(metacard);
assertThat(metacard.getTitle(), is("Tosteberga Ă„ngar"));
assertNotNull(metacard.getMetadata());
assertThat(metacard.getMetadata(), containsString("<meta name=\"Keywords\" content=\"bird watching\"/>"));
assertThat(metacard.getContentTypeName(), is("image/jpeg"));
assertThat(convertDate(metacard.getCreatedDate()), is("2010-07-28 11:02:00 UTC"));
// Reset timezone back to local time zone.
TimeZone.setDefault(defaultTimeZone);
assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(IMAGE));
assertThat(metacard.getContentTypeName(), is("image/jpeg"));
}
use of ddf.catalog.data.Metacard in project ddf by codice.
the class TikaInputTransformerTest method testPptx.
@Test
public void testPptx() throws Exception {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testPPT.pptx");
Metacard metacard = transform(stream);
assertNotNull(metacard);
assertThat(metacard.getTitle(), is("Attachment Test"));
assertThat(convertDate(metacard.getCreatedDate()), is("2010-05-04 06:43:54 UTC"));
assertThat(convertDate(metacard.getModifiedDate()), is("2010-06-29 06:34:35 UTC"));
assertNotNull(metacard.getMetadata());
assertThat(metacard.getMetadata(), containsString("content as every other file being tested for tika content parsing"));
assertThat(metacard.getContentTypeName(), is("application/vnd.openxmlformats-officedocument.presentationml.presentation"));
assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(DOCUMENT));
}
use of ddf.catalog.data.Metacard in project ddf by codice.
the class TikaInputTransformerTest method testAudioAu.
@Test
public void testAudioAu() throws Exception {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testAU.au");
Metacard metacard = transform(stream);
assertNotNull(metacard);
assertNotNull(metacard.getMetadata());
assertThat(metacard.getMetadata(), containsString("PCM_SIGNED"));
assertThat(metacard.getContentTypeName(), is("audio/basic"));
assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(SOUND));
}
use of ddf.catalog.data.Metacard in project ddf by codice.
the class TikaInputTransformerTest method testJavaSource.
@Test
public void testJavaSource() throws Exception {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testpackage/testJAVA.java");
Metacard metacard = transform(stream);
assertNotNull(metacard);
assertNotNull(metacard.getMetadata());
assertThat(metacard.getMetadata(), containsString("HelloWorld"));
assertThat(metacard.getContentTypeName(), containsString("text/plain"));
assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(TEXT));
}
use of ddf.catalog.data.Metacard in project ddf by codice.
the class VideoInputTransformer method transform.
@Override
public Metacard transform(InputStream input, String id) throws IOException, CatalogTransformerException {
Parser parser = new AutoDetectParser();
ToXMLContentHandler handler = new ToXMLContentHandler();
TikaMetadataExtractor tikaMetadataExtractor = new TikaMetadataExtractor(parser, handler);
Metadata metadata = tikaMetadataExtractor.parseMetadata(input, new ParseContext());
String metadataText = handler.toString();
if (templates != null) {
metadataText = transformToXml(metadataText);
}
Metacard metacard = MetacardCreator.createMetacard(metadata, id, metadataText, metacardType);
metacard.setAttribute(new AttributeImpl(Core.DATATYPE, DataType.VIDEO.toString()));
return metacard;
}
Aggregations