XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx");
XWPFParagraph paragraph = doc.getParagraphs().get(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());
for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) {
assertEquals("poi", bookmark.getName());
}
}