GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
AssetURLConnectionBase.java
Go to the documentation of this file.
1package com.jogamp.common.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.junit.Assert;
10
11import com.jogamp.common.os.AndroidVersion;
12import com.jogamp.common.util.IOUtil;
13import com.jogamp.junit.util.SingletonJunitCase;
14
15public abstract class AssetURLConnectionBase extends SingletonJunitCase {
16
17 /** In gluegen-rt.jar */
18 protected static final String test_asset_rt_url = "asset:gluegen/info.txt";
19 protected static final String test_asset_rt_entry = "gluegen/info.txt";
20
21 protected static final String test_asset_rt2_url = "asset:/gluegen/info.txt";
22
23 /** In gluegen.test.jar */
24 protected static final String test_asset_test1_url = "asset:gluegen-test/info.txt";
25 protected static final String test_asset_test1_entry = "gluegen-test/info.txt";
26 protected static final Uri.Encoded test_asset_test2_rel = Uri.Encoded.cast("data/AssetURLConnectionTest.txt");
27 protected static final String test_asset_test2a_url = "asset:com/jogamp/common/net/data/AssetURLConnectionTest.txt";
28 protected static final String test_asset_test2b_url = "asset:/com/jogamp/common/net/data/AssetURLConnectionTest.txt";
29 protected static final String test_asset_test2_entry = "com/jogamp/common/net/data/AssetURLConnectionTest.txt";
30 protected static final Uri.Encoded test_asset_test3_rel = Uri.Encoded.cast("RelativeData.txt");
31 protected static final String test_asset_test3a_url = "asset:com/jogamp/common/net/data/RelativeData.txt";
32 protected static final String test_asset_test3b_url = "asset:/com/jogamp/common/net/data/RelativeData.txt";
33 protected static final String test_asset_test3_entry = "com/jogamp/common/net/data/RelativeData.txt";
34 protected static final Uri.Encoded test_asset_test4_rel = Uri.Encoded.cast("../data2/RelativeData2.txt");
35 protected static final String test_asset_test4a_url = "asset:com/jogamp/common/net/data2/RelativeData2.txt";
36 protected static final String test_asset_test4b_url = "asset:/com/jogamp/common/net/data2/RelativeData2.txt";
37 protected static final String test_asset_test4_entry = "com/jogamp/common/net/data2/RelativeData2.txt";
38
39 protected static void testAssetConnection(final URLConnection c, final String entry_name) throws IOException {
40 Assert.assertNotNull(c);
41 if(c instanceof AssetURLConnection) {
43 Assert.assertEquals(entry_name, ac.getEntryName());
44 } else if(c instanceof JarURLConnection) {
45 final JarURLConnection jc = (JarURLConnection) c;
47 Assert.assertEquals("assets/"+entry_name, jc.getEntryName());
48 } else {
49 Assert.assertEquals(entry_name, jc.getEntryName());
50 }
51 }
52
53 final BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream()));
54 try {
55 String line = null;
56 int l = 0;
57 while ((line = reader.readLine()) != null) {
58 System.err.println(c.getURL()+":"+l+"> "+line);
59 l++;
60 }
61 } finally {
62 IOUtil.close(reader, false);
63 }
64 }
65}
static void testAssetConnection(final URLConnection c, final String entry_name)
static final String test_asset_test1_url
In gluegen.test.jar.
static final String test_asset_rt_url
In gluegen-rt.jar.
See base class PiggybackURLConnection for motivation.
Immutable RFC3986 encoded string.
Definition: Uri.java:296
static Encoded cast(final String encoded)
Casts the given encoded String by creating a new Encoded instance.
Definition: Uri.java:305
This class implements an immutable Uri as defined by RFC 2396.
Definition: Uri.java:160
static void close(final Closeable stream, final boolean throwRuntimeException)
Definition: IOUtil.java:1405