use of org.apache.tika.metadata.Metadata in project tika by apache.
the class AudioParserTest method testWAV.
@Test
public void testWAV() throws Exception {
String path = "/test-documents/testWAV.wav";
Metadata metadata = new Metadata();
String content = new Tika().parseToString(AudioParserTest.class.getResourceAsStream(path), metadata);
assertEquals("audio/x-wav", 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 Pkcs7ParserTest method testDetachedSignature.
public void testDetachedSignature() throws Exception {
try (InputStream input = Pkcs7ParserTest.class.getResourceAsStream("/test-documents/testDetached.p7s")) {
ContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
new Pkcs7Parser().parse(input, handler, metadata, new ParseContext());
} catch (NullPointerException npe) {
fail("should not get NPE");
} catch (TikaException te) {
assertTrue(te.toString().contains("cannot parse detached pkcs7 signature"));
}
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class SourceCodeParserTest method createMetadata.
private Metadata createMetadata(String mimeType) {
Metadata metadata = new Metadata();
metadata.add(Metadata.RESOURCE_NAME_KEY, "testFile");
metadata.add(Metadata.CONTENT_TYPE, mimeType);
return metadata;
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class DBFParserTest method testVariants.
@Test
public void testVariants() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (InputStream is = getResourceAsStream("/test-documents/testDBF.dbf")) {
IOUtils.copy(is, bos);
}
byte[] bytes = bos.toByteArray();
for (DBFReader.Version version : DBFReader.Version.values()) {
//this cast happens to work because of the range of possible values
bytes[0] = (byte) version.getId();
XMLResult r = getXML(TikaInputStream.get(bytes), new AutoDetectParser(), new Metadata());
assertEquals(version.getFullMimeString(), r.metadata.get(Metadata.CONTENT_TYPE));
}
}
use of org.apache.tika.metadata.Metadata in project tika by apache.
the class ExecutableParserTest method testElfParser_x86_32.
@Test
public void testElfParser_x86_32() throws Exception {
XMLResult r = getXML("testLinux-x86-32");
Metadata metadata = r.metadata;
assertEquals("application/x-executable", metadata.get(Metadata.CONTENT_TYPE));
assertEquals(ExecutableParser.MACHINE_x86_32, metadata.get(ExecutableParser.MACHINE_TYPE));
assertEquals("Little", metadata.get(ExecutableParser.ENDIAN));
assertEquals("32", metadata.get(ExecutableParser.ARCHITECTURE_BITS));
// assertEquals("Linux",
// metadata.get(ExecutableParser.PLATFORM));
assertContains("<body />", r.xml);
}
Aggregations