diff options
author | Dominik Stadler <centic@apache.org> | 2015-09-29 06:08:08 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2015-09-29 06:08:08 +0000 |
commit | 8e02c19b15606b9a0d27a5278ac044361b497872 (patch) | |
tree | a91007f9963fe67d0f11009522b4aa24aa44504f /src | |
parent | 079d946894f90bbb158f2f35a763357237715271 (diff) | |
download | poi-8e02c19b15606b9a0d27a5278ac044361b497872.tar.gz poi-8e02c19b15606b9a0d27a5278ac044361b497872.zip |
Verify that bug 45541 can be resolved, add some more checks in XSLFFileHandler
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1705804 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java | 25 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java | 37 |
2 files changed, 59 insertions, 3 deletions
diff --git a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java index e65c1225c0..9278f32f3e 100644 --- a/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSLFFileHandler.java @@ -16,13 +16,16 @@ ==================================================================== */ package org.apache.poi.stress; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import org.apache.poi.extractor.ExtractorFactory; import org.apache.poi.xslf.XSLFSlideShow; +import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.junit.Test; @@ -43,7 +46,25 @@ public class XSLFFileHandler extends SlideShowHandler { slide.close(); } - // a test-case to test this locally without executing the full TestAllFiles + public void handleExtracting(File file) throws Exception { + super.handleExtracting(file); + + + // additionally try the other getText() methods + + XSLFPowerPointExtractor extractor = (XSLFPowerPointExtractor) ExtractorFactory.createExtractor(file); + try { + assertNotNull(extractor); + + assertNotNull(extractor.getText(true, true, true)); + assertEquals("With all options disabled we should not get text", + "", extractor.getText(false, false, false)); + } finally { + extractor.close(); + } + } + + // a test-case to test this locally without executing the full TestAllFiles @Test public void test() throws Exception { InputStream stream = new FileInputStream("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx"); @@ -58,5 +79,5 @@ public class XSLFFileHandler extends SlideShowHandler { @Test public void testExtractor() throws Exception { handleExtracting(new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx")); - } + } }
\ No newline at end of file diff --git a/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java b/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java index 35ee3f1cb4..5b61979570 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/extractor/TestXSLFPowerPointExtractor.java @@ -16,11 +16,14 @@ ==================================================================== */ package org.apache.poi.xslf.extractor; -import junit.framework.TestCase; import org.apache.poi.POIDataSamples; +import org.apache.poi.POITextExtractor; +import org.apache.poi.extractor.ExtractorFactory; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.xslf.XSLFSlideShow; +import junit.framework.TestCase; + /** * Tests for HXFPowerPointExtractor */ @@ -279,4 +282,36 @@ public class TestXSLFPowerPointExtractor extends TestCase { extractor.close(); } } + + public void test45541() throws Exception { + // extract text from a powerpoint that has a header in the notes-element + POITextExtractor extr = ExtractorFactory.createExtractor(slTests + .openResourceAsStream("45541_Header.pptx")); + String text = extr.getText(); + assertNotNull(text); + assertFalse("Had: " + text, text.contains("testdoc")); + + text = ((XSLFPowerPointExtractor)extr).getText(false, true); + assertNotNull(text); + assertTrue("Had: " + text, text.contains("testdoc")); + extr.close(); + assertNotNull(text); + + // extract text from a powerpoint that has a footer in the master-slide + extr = ExtractorFactory.createExtractor(slTests + .openResourceAsStream("45541_Footer.pptx")); + text = extr.getText(); + assertNotNull(text); + assertFalse("Had " + text, text.contains("testdoc")); + + text = ((XSLFPowerPointExtractor)extr).getText(false, true); + assertNotNull(text); + assertFalse("Had: " + text, text.contains("testdoc")); + + text = ((XSLFPowerPointExtractor)extr).getText(false, false, true); + assertNotNull(text); + assertFalse("Had: " + text, text.contains("testdoc")); + + extr.close(); + } } |