aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit
diff options
context:
space:
mode:
Diffstat (limited to 'src/junit')
-rw-r--r--src/junit/com/jogamp/common/net/URLCompositionTest.java40
-rw-r--r--src/junit/com/jogamp/common/util/TestJarUtil.java16
-rw-r--r--src/junit/com/jogamp/common/util/TestTempJarCache.java2
3 files changed, 50 insertions, 8 deletions
diff --git a/src/junit/com/jogamp/common/net/URLCompositionTest.java b/src/junit/com/jogamp/common/net/URLCompositionTest.java
index 405e877..7ddd80c 100644
--- a/src/junit/com/jogamp/common/net/URLCompositionTest.java
+++ b/src/junit/com/jogamp/common/net/URLCompositionTest.java
@@ -83,8 +83,48 @@ public class URLCompositionTest extends JunitTracer {
System.err.println("3 fragment: "+uri.getRawFragment());
}
+
@Test
public void showURLComponents1() throws IOException, URISyntaxException {
+ testURI2URL("jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class",
+ "jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class");
+
+ testURI2URL("jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/",
+ "jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64 öä lala/gluegen-rt.jar!/");
+
+ testURI2URL("file:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar",
+ "file:/usr/local/projects/JOGL/gluegen/build-x86_64 öä lala/gluegen-rt.jar");
+
+ testURI2URL("jar:http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class",
+ "jar:http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class");
+
+ testURI2URL("jar:http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/",
+ "jar:http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/");
+
+ testURI2URL("http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar",
+ "http:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar");
+
+ testURI2URL("jar:ftp:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class",
+ "jar:ftp:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar!/com/jogamp/common/os/Platform.class");
+
+ testURI2URL("ftp:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar",
+ "ftp:/usr/local/projects/JOGL/gluegen/build-x86_64%20%c3%b6%c3%a4%20lala/gluegen-rt.jar");
+ }
+
+ void testURI2URL(String source, String expected) throws IOException, URISyntaxException {
+ System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+ final URI uri0 = new URI(source);
+ System.err.println("uri: "+uri0.toString());
+
+ final URL url0 = IOUtil.toURL(uri0);
+ final String actual = url0.toExternalForm();
+ System.err.println("url: "+actual);
+ Assert.assertEquals(expected, actual);
+ System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+ }
+
+ @Test
+ public void showURLComponents2() throws IOException, URISyntaxException {
testURNCompositioning("file:///rootDir/file1.txt");
testURNCompositioning("file://host/rootDir/file1.txt");
testURNCompositioning("jar:file:/web1/file1.jar!/rootDir/file1.txt");
diff --git a/src/junit/com/jogamp/common/util/TestJarUtil.java b/src/junit/com/jogamp/common/util/TestJarUtil.java
index ab78556..fa45853 100644
--- a/src/junit/com/jogamp/common/util/TestJarUtil.java
+++ b/src/junit/com/jogamp/common/util/TestJarUtil.java
@@ -94,10 +94,11 @@ public class TestJarUtil extends JunitTracer {
}
}
- void validateJarFileURL(URI jarFileURI) throws IllegalArgumentException, IOException {
- Assert.assertNotNull(jarFileURI);
- URLConnection aURLc = jarFileURI.toURL().openConnection();
- Assert.assertTrue("jarFileURI/URL has zero content: "+jarFileURI, aURLc.getContentLength()>0);
+ void validateJarFileURL(URI jarFileURI) throws IllegalArgumentException, IOException, URISyntaxException {
+ Assert.assertNotNull(jarFileURI);
+ final URL jarFileURL = IOUtil.toURL(jarFileURI);
+ URLConnection aURLc = jarFileURL.openConnection();
+ Assert.assertTrue("jarFileURI/URL has zero content: "+jarFileURL, aURLc.getContentLength()>0);
System.err.println("URLConnection: "+aURLc);
Assert.assertTrue("Not a JarURLConnection: "+aURLc, (aURLc instanceof JarURLConnection) );
JarURLConnection jURLc = (JarURLConnection) aURLc;
@@ -110,9 +111,10 @@ public class TestJarUtil extends JunitTracer {
Assert.assertNotNull(jarName);
Assert.assertEquals(expJarName, jarName);
- URI jarSubURL = JarUtil.getJarSubURI(clazzBinName, cl);
- Assert.assertNotNull(jarSubURL);
- URLConnection urlConn = jarSubURL.toURL().openConnection();
+ URI jarSubURI = JarUtil.getJarSubURI(clazzBinName, cl);
+ Assert.assertNotNull(jarSubURI);
+ final URL jarSubURL= IOUtil.toURL(jarSubURI);
+ URLConnection urlConn = jarSubURL.openConnection();
Assert.assertTrue("jarSubURL has zero content: "+jarSubURL, urlConn.getContentLength()>0);
System.err.println("URLConnection of jarSubURL: "+urlConn);
diff --git a/src/junit/com/jogamp/common/util/TestTempJarCache.java b/src/junit/com/jogamp/common/util/TestTempJarCache.java
index 7edb286..62a916a 100644
--- a/src/junit/com/jogamp/common/util/TestTempJarCache.java
+++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java
@@ -199,7 +199,7 @@ public class TestTempJarCache extends JunitTracer {
final ClassLoader cl = getClass().getClassLoader();
URI jarUriRoot = JarUtil.getJarSubURI(TempJarCache.class.getName(), cl);
- jarUriRoot = JarUtil.getURIDirname(jarUriRoot);
+ jarUriRoot = IOUtil.getDirname(jarUriRoot);
URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName);