Search in sources :

Example 46 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testPng.

@Test
public void testPng() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testPNG.png");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("<meta name=\"Compression Lossless\" content=\"true\"/>"));
    assertThat(metacard.getContentTypeName(), is("image/png"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(IMAGE));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 47 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testXml.

@Test
public void testXml() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testXML.xml");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Test Document"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2000-12-01 00:00:00 UTC"));
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("John Smith"));
    assertThat(metacard.getContentTypeName(), is("application/xml"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(DOCUMENT));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 48 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testEmail.

@Test
public void testEmail() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testEmail.eml");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Welcome"));
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("<meta name=\"Content-Type\" content=\"message/rfc822\"/>"));
    assertThat(metacard.getContentTypeName(), is("message/rfc822"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(DATASET));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 49 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testAudioMidi.

@Test
public void testAudioMidi() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testMID.mid");
    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("PPQ"));
    assertThat(metacard.getContentTypeName(), is("audio/midi"));
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(SOUND));
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 50 with Metacard

use of ddf.catalog.data.Metacard in project ddf by codice.

the class TikaInputTransformerTest method testGeoTaggedJpeg.

@Test
public void testGeoTaggedJpeg() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("testJPEG_GEO.jpg");
    /*
         * The dates in testJPED_GEO.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);
    assertNotNull(metacard.getMetadata());
    assertThat(metacard.getMetadata(), containsString("<meta name=\"Model\" content=\"Canon EOS 40D\"/>"));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2009-08-11 09:09:45 UTC"));
    assertThat(convertDate(metacard.getModifiedDate()), is("2009-10-02 23:02:49 UTC"));
    assertThat(metacard.getAttribute(Metacard.GEOGRAPHY).getValue(), is("POINT(-54.1234 12.54321)"));
    // Reset timezone back to local time zone.
    TimeZone.setDefault(defaultTimeZone);
    assertThat(metacard.getAttribute(Core.DATATYPE).getValue(), is(IMAGE));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
}
Also used : TimeZone(java.util.TimeZone) Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Test(org.junit.Test)

Aggregations

Metacard (ddf.catalog.data.Metacard)746 Test (org.junit.Test)470 ArrayList (java.util.ArrayList)206 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)149 InputStream (java.io.InputStream)136 HashMap (java.util.HashMap)129 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)115 Result (ddf.catalog.data.Result)109 Serializable (java.io.Serializable)100 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)90 QueryRequest (ddf.catalog.operation.QueryRequest)84 QueryImpl (ddf.catalog.operation.impl.QueryImpl)80 QueryResponse (ddf.catalog.operation.QueryResponse)78 SourceResponse (ddf.catalog.operation.SourceResponse)76 IOException (java.io.IOException)75 List (java.util.List)74 Map (java.util.Map)67 Filter (org.opengis.filter.Filter)67 CreateResponse (ddf.catalog.operation.CreateResponse)66 HashSet (java.util.HashSet)65