3import java.io.IOException;
4import java.net.URISyntaxException;
6import java.net.URLConnection;
8import org.jau.io.IOUtil;
9import org.jau.net.AssetURLContext;
10import org.jau.net.Uri;
11import org.junit.Assert;
12import org.junit.BeforeClass;
13import org.junit.FixMethodOrder;
15import org.junit.runners.MethodSorters;
17@FixMethodOrder(MethodSorters.NAME_ASCENDING)
23 System.err.println(
"******* Asset URL Stream Handler Registration: PRE");
24 Assert.assertTrue(
"GenericURLStreamHandlerFactory.register() failed", AssetURLContext.registerHandler(
TestAssetURLConnectionRegistered.class.getClassLoader()));
25 Assert.assertNotNull(AssetURLContext.getRegisteredHandler());
26 System.err.println(
"******* Asset URL Stream Handler Registration: POST");
27 }
catch (
final Exception e) {
28 setTestSupported(
false);
35 testAssetConnection(createAssetURLConnection(test_asset_rt_url), test_asset_rt_entry);
40 testAssetConnection(createAssetURLConnection(test_asset_test1_url), test_asset_test1_entry);
45 final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2a_url, this.getClass().getClassLoader());
46 Assert.assertNotNull(urlConn0);
47 Assert.assertEquals(test_asset_test2a_url, urlConn0.getURL().toExternalForm());
48 testAssetConnection(urlConn0, test_asset_test2_entry);
50 final Uri uri1 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test3_rel);
51 Assert.assertNotNull(uri1);
52 Assert.assertEquals(test_asset_test3a_url, uri1.toString());
53 testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry);
55 final Uri uri2 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test4_rel);
56 Assert.assertNotNull(uri2);
57 Assert.assertEquals(test_asset_test4a_url, uri2.toString());
58 testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry);
63 final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2b_url, this.getClass().getClassLoader());
64 Assert.assertNotNull(urlConn0);
65 Assert.assertEquals(test_asset_test2b_url, urlConn0.getURL().toExternalForm());
66 testAssetConnection(urlConn0, test_asset_test2_entry);
68 final Uri uri1 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test3_rel);
69 Assert.assertNotNull(uri1);
70 Assert.assertEquals(test_asset_test3b_url, uri1.toString());
71 testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry);
73 final Uri uri2 = Uri.valueOf(urlConn0.getURL()).getRelativeOf(test_asset_test4_rel);
74 Assert.assertNotNull(uri2);
75 Assert.assertEquals(test_asset_test4b_url, uri2.toString());
76 testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry);
79 URLConnection createAssetURLConnection(
final String path)
throws IOException {
80 final URL url = AssetURLContext.createURL(path);
81 final URLConnection c = url.openConnection();
82 System.err.println(
"createAssetURL: "+path+
" -> url: "+url+
" -> conn: "+c+
" / connURL "+(
null!=c?c.getURL():
null));
87 public static void main(
final String args[])
throws IOException {
89 org.junit.runner.JUnitCore.
main(tstname);
void assetRegisteredURLConnection_RT()
void assetRegisteredIOUtilGetResourceRel2_RT()
static void main(final String args[])
void assetRegisteredURLConnection_Test()
void assetRegisteredIOUtilGetResourceRel1_RT()
static void assetRegistration()