use of org.apache.tika.metadata.Metadata in project tika by apache.
the class AudioParserTest method testAU.
@Test
public void testAU() throws Exception {
String path = "/test-documents/testAU.au";
Metadata metadata = new Metadata();
String content = new Tika().parseToString(AudioParserTest.class.getResourceAsStream(path), metadata);
assertEquals("audio/basic", metadata.get(Metadata.CONTENT_TYPE));
assertEquals("44100.0", metadata.get("samplerate"));
assertEquals("2", metadata.get("channels"));
assertEquals("16", metadata.get("bits"));
assertEquals("PCM_SIGNED", metadata.get("encoding"));
assertEquals("", content);
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class MidiParserTest method testMID.
@Test
public void testMID() throws Exception {
String path = "/test-documents/testMID.mid";
Metadata metadata = new Metadata();
String content = new Tika().parseToString(MidiParserTest.class.getResourceAsStream(path), metadata);
assertEquals("audio/midi", metadata.get(Metadata.CONTENT_TYPE));
assertEquals("2", metadata.get("tracks"));
assertEquals("0", metadata.get("patches"));
assertEquals("PPQ", metadata.get("divisionType"));
assertContains("Untitled", content);
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class DWGParserTest method testParser.
@SuppressWarnings("deprecation")
private void testParser(InputStream input) throws Exception {
try {
Metadata metadata = new Metadata();
ContentHandler handler = new BodyContentHandler();
new DWGParser().parse(input, handler, metadata);
assertEquals("image/vnd.dwg", metadata.get(Metadata.CONTENT_TYPE));
assertEquals("The quick brown fox jumps over the lazy dog", metadata.get(TikaCoreProperties.TITLE));
assertEquals("Gym class featuring a brown fox and lazy dog", metadata.get(TikaCoreProperties.DESCRIPTION));
assertEquals("Gym class featuring a brown fox and lazy dog", metadata.get(Metadata.SUBJECT));
assertEquals("Nevin Nollop", metadata.get(TikaCoreProperties.CREATOR));
assertEquals("Pangram, fox, dog", metadata.get(TikaCoreProperties.KEYWORDS));
assertEquals("Lorem ipsum", metadata.get(TikaCoreProperties.COMMENTS).substring(0, 11));
assertEquals("http://www.alfresco.com", metadata.get(TikaCoreProperties.RELATION));
// Check some of the old style metadata too
assertEquals("The quick brown fox jumps over the lazy dog", metadata.get(Metadata.TITLE));
assertEquals("Gym class featuring a brown fox and lazy dog", metadata.get(Metadata.SUBJECT));
String content = handler.toString();
assertContains("The quick brown fox jumps over the lazy dog", content);
assertContains("Gym class", content);
assertContains("www.alfresco.com", content);
} finally {
input.close();
}
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class EnviHeaderParserTest method testParseGlobalMetadata.
@Test
public void testParseGlobalMetadata() throws Exception {
if (System.getProperty("java.version").startsWith("1.5")) {
return;
}
Parser parser = new EnviHeaderParser();
ToXMLContentHandler handler = new ToXMLContentHandler();
Metadata metadata = new Metadata();
try (InputStream stream = EnviHeaderParser.class.getResourceAsStream("/test-documents/envi_test_header.hdr")) {
assertNotNull("Test ENVI file not found", stream);
parser.parse(stream, handler, metadata, new ParseContext());
}
// Check content of test file
String content = handler.toString();
assertContains("<body><p>ENVI</p>", content);
assertContains("<p>samples = 2400</p>", content);
assertContains("<p>lines = 2400</p>", content);
assertContains("<p>map info = {Sinusoidal, 1.5000, 1.5000, -10007091.3643, 5559289.2856, 4.6331271653e+02, 4.6331271653e+02, , units=Meters}</p>", content);
assertContains("content=\"application/envi.hdr\"", content);
assertContains("projection info = {16, 6371007.2, 0.000000, 0.0, 0.0, Sinusoidal, units=Meters}", content);
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class DWGParserTest method testDWG2010CustomPropertiesParser.
@Test
public void testDWG2010CustomPropertiesParser() throws Exception {
// Check that standard parsing works
InputStream testInput = DWGParserTest.class.getResourceAsStream("/test-documents/testDWG2010_custom_props.dwg");
testParser(testInput);
// Check that custom properties with alternate padding work
try (InputStream input = DWGParserTest.class.getResourceAsStream("/test-documents/testDWG2010_custom_props.dwg")) {
Metadata metadata = new Metadata();
ContentHandler handler = new BodyContentHandler();
new DWGParser().parse(input, handler, metadata, null);
assertEquals("valueforcustomprop1", metadata.get("customprop1"));
assertEquals("valueforcustomprop2", metadata.get("customprop2"));
}
}
Aggregations