From 5f7a1597e4007b14359b1aba511ecaf240780a9b Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 20 Jun 2013 12:51:30 +0000 Subject: [PATCH] Patch from Tim Allen from bug #55066 - unit test to show that we no longer load XWPF footnotes twice git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1494962 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/TestXWPFFootnotes.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java index 05e4afde85..fb97bf594e 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFFootnotes.java @@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel; import java.io.IOException; import java.math.BigInteger; +import java.util.List; import junit.framework.TestCase; @@ -45,5 +46,25 @@ public class TestXWPFFootnotes extends TestCase { XWPFFootnote note = docIn.getFootnoteByID(noteId.intValue()); assertEquals(note.getCTFtnEdn().getType(), STFtnEdn.NORMAL); } + + /** + * Bug 55066 - avoid double loading the footnotes + */ + public void testLoadFootnotesOnce() throws IOException{ + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("Bug54849.docx"); + List footnotes = doc.getFootnotes(); + int hits = 0; + for (XWPFFootnote fn : footnotes){ + for (IBodyElement e : fn.getBodyElements()){ + if (e instanceof XWPFParagraph){ + String txt = ((XWPFParagraph)e).getText(); + if (txt.indexOf("Footnote_sdt") > -1){ + hits++; + } + } + } + } + assertEquals("Load footnotes once", 1, hits); + } } -- 2.39.5