Package org.apache.tika.extractor

Examples of org.apache.tika.extractor.ParserContainerExtractor$RecursiveParser


     * Office files with embedded images, but no other
     *  office files in them
     */
    @Test
    public void testEmbeddedImages() throws Exception {
       ContainerExtractor extractor = new ParserContainerExtractor();
       TrackingHandler handler;
      
       // Excel with 1 image
       handler = process("testEXCEL_1img.xls", extractor, false);
       assertEquals(1, handler.filenames.size());
View Full Code Here


     *       -> excel
     *           -> image
     */
    @Test
    public void testEmbeddedOfficeFiles() throws Exception {
       ContainerExtractor extractor = new ParserContainerExtractor();
       TrackingHandler handler;
      
      
       // Excel with a word doc and a powerpoint doc, both of which have images in them
       // Without recursion, should see both documents + the images
View Full Code Here

       assertEquals(TYPE_PDF, handler.mediaTypes.get(1));
    }

    @Test
    public void testEmbeddedOfficeFilesXML() throws Exception {
        ContainerExtractor extractor = new ParserContainerExtractor();
        TrackingHandler handler;

        handler = process("EmbeddedDocument.docx", extractor, false);
        assertTrue(handler.filenames.contains("Microsoft_Office_Excel_97-2003_Worksheet1.bin"));
        assertEquals(2, handler.filenames.size());
View Full Code Here

        assertEquals(2, handler.filenames.size());
    }

    @Test
    public void testPowerpointImages() throws Exception {
        ContainerExtractor extractor = new ParserContainerExtractor();
        TrackingHandler handler;

        handler = process("pictures.ppt", extractor, false);
        assertTrue(handler.mediaTypes.contains(new MediaType("image", "jpeg")));
        assertTrue(handler.mediaTypes.contains(new MediaType("image", "png")));
View Full Code Here

       assertTrue(needle > -1);
       assertTrue(needle > pdfHaystack && pdfHaystack > outerHaystack);
      
       TrackingHandler tracker = new TrackingHandler();
       TikaInputStream tis;
       ContainerExtractor ex = new ParserContainerExtractor();
       try{
          tis= TikaInputStream.get(getResourceAsStream("/test-documents/testPDFEmbeddingAndEmbedded.docx"));
          ex.extract(tis, ex, tracker);
       } finally {
          stream.close();
       }
       assertEquals(true, ex.isSupported(tis));
       assertEquals(3, tracker.filenames.size());
       assertEquals(3, tracker.mediaTypes.size());
       assertEquals("image1.emf", tracker.filenames.get(0));
       assertNull(tracker.filenames.get(1));
       assertEquals("Test.docx", tracker.filenames.get(2));
View Full Code Here

    @Test
    public void testBinControlWord() throws Exception {
        ByteCopyingHandler embHandler = new ByteCopyingHandler();
        TikaInputStream tis = null;
        try {
            ContainerExtractor ex = new ParserContainerExtractor();
            tis = TikaInputStream.get(getResourceAsStream("/test-documents/testBinControlWord.rtf"));
            assertEquals(true, ex.isSupported(tis));
            ex.extract(tis, ex, embHandler);           
        } finally {
            tis.close();
        }
        assertEquals(1, embHandler.bytes.size());
       
View Full Code Here

        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());
View Full Code Here

        skipTypes.add(MediaType.parse("application/x-msmetafile"));

        TrackingHandler tracker = new TrackingHandler(skipTypes);
        TikaInputStream tis = null;
        try {
            ContainerExtractor ex = new ParserContainerExtractor();
            tis = TikaInputStream.get(getResourceAsStream("/test-documents/testRTFEmbeddedLink.rtf"));
            assertEquals(true, ex.isSupported(tis));
            ex.extract(tis, ex, tracker);

        } finally {
            tis.close();
        }
        //should gracefully skip link and not throw NPE, IOEx, etc
        assertEquals(0, tracker.filenames.size());

        tracker = new TrackingHandler();
        tis = null;
        try {
            ContainerExtractor ex = new ParserContainerExtractor();
            tis = TikaInputStream.get(getResourceAsStream("/test-documents/testRTFEmbeddedLink.rtf"));
            assertEquals(true, ex.isSupported(tis));
            ex.extract(tis, ex, tracker);
        } finally {
            tis.close();
        }
        //should gracefully skip link and not throw NPE, IOEx, etc
        assertEquals(2, tracker.filenames.size());
View Full Code Here

  
    /**
     * For office files which don't have anything embedded in them
     */
    public void testWithoutEmbedded() throws Exception {
       ContainerExtractor extractor = new ParserContainerExtractor();
      
       String[] files = new String[] {
             "testEXCEL.xls", "testWORD.doc", "testPPT.ppt",
             "testVISIO.vsd", "test-outlook.msg"
       };
View Full Code Here

    /**
     * Office files with embedded images, but no other
     *  office files in them
     */
    public void testEmbeddedImages() throws Exception {
       ContainerExtractor extractor = new ParserContainerExtractor();
       TrackingHandler handler;
      
       // Excel with 1 image
       handler = process("testEXCEL_1img.xls", extractor, false);
       assertEquals(1, handler.filenames.size());
View Full Code Here

TOP

Related Classes of org.apache.tika.extractor.ParserContainerExtractor$RecursiveParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.