Regression tests: Add test which triggers reading header/footer of PPTX files so that we include the related CT classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1835184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2018-07-05 19:54:24 +00:00
parent a4251b706b
commit 8e9ccfaacd
2 changed files with 21 additions and 6 deletions

View File

@ -33,6 +33,8 @@ import org.apache.poi.ooxml.extractor.ExtractorFactory;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.sl.extractor.SlideShowExtractor;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFShape;
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.xmlbeans.XmlException;
import org.junit.Test;
@ -48,7 +50,7 @@ public class TestXSLFPowerPointExtractor {
@Test
public void testGetSimpleText() throws IOException {
try (XMLSlideShow xmlA = openPPTX("sample.pptx");
SlideShowExtractor extractor = new SlideShowExtractor(xmlA)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xmlA)) {
extractor.getText();
@ -160,7 +162,7 @@ public class TestXSLFPowerPointExtractor {
@Test
public void testGetComments() throws IOException {
try (XMLSlideShow xml = openPPTX("45545_Comment.pptx");
SlideShowExtractor extractor = new SlideShowExtractor(xml)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml)) {
extractor.setCommentsByDefault(true);
String text = extractor.getText();
@ -178,7 +180,7 @@ public class TestXSLFPowerPointExtractor {
@Test
public void testGetMasterText() throws Exception {
try (XMLSlideShow xml = openPPTX("WithMaster.pptx");
SlideShowExtractor extractor = new SlideShowExtractor(xml)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml)) {
extractor.setSlidesByDefault(true);
extractor.setNotesByDefault(false);
extractor.setMasterByDefault(true);
@ -215,7 +217,7 @@ public class TestXSLFPowerPointExtractor {
@Test
public void testTable() throws Exception {
try (XMLSlideShow xml = openPPTX("present1.pptx");
SlideShowExtractor extractor = new SlideShowExtractor(xml)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml)) {
String text = extractor.getText();
assertTrue(text.length() > 0);
@ -240,7 +242,7 @@ public class TestXSLFPowerPointExtractor {
String filename = "testPPT." + extension;
try (XMLSlideShow xml = openPPTX(filename);
SlideShowExtractor extractor = new SlideShowExtractor(xml)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml)) {
String text = extractor.getText();
if (extension.equals("thmx")) {
@ -299,7 +301,7 @@ public class TestXSLFPowerPointExtractor {
@Test
public void bug54570() throws IOException {
try (XMLSlideShow xml = openPPTX("bug54570.pptx");
SlideShowExtractor extractor = new SlideShowExtractor(xml)) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml)) {
String text = extractor.getText();
assertNotNull(text);
}
@ -310,4 +312,17 @@ public class TestXSLFPowerPointExtractor {
return new XMLSlideShow(is);
}
}
@Test
public void setSlTests() throws IOException {
try (XMLSlideShow xml = openPPTX("aascu.org_hbcu_leadershipsummit_cooper_.pptx")) {
SlideShowExtractor<XSLFShape, XSLFTextParagraph> extractor = new SlideShowExtractor<>(xml);
assertNotNull(extractor);
extractor.setSlidesByDefault(true);
extractor.setNotesByDefault(true);
extractor.setMasterByDefault(true);
assertNotNull(extractor.getText());
}
}
}