]> source.dussan.org Git - poi.git/commitdiff
added a test covering bookmarks
authorYegor Kozlov <yegor@apache.org>
Thu, 3 Dec 2009 10:41:00 +0000 (10:41 +0000)
committerYegor Kozlov <yegor@apache.org>
Thu, 3 Dec 2009 10:41:00 +0000 (10:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886733 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFParagraph.java
test-data/document/bookmarks.docx [new file with mode: 0644]

index 3c826ba255d95bf1495c5546247c18095ac3329a..73f66927fd7b81889890d723fa114587212e7ce6 100644 (file)
 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 (file)
index 0000000..b7816e7
Binary files /dev/null and b/test-data/document/bookmarks.docx differ