use of org.apache.tika.detect.CompositeDetector in project tika by apache.
the class TikaDetectorConfigTest method testDetectorExcludeFromDefault.
@Test
public void testDetectorExcludeFromDefault() throws Exception {
TikaConfig config = getConfig("TIKA-1702-detector-blacklist.xml");
assertNotNull(config.getParser());
assertNotNull(config.getDetector());
CompositeDetector detector = (CompositeDetector) config.getDetector();
// Should be wrapping two detectors
assertEquals(2, detector.getDetectors().size());
// First should be DefaultDetector, second Empty, that order
assertEquals(DefaultDetector.class, detector.getDetectors().get(0).getClass());
assertEquals(EmptyDetector.class, detector.getDetectors().get(1).getClass());
// Get the DefaultDetector from the config
DefaultDetector confDetector = (DefaultDetector) detector.getDetectors().get(0);
// Get a fresh "default" DefaultParser
DefaultDetector normDetector = new DefaultDetector(config.getMimeRepository());
// The default one will offer the Zip and POIFS detectors
assertDetectors(normDetector, true, true);
// The one from the config won't, as we excluded those
assertDetectors(confDetector, false, false);
}
Aggregations