From c4068ea0394e798601d3dd06bf89f7d1f112e27a Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Thu, 3 Dec 2009 10:41:00 +0000 Subject: [PATCH] added a test covering bookmarks git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886733 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xwpf/usermodel/TestXWPFParagraph.java | 26 ++++++++---------- test-data/document/bookmarks.docx | Bin 0 -> 10405 bytes 2 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 test-data/document/bookmarks.docx 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 0000000000000000000000000000000000000000..b7816e70c24bfed7c66b69c6294c7ca40404b057 GIT binary patch literal 10405 zcmeHtKIH7Tl$AZybWV2X{$GaCd?QcbDKAB)CI(J2`jWnaP=Z z?;mi^{;+%XuluRBcde>bPgN~tIj9#{02lxq001BdtUSKswSWKs$e;lLOaL6DuDFA} ztGT_ap}MD|xr;uFhn+21!3#*bJOCv4|Np)IgEdg6K5XC3hSsKaAS}_L8Id3M=@T5$ zJzs-#F{#lJ@|!EU>+|~udq@clL{Wwv40`R8k)xyDpvk2STX=ThiR>J!7ZVh1`;@(A zP28ZI-*`=MH@$INP@)}K_2lWjHQV9~X?(X<^%{N?k9EO8{x=B-q@60o=aUFU^L$&P z14`^re#?g|PTzZ7LEY(4tcyW#|oGUIkIF zv183FX34k^PazK)J(7v*^D9;zdQ;jIXvW7#_G%f+z!=_@G@Uye149c4cLNj+HFU(5 z4GTl|sf#3Xbk*vx8S9o0g+Ebl^oiX2W9xop@tWd~6{1q~=FcQO7-dxE*G4BR2z7Vs zmx7h3Il|~UiEr(5Pz^{1t&i6FH^3r~$P7jLMMR_#@MWH8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