diff options
author | Nick Burch <nick@apache.org> | 2010-12-16 07:39:21 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2010-12-16 07:39:21 +0000 |
commit | 4c8a39924bab46769287b2602208be082abe23ce (patch) | |
tree | ea639436bfb263093f5547e377023cfc119048b6 /src/ooxml/testcases/org/apache/poi/extractor | |
parent | 12c173389f0cec05f7bc3ca5ad8920eeb4468bc1 (diff) | |
download | poi-4c8a39924bab46769287b2602208be082abe23ce.tar.gz poi-4c8a39924bab46769287b2602208be082abe23ce.zip |
Inside ExtractorFactory, support finding embedded OOXML documents and providing extractors for them
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1049802 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/extractor')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java b/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java index 4def3d3268..57574c6ab3 100644 --- a/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java +++ b/src/ooxml/testcases/org/apache/poi/extractor/TestExtractorFactory.java @@ -60,6 +60,7 @@ public class TestExtractorFactory extends TestCase { private File docx; private File dotx; private File docEmb; + private File docEmbOOXML; private File ppt; private File pptx; @@ -88,6 +89,7 @@ public class TestExtractorFactory extends TestCase { docx = wpTests.getFile("SampleDoc.docx"); dotx = wpTests.getFile("test.dotx"); docEmb = wpTests.getFile("word_with_embeded.doc"); + docEmbOOXML = wpTests.getFile("word_with_embeded_ooxml.doc"); POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); ppt = slTests.getFile("SampleShow.ppt"); @@ -536,7 +538,7 @@ public class TestExtractorFactory extends TestCase { embeds = ExtractorFactory.getEmbededDocsTextExtractors(ext); assertEquals(6, embeds.length); - int numWord = 0, numXls = 0, numPpt = 0, numMsg = 0; + int numWord = 0, numXls = 0, numPpt = 0, numMsg = 0, numWordX; for(int i=0; i<embeds.length; i++) { assertTrue(embeds[i].getText().length() > 20); @@ -569,6 +571,27 @@ public class TestExtractorFactory extends TestCase { assertEquals(1, numWord); assertEquals(0, numMsg); + // Word which contains an OOXML file + ext = (POIOLE2TextExtractor) + ExtractorFactory.createExtractor(docEmbOOXML); + embeds = ExtractorFactory.getEmbededDocsTextExtractors(ext); + + numWord = 0; numXls = 0; numPpt = 0; numMsg = 0; numWordX = 0; + assertEquals(3, embeds.length); + for(int i=0; i<embeds.length; i++) { + assertTrue(embeds[i].getText().length() > 20); + if(embeds[i] instanceof PowerPointExtractor) numPpt++; + else if(embeds[i] instanceof ExcelExtractor) numXls++; + else if(embeds[i] instanceof WordExtractor) numWord++; + else if(embeds[i] instanceof OutlookTextExtactor) numMsg++; + else if(embeds[i] instanceof XWPFWordExtractor) numWordX++; + } + assertEquals(1, numPpt); + assertEquals(1, numXls); + assertEquals(0, numWord); + assertEquals(1, numWordX); + assertEquals(0, numMsg); + // Outlook ext = (OutlookTextExtactor) ExtractorFactory.createExtractor(msgEmb); |