|
From: <lh...@us...> - 2009-03-27 10:32:50
|
Revision: 104
http://tmapi.svn.sourceforge.net/tmapi/?rev=104&view=rev
Author: lheuer
Date: 2009-03-27 10:32:43 +0000 (Fri, 27 Mar 2009)
Log Message:
-----------
Added more locator tests
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestLocator.java
Modified: trunk/src/test/java/org/tmapi/core/TestLocator.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestLocator.java 2009-03-18 21:45:46 UTC (rev 103)
+++ trunk/src/test/java/org/tmapi/core/TestLocator.java 2009-03-27 10:32:43 UTC (rev 104)
@@ -41,4 +41,74 @@
assertEquals(loc, loc3);
}
+ public void testIllegalLocatorAddresses() {
+ final String[] ILLEGAL = {"", "#fragment"};
+ for (String addr: ILLEGAL) {
+ try {
+ _tm.createLocator(addr);
+ fail("Expected an error TopicMap#createLocator() with the input '" + addr + "'");
+ }
+ catch (MalformedIRIException ex) {
+ // noop.
+ }
+ try {
+ _sys.createLocator(addr);
+ fail("Expected an error TopicMapSystem#createLocator() with the input '" + addr + "'");
+ }
+ catch (MalformedIRIException ex) {
+ // noop.
+ }
+ }
+ }
+
+ /**
+ * Tests the examples from RFC 3986 -- 5.4.1. Normal Examples.
+ */
+ public void test_RFC_3986__5_4_1_Normal_Examples() {
+ String[][] IRIS = new String[][] {
+ {"g:h", "g:h"},
+ {"g", "http://a/b/c/g"},
+ {"./g", "http://a/b/c/g"},
+ {"/g", "http://a/g"},
+ // Original: //g -> http://g
+ // Changed to avoid problems with trailing slash normailzations
+ {"//g/x", "http://g//x"},
+ {"?y", "http://a/b/c/d;p?y"},
+ {"g?y", "http://a/b/c/g?y"},
+ {"#s", "http://a/b/c/d;p?q#s"},
+ {"g#s", "http://a/b/c/g#s"},
+ {"g?y#s", "http://a/b/c/g?y#s"},
+ {";x", "http://a/b/c/;x"},
+ {"g;x", "http://a/b/c/g;x"},
+ {"g;x?y#s", "http://a/b/c/g;x?y#s"},
+ {"", "http://a/b/c/d;p?q"},
+ {".", "http://a/b/c/"},
+ {"./", "http://a/b/c/"},
+ {"..", "http://a/b/"},
+ {"../", "http://a/b/"},
+ {"../g", "http://a/b/g"},
+ {"../..", "http://a/"},
+ {"../../", "http://a/"},
+ {"../../g", "http://a/g"}
+ };
+ final String reference = "http://a/b/c/d;p?q";
+ final Locator base = _tm.createLocator(reference);
+ assertEquals(reference, base.toExternalForm());
+ for (int i=0; i<IRIS.length; i++) {
+ assertEquals("Unexpected result for " + IRIS[i][0],
+ IRIS[i][1], base.resolve(IRIS[i][0]).toExternalForm());
+ }
+ }
+
+ /**
+ * According to RFC 3986 an empty fragment / query has to be kept and
+ * must not be stripped away from the address.
+ */
+ public void testNormizationPreserveEmpty() {
+ String ref = "http://www.semagia.com/x?";
+ assertEquals("http://www.semagia.com/x?", _tm.createLocator(ref).toExternalForm());
+ ref = "http://www.semagia.com/x#";
+ assertEquals("http://www.semagia.com/x#", _tm.createLocator(ref).toExternalForm());
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|