aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/common/net/URLCompositionTest.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-02 17:23:31 +0200
committerSven Gothel <[email protected]>2012-04-02 17:23:31 +0200
commit924e2eefd99b2c93d50c19db146253c85e04fe6d (patch)
tree1cec506c776754bd2cfcc03f5691667a8f35d835 /src/junit/com/jogamp/common/net/URLCompositionTest.java
parent28814ae3946cf13619b70ddaf08c564f88252519 (diff)
Fix IOUtil: Handle all '../' and './' cases by reducing the path.
Diffstat (limited to 'src/junit/com/jogamp/common/net/URLCompositionTest.java')
-rw-r--r--src/junit/com/jogamp/common/net/URLCompositionTest.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/junit/com/jogamp/common/net/URLCompositionTest.java b/src/junit/com/jogamp/common/net/URLCompositionTest.java
index fb6d298..36b38ab 100644
--- a/src/junit/com/jogamp/common/net/URLCompositionTest.java
+++ b/src/junit/com/jogamp/common/net/URLCompositionTest.java
@@ -33,11 +33,19 @@ public class URLCompositionTest extends JunitTracer {
testURLCompositioning(new URL("jar:file:/web1/file1.jar!/rootDir/file1.txt"));
testURLCompositioning(new URL("asset:gluegen-test/info.txt"));
testURLCompositioning(new URL("asset:/gluegen-test/info.txt"));
- testURLCompositioning(new URL("asset:jar:file:/web1/file1.jar!/rootDir/file1.txt"));
testURLCompositioning(new URL("http://domain.com:1234/web1/index.html?lala=23&lili=24#anchor"));
+
+ final URL file1URL = new URL("asset:jar:file:/web1/file1.jar!/rootDir/file1.txt");
+ testURLCompositioning(file1URL);
+ testURLCompositioning(file1URL, new URL("asset:jar:file:/web1/file1.jar!/rootDir/./file1.txt"));
+ testURLCompositioning(file1URL, new URL("asset:jar:file:/web1/file1.jar!/rootDir/dummyParent/../file1.txt"));
+ }
+
+ static void testURLCompositioning(URL u) throws MalformedURLException {
+ testURLCompositioning(u, u);
}
- static void testURLCompositioning(URL u) throws MalformedURLException {
+ static void testURLCompositioning(URL refURL, URL u) throws MalformedURLException {
final String scheme = u.getProtocol();
final String auth = u.getAuthority();
String path = u.getPath();
@@ -47,12 +55,13 @@ public class URLCompositionTest extends JunitTracer {
System.err.println("scheme <"+scheme+">, auth <"+auth+">, path <"+path+">, query <"+query+">, fragment <"+fragment+">");
URL u2 = IOUtil.compose(scheme, auth, path, null, query, fragment);
- System.err.println("URL-equals: "+u.equals(u2));
- System.err.println("URL-same : "+u.sameFile(u2));
+ System.err.println("URL-equals: "+refURL.equals(u2));
+ System.err.println("URL-same : "+refURL.sameFile(u2));
+ System.err.println("URL-ref : <"+refURL+">");
System.err.println("URL-orig : <"+u+">");
System.err.println("URL-comp : <"+u2+">");
- Assert.assertEquals(u, u2);
- Assert.assertTrue(u.sameFile(u2));
+ Assert.assertEquals(refURL, u2);
+ Assert.assertTrue(refURL.sameFile(u2));
}
public static void main(String args[]) throws IOException {