]> source.dussan.org Git - poi.git/commitdiff
Finish off ExtractorFactory tests
authorNick Burch <nick@apache.org>
Tue, 8 Apr 2008 12:39:39 +0000 (12:39 +0000)
committerNick Burch <nick@apache.org>
Tue, 8 Apr 2008 12:39:39 +0000 (12:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@645879 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/extractor/TestExtractorFactory.java

index e18b7e3989bb1640309a628e372171d3cd5afe89..762eb92ec7cb4760d1e1747770dbb600dd3cd73e 100644 (file)
@@ -31,6 +31,9 @@ import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
 
 import junit.framework.TestCase;
 
+import org.openxml4j.exceptions.InvalidOperationException;
+import org.openxml4j.opc.Package;
+
 /**
  * Test that the extractor factory plays nicely
  */
@@ -262,6 +265,39 @@ public class TestExtractorFactory extends TestCase {
        }
        
        public void testPackage() throws Exception {
+               // Excel
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(xlsx.toString()))
+                               instanceof XSSFExcelExtractor
+               );
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(xlsx.toString())).getText().length() > 200
+               );
+               
+               // Word
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(docx.toString()))
+                               instanceof XWPFWordExtractor
+               );
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(docx.toString())).getText().length() > 120
+               );
                
+               // PowerPoint
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(pptx.toString()))
+                               instanceof XSLFPowerPointExtractor
+               );
+               assertTrue(
+                               ExtractorFactory.createExtractor(Package.open(pptx.toString())).getText().length() > 120
+               );
+               
+               // Text
+               try {
+                       ExtractorFactory.createExtractor(Package.open(txt.toString()));
+                       fail();
+               } catch(InvalidOperationException e) {
+                       // Good
+               }
        }
 }