diff options
author | Sven Gothel <[email protected]> | 2013-06-19 04:44:14 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-19 04:44:14 +0200 |
commit | 4376174ad35fdaf76f59430328582e913f468674 (patch) | |
tree | eb1faa41eb440b1fec0c5f9932007050e5bd7e8b /src/junit/com/jogamp/common/net/URLCompositionTest.java | |
parent | 88dca02541d96f68a892ae7824e9e1b29793ae55 (diff) |
Fix Bug 757: Regression of URL to URI conversion (Encoded path not compatible w/ file scheme.
Regression of (Bug 683, Commit b98825eb7cfb61aead4a7dff57471cd2d2c26823).
The URI encoded path cannot be read by File I/O (if file scheme), since the latter
requests an UTF8/16 name, not an URI encoded name (i.e. %20 for space).
The encoded URL is produced if calling 'uri.toURL()' and hence
the new 'IOUtil.toURL(URI)' provides a custom conversion recovering the UTF name via 'new File(uri).getPath()'.
Tested w/
- synthetic URI/URL coposition (unit test)
- manual w/ moving 'build' to 'build öä lala' for gluegen, joal and jogl.
+++
Misc.:
- 'URI JarUtil.getURIDirname(URI)' -> 'URI IOUtil.getDirname(URI)'
++
Diffstat (limited to 'src/junit/com/jogamp/common/net/URLCompositionTest.java')
-rw-r--r-- | src/junit/com/jogamp/common/net/URLCompositionTest.java | 40 |
1 files changed, 40 insertions, 0 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"); |