diff options
Diffstat (limited to 'src/junit/com/jogamp/common')
4 files changed, 33 insertions, 6 deletions
diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java b/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java index 80f9bd4..cb3fe14 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java @@ -31,6 +31,10 @@ public abstract class AssetURLConnectionBase extends JunitTracer { protected static final String test_asset_test3a_url = "asset:com/jogamp/common/net/data/RelativeData.txt"; protected static final String test_asset_test3b_url = "asset:/com/jogamp/common/net/data/RelativeData.txt"; protected static final String test_asset_test3_entry = "com/jogamp/common/net/data/RelativeData.txt"; + protected static final String test_asset_test4_rel = "../data2/RelativeData2.txt"; + protected static final String test_asset_test4a_url = "asset:com/jogamp/common/net/data2/RelativeData2.txt"; + protected static final String test_asset_test4b_url = "asset:/com/jogamp/common/net/data2/RelativeData2.txt"; + protected static final String test_asset_test4_entry = "com/jogamp/common/net/data2/RelativeData2.txt"; protected static void testAssetConnection(URLConnection c, String entry_name) throws IOException { Assert.assertNotNull(c); diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java b/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java index 7b8d1a4..edf1592 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java @@ -46,6 +46,11 @@ public class AssetURLConnectionRegisteredTest extends AssetURLConnectionBase { Assert.assertNotNull(url1); Assert.assertEquals(test_asset_test3a_url, url1.toExternalForm()); testAssetConnection(url1.openConnection(), test_asset_test3_entry); + + final URL url2 = IOUtil.getRelativeOf(urlConn0.getURL(), test_asset_test4_rel); + Assert.assertNotNull(url1); + Assert.assertEquals(test_asset_test4a_url, url2.toExternalForm()); + testAssetConnection(url2.openConnection(), test_asset_test4_entry); } @Test @@ -59,6 +64,11 @@ public class AssetURLConnectionRegisteredTest extends AssetURLConnectionBase { Assert.assertNotNull(url1); Assert.assertEquals(test_asset_test3b_url, url1.toExternalForm()); testAssetConnection(url1.openConnection(), test_asset_test3_entry); + + final URL url2 = IOUtil.getRelativeOf(urlConn0.getURL(), test_asset_test4_rel); + Assert.assertNotNull(url1); + Assert.assertEquals(test_asset_test4b_url, url2.toExternalForm()); + testAssetConnection(url2.openConnection(), test_asset_test4_entry); } URLConnection createAssetURLConnection(String path) throws IOException { diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java index 6db8c17..cf26da4 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java @@ -39,6 +39,10 @@ public class AssetURLConnectionUnregisteredTest extends AssetURLConnectionBase { final URL url1 = IOUtil.getRelativeOf(urlConn0.getURL(), test_asset_test3_rel); Assert.assertNotNull(url1); // JARFile URL .. testAssetConnection(url1.openConnection(), test_asset_test3_entry); + + final URL url2 = IOUtil.getRelativeOf(urlConn0.getURL(), test_asset_test4_rel); + Assert.assertNotNull(url1); + testAssetConnection(url2.openConnection(), test_asset_test4_entry); } protected static URLConnection createAssetURLConnection(String path, ClassLoader cl) throws IOException { 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 { |