From: Yegor Kozlov Date: Thu, 3 Dec 2009 10:41:00 +0000 (+0000) Subject: added a test covering bookmarks X-Git-Tag: REL_3_6~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c4068ea0394e798601d3dd06bf89f7d1f112e27a;p=poi.git added a test covering bookmarks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886733 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java index 3c826ba255..73f66927fd 100644 --- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java @@ -18,24 +18,12 @@ package org.apache.poi.xwpf.usermodel; import java.math.BigInteger; +import java.io.File; import junit.framework.TestCase; import org.apache.poi.xwpf.XWPFTestDataSamples; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTextAlignment; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; /** * Tests for XWPF Paragraphs @@ -225,4 +213,14 @@ public final class TestXWPFParagraph extends TestCase { p.setPageBreak(true); assertEquals(STOnOff.TRUE, ppr.getPageBreakBefore().getVal()); } + + public void testBookmarks() { + XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx"); + XWPFParagraph paragraph = doc.getParagraphs()[0]; + assertEquals("Sample Word Document", paragraph.getText()); + assertEquals(1, paragraph.getCTP().sizeOfBookmarkStartArray()); + assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray()); + CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0); + assertEquals("poi", ctBookmark.getName()); + } } diff --git a/test-data/document/bookmarks.docx b/test-data/document/bookmarks.docx new file mode 100644 index 0000000000..b7816e70c2 Binary files /dev/null and b/test-data/document/bookmarks.docx differ