GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
TestAssetURLConnectionUnregistered.java
Go to the documentation of this file.
1package com.jogamp.common.net;
2
3import java.io.IOException;
4import java.net.URISyntaxException;
5import java.net.URL;
6import java.net.URLConnection;
7
8import org.junit.Assert;
9import org.junit.Test;
10
11import com.jogamp.common.util.IOUtil;
12
13import org.junit.FixMethodOrder;
14import org.junit.runners.MethodSorters;
15
16@FixMethodOrder(MethodSorters.NAME_ASCENDING)
18 @Test
19 public void assetUnregisteredURLConnection_RT2() throws IOException {
20 testAssetConnection(createAssetURLConnection(test_asset_rt2_url, this.getClass().getClassLoader()), test_asset_rt_entry);
21 }
22
23 @Test
24 public void assetUnregisteredURLConnection_RT() throws IOException {
25 testAssetConnection(createAssetURLConnection(test_asset_rt_url, this.getClass().getClassLoader()), test_asset_rt_entry);
26 }
27
28 @Test
29 public void assetUnregisteredURLConnection_Test() throws IOException {
30 testAssetConnection(createAssetURLConnection(test_asset_test1_url, this.getClass().getClassLoader()), test_asset_test1_entry);
31 }
32
33 @Test
34 public void assetUnregisteredIOUtilGetResourceAbs_RT() throws IOException {
35 final URLConnection c = IOUtil.getResource(test_asset_rt_entry, this.getClass().getClassLoader());
36 testAssetConnection(c, test_asset_rt_entry);
37 }
38
39 @Test
40 public void assetUnregisteredIOUtilGetResourceRel0_RT() throws IOException, URISyntaxException {
41 final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2_rel.get(), this.getClass().getClassLoader(), this.getClass());
42 testAssetConnection(urlConn0, test_asset_test2_entry);
43
44 final Uri uri1 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test3_rel);
45 Assert.assertNotNull(uri1); // JARFile URL ..
46 testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry);
47
48 final Uri uri2 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test4_rel);
49 Assert.assertNotNull(uri2);
50 testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry);
51 }
52
53 protected static URLConnection createAssetURLConnection(final String path, final ClassLoader cl) throws IOException {
54 final URL url = AssetURLContext.createURL(path, cl);
55 final URLConnection c = url.openConnection();
56 System.err.println("createAssetURL: "+path+" -> url: "+url+" -> conn: "+c+" / connURL "+(null!=c?c.getURL():null));
57 return c;
58 }
59
60 public static void main(final String args[]) throws IOException {
61 final String tstname = TestAssetURLConnectionUnregistered.class.getName();
62 org.junit.runner.JUnitCore.main(tstname);
63 }
64}
See PiggybackURLConnection for description and examples.
static URL createURL(final String path, final ClassLoader cl)
Create an asset URL, suitable even w/o the registered asset URLStreamHandler.
static URLConnection createAssetURLConnection(final String path, final ClassLoader cl)
This class implements an immutable Uri as defined by RFC 2396.
Definition: Uri.java:160
static Uri valueOf(final File file)
Creates a new Uri instance using the given File instance.
Definition: Uri.java:1121
Uri getRelativeOf(final Encoded appendPath)
Returns a new Uri appending the given appendPath to this instance's directory.
Definition: Uri.java:1709
final java.net.URL toURL()
Returns a new URL instance using the encoded input string, new URL(uri.input), i.e.
Definition: Uri.java:1369
static URLConnection getResource(final String resourcePath, final ClassLoader classLoader, final Class<?> relContext)
Locating a resource using getResource(String, ClassLoader):
Definition: IOUtil.java:578