aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/testcases/org/apache/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2019-07-19 20:49:48 +0000
committerPJ Fanning <fanningpj@apache.org>2019-07-19 20:49:48 +0000
commitea58359b7c4f4a4b9f26803a94d5aadd289f2bac (patch)
treea2ff276e381ab183e0a831a2961952901d88d875 /src/ooxml/testcases/org/apache/poi
parent10b5a462dcf52ea6e047cd0ccdb6a6dbce45123d (diff)
downloadpoi-ea58359b7c4f4a4b9f26803a94d5aadd289f2bac.tar.gz
poi-ea58359b7c4f4a4b9f26803a94d5aadd289f2bac.zip
[github-153] XWPFParagraph: easier way to create a link. Thanks to Thibaut Cuvelier. This closes #153
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1863433 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi')
-rw-r--r--src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
index 15611bcf4b..f68dd50a13 100644
--- a/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
+++ b/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
@@ -186,6 +186,18 @@ public final class TestXWPFDocument {
}
@Test
+ public void testAddHyperlink() throws IOException {
+ XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx");
+ XWPFParagraph p = doc.createParagraph();
+ XWPFHyperlinkRun h = p.createHyperlinkRun("http://poi.apache.org/");
+ h.setText("Apache POI");
+
+ assertEquals("http://poi.apache.org/", h.getHyperlink(doc).getURL());
+ assertEquals(p.getRuns().size(), 1);
+ assertEquals(p.getRuns().get(0), h);
+ }
+
+ @Test
public void testRemoveBodyElement() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("sample.docx");
assertEquals(3, doc.getParagraphs().size());