trueTypes.add("image/jpeg");
TrackingHandler tracker = new TrackingHandler(skipTypes);
TikaInputStream tis = null;
try {
ContainerExtractor ex = new ParserContainerExtractor();
tis = TikaInputStream.get(getResourceAsStream("/test-documents/testRTFEmbeddedFiles.rtf"));
assertEquals(true, ex.isSupported(tis));
ex.extract(tis, ex, tracker);
} finally {
tis.close();
}
assertEquals(trueNames.size(), tracker.filenames.size());
assertEquals(trueTypes.size(), tracker.mediaTypes.size());
for (int i = 0; i < tracker.filenames.size(); i++) {
String expectedName = trueNames.get(i);
if (expectedName == null) {
assertNull(tracker.filenames.get(i));
} else {
assertNotNull(tracker.filenames.get(i));
//necessary to getName() because MSOffice extractor includes
//directory: _1457338524/HW.txt
assertEquals("filename equals ",
expectedName, FilenameUtils.getName(tracker.filenames.get(i)));
}
assertEquals(trueTypes.get(i), tracker.mediaTypes.get(i).toString());
}
tracker = new TrackingHandler();
tis = null;
try {
ContainerExtractor ex = new ParserContainerExtractor();
tis = TikaInputStream.get(getResourceAsStream("/test-documents/testRTFEmbeddedFiles.rtf"));
assertEquals(true, ex.isSupported(tis));
ex.extract(tis, ex, tracker);
} finally {
tis.close();
}
assertEquals(47, tracker.filenames.size());