diff options
author | Yegor Kozlov <yegor@apache.org> | 2012-02-02 10:37:49 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2012-02-02 10:37:49 +0000 |
commit | 4b1b2f4af28b21b5e7992e6f02f20d2c1542c60d (patch) | |
tree | 841136a9633c2df61b14f5a63d43e508a59a01ed /src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java | |
parent | 3ab1ff03047cdc5a2f39adf03189fe8a3904415f (diff) | |
download | poi-4b1b2f4af28b21b5e7992e6f02f20d2c1542c60d.tar.gz poi-4b1b2f4af28b21b5e7992e6f02f20d2c1542c60d.zip |
validate hyperlink address as discussed on poi-user
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1239529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java')
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java index 6e226e331b..49f79365f3 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java @@ -50,6 +50,35 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { doTestHyperlinkContents(sheet); } + public void testCreate() { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFCreationHelper createHelper = workbook.getCreationHelper(); + + String[] validURLs = { + "http://apache.org", + "www.apache.org", + "/temp", + "c:/temp", + "http://apache.org/default.php?s=isTramsformed&submit=Search&la=*&li=*"}; + for(String s : validURLs){ + createHelper.createHyperlink(Hyperlink.LINK_URL).setAddress(s); + } + + String[] invalidURLs = { + "http:\\apache.org", + "www.apache .org", + "c:\\temp", + "\\poi"}; + for(String s : invalidURLs){ + try { + createHelper.createHyperlink(Hyperlink.LINK_URL).setAddress(s); + fail("expected IllegalArgumentException: " + s); + } catch (IllegalArgumentException e){ + + } + } + } + public void testLoadSave() { XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("WithMoreVariousData.xlsx"); CreationHelper createHelper = workbook.getCreationHelper(); |