Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
AssetURLConnectionBase.java
Go to the documentation of this file.
1package jau.test.net;
2
3import java.io.BufferedReader;
4import java.io.IOException;
5import java.io.InputStreamReader;
6import java.net.JarURLConnection;
7import java.net.URLConnection;
8
9import org.jau.io.IOUtil;
10import org.jau.net.AssetURLConnection;
11import org.jau.net.Uri;
12import org.jau.sys.AndroidVersion;
13import org.junit.Assert;
14
15import jau.test.junit.util.JunitTracer;
16
17public abstract class AssetURLConnectionBase extends JunitTracer {
18
19 /** In jaulib_base.jar */
20 protected static final String test_asset_rt_url = "asset:jau/info.txt";
21 protected static final String test_asset_rt_entry = "jau/info.txt";
22
23 protected static final String test_asset_rt2_url = "asset:/jau/info.txt";
24
25 /** In gluegen.test.jar */
26 protected static final String test_asset_test1_url = "asset:jau-test/info.txt";
27 protected static final String test_asset_test1_entry = "jau-test/info.txt";
28 protected static final Uri.Encoded test_asset_test2_rel = Uri.Encoded.cast("data/AssetURLConnectionTest.txt");
29 protected static final String test_asset_test2a_url = "asset:jau/test/net/data/AssetURLConnectionTest.txt";
30 protected static final String test_asset_test2b_url = "asset:/jau/test/net/data/AssetURLConnectionTest.txt";
31 protected static final String test_asset_test2_entry = "jau/test/net/data/AssetURLConnectionTest.txt";
32 protected static final Uri.Encoded test_asset_test3_rel = Uri.Encoded.cast("RelativeData.txt");
33 protected static final String test_asset_test3a_url = "asset:jau/test/net/data/RelativeData.txt";
34 protected static final String test_asset_test3b_url = "asset:/jau/test/net/data/RelativeData.txt";
35 protected static final String test_asset_test3_entry = "jau/test/net/data/RelativeData.txt";
36 protected static final Uri.Encoded test_asset_test4_rel = Uri.Encoded.cast("../data2/RelativeData2.txt");
37 protected static final String test_asset_test4a_url = "asset:jau/test/net/data2/RelativeData2.txt";
38 protected static final String test_asset_test4b_url = "asset:/jau/test/net/data2/RelativeData2.txt";
39 protected static final String test_asset_test4_entry = "jau/test/net/data2/RelativeData2.txt";
40
41 protected static void testAssetConnection(final URLConnection c, final String entry_name) throws IOException {
42 Assert.assertNotNull(c);
43 if(c instanceof AssetURLConnection) {
44 final AssetURLConnection ac = (AssetURLConnection) c;
45 Assert.assertEquals(entry_name, ac.getEntryName());
46 } else if(c instanceof JarURLConnection) {
47 final JarURLConnection jc = (JarURLConnection) c;
48 if(AndroidVersion.isAvailable) {
49 Assert.assertEquals("assets/"+entry_name, jc.getEntryName());
50 } else {
51 Assert.assertEquals(entry_name, jc.getEntryName());
52 }
53 }
54
55 final BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
56 try {
57 String line = null;
58 int l = 0;
59 while ((line = reader.readLine()) != null) {
60 System.err.println(c.getURL()+":"+l+"> "+line);
61 l++;
62 }
63 } finally {
64 IOUtil.close(reader, false);
65 }
66 }
67}
static final String test_asset_test1_url
In gluegen.test.jar.
static final String test_asset_rt_url
In jaulib_base.jar.
static void testAssetConnection(final URLConnection c, final String entry_name)