From 924e2eefd99b2c93d50c19db146253c85e04fe6d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Apr 2012 17:23:31 +0200 Subject: Fix IOUtil: Handle all '../' and './' cases by reducing the path. --- .../com/jogamp/common/net/URLCompositionTest.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/junit/com/jogamp/common/net/URLCompositionTest.java') 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 { -- cgit v1.2.3