Search in sources :

Example 1 with POIFSContainerDetector

use of org.apache.tika.parser.microsoft.POIFSContainerDetector in project tika by apache.

the class TikaDetectorsTest method testGetHTML.

@Test
public void testGetHTML() throws Exception {
    Response response = WebClient.create(endPoint + DETECTORS_PATH).type("text/html").accept("text/html").get();
    String text = getStringFromInputStream((InputStream) response.getEntity());
    assertContains("<h2>DefaultDetector</h2>", text);
    assertContains("Composite", text);
    assertContains("<h3>OggDetector", text);
    assertContains("<h3>POIFSContainerDetector", text);
    assertContains("<h3>MimeTypes", text);
    assertContains(OggDetector.class.getName(), text);
    assertContains(POIFSContainerDetector.class.getName(), text);
    assertContains(ZipContainerDetector.class.getName(), text);
    assertContains(MimeTypes.class.getName(), text);
}
Also used : Response(javax.ws.rs.core.Response) POIFSContainerDetector(org.apache.tika.parser.microsoft.POIFSContainerDetector) ZipContainerDetector(org.apache.tika.parser.pkg.ZipContainerDetector) OggDetector(org.gagravarr.tika.OggDetector) MimeTypes(org.apache.tika.mime.MimeTypes) Test(org.junit.Test)

Example 2 with POIFSContainerDetector

use of org.apache.tika.parser.microsoft.POIFSContainerDetector in project tika by apache.

the class TikaDetectorConfigTest method assertDetectors.

private void assertDetectors(CompositeDetector detector, boolean shouldHavePOIFS, boolean shouldHaveZip) {
    boolean hasZip = false;
    boolean hasPOIFS = false;
    for (Detector d : detector.getDetectors()) {
        if (d instanceof ZipContainerDetector) {
            if (shouldHaveZip) {
                hasZip = true;
            } else {
                fail("Shouldn't have the ZipContainerDetector from config");
            }
        }
        if (d instanceof POIFSContainerDetector) {
            if (shouldHavePOIFS) {
                hasPOIFS = true;
            } else {
                fail("Shouldn't have the POIFSContainerDetector from config");
            }
        }
    }
    if (shouldHavePOIFS)
        assertTrue("Should have the POIFSContainerDetector", hasPOIFS);
    if (shouldHaveZip)
        assertTrue("Should have the ZipContainerDetector", hasZip);
}
Also used : POIFSContainerDetector(org.apache.tika.parser.microsoft.POIFSContainerDetector) CompositeDetector(org.apache.tika.detect.CompositeDetector) EmptyDetector(org.apache.tika.detect.EmptyDetector) Detector(org.apache.tika.detect.Detector) ZipContainerDetector(org.apache.tika.parser.pkg.ZipContainerDetector) POIFSContainerDetector(org.apache.tika.parser.microsoft.POIFSContainerDetector) DefaultDetector(org.apache.tika.detect.DefaultDetector) ZipContainerDetector(org.apache.tika.parser.pkg.ZipContainerDetector)

Aggregations

POIFSContainerDetector (org.apache.tika.parser.microsoft.POIFSContainerDetector)2 ZipContainerDetector (org.apache.tika.parser.pkg.ZipContainerDetector)2 Response (javax.ws.rs.core.Response)1 CompositeDetector (org.apache.tika.detect.CompositeDetector)1 DefaultDetector (org.apache.tika.detect.DefaultDetector)1 Detector (org.apache.tika.detect.Detector)1 EmptyDetector (org.apache.tika.detect.EmptyDetector)1 MimeTypes (org.apache.tika.mime.MimeTypes)1 OggDetector (org.gagravarr.tika.OggDetector)1 Test (org.junit.Test)1