Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestAssetURLConnectionUnregistered.java
Go to the documentation of this file.
1package jau.test.net;
2
3import java.io.IOException;
4import java.net.URISyntaxException;
5import java.net.URL;
6import java.net.URLConnection;
7
8import org.jau.io.IOUtil;
9import org.jau.net.AssetURLContext;
10import org.jau.net.Uri;
11import org.junit.Assert;
12import org.junit.FixMethodOrder;
13import org.junit.Test;
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}
static URLConnection createAssetURLConnection(final String path, final ClassLoader cl)