comments = XWPFTestDataSamples.openSampleDocument("WordWithAttachments.docx");
}
@SuppressWarnings("deprecation")
public void testHyperlink() {
XWPFParagraph ps;
XWPFParagraph ph;
assertEquals(7, simple.getParagraphs().size());
assertEquals(5, hyperlink.getParagraphs().size());
// Simple text
ps = simple.getParagraphs().get(0);
assertEquals("I am a test document", ps.getParagraphText());
assertEquals(1, ps.getRuns().size());
ph = hyperlink.getParagraphs().get(4);
assertEquals("We have a hyperlink here, and another.", ph.getParagraphText());
assertEquals(3, ph.getRuns().size());
// The proper way to do hyperlinks(!)
assertFalse(ps.getRuns().get(0) instanceof XWPFHyperlinkRun);
assertFalse(ph.getRuns().get(0) instanceof XWPFHyperlinkRun);
assertTrue(ph.getRuns().get(1) instanceof XWPFHyperlinkRun);
assertFalse(ph.getRuns().get(2) instanceof XWPFHyperlinkRun);
XWPFHyperlinkRun link = (XWPFHyperlinkRun)ph.getRuns().get(1);
assertEquals("http://poi.apache.org/", link.getHyperlink(hyperlink).getURL());
// Test the old style decorator
// You probably don't want to still be using it...