From fde6f81305eb7d8895916f998a25d4be03109b72 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 14 Apr 2020 12:53:17 +0000 Subject: [PATCH] [bug-64348] partial fix for IndexOutOfBoundsException git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876512 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/TestXWPFHeader.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java index d76309ae99..29fa8ba142 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFHeader.java @@ -25,6 +25,7 @@ import java.io.IOException; import org.apache.poi.xwpf.XWPFTestDataSamples; import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy; +import org.junit.Ignore; import org.junit.Test; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; @@ -205,21 +206,50 @@ public final class TestXWPFHeader { } } + public void testSetWatermarkOnEmptyDoc() throws IOException { + try (XWPFDocument sampleDoc = new XWPFDocument()) { + + // No header is set (yet) + XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy(); + assertNull(policy.getDefaultHeader()); + assertNull(policy.getFirstPageHeader()); + assertNull(policy.getDefaultFooter()); + + policy.createWatermark("DRAFT"); + + assertNotNull(policy.getDefaultHeader()); + assertNotNull(policy.getFirstPageHeader()); + assertNotNull(policy.getEvenPageHeader()); + + // Re-open, and check + XWPFDocument reopened = XWPFTestDataSamples.writeOutAndReadBack(sampleDoc); + policy = reopened.getHeaderFooterPolicy(); + + assertNotNull(policy.getDefaultHeader()); + assertNotNull(policy.getFirstPageHeader()); + assertNotNull(policy.getEvenPageHeader()); + } + } + + @Ignore @Test public void testAddPictureData() { // TODO } + @Ignore @Test public void testGetAllPictures() { // TODO } + @Ignore @Test public void testGetAllPackagePictures() { // TODO } + @Ignore @Test public void testGetPictureDataById() { // TODO -- 2.39.5