GlueGen: src/junit/com/jogamp/common/net/AssetURLConnectionBase.java Source File

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
15 public 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) {
42 final AssetURLConnection ac = (AssetURLConnection) c;
43 Assert.assertEquals(entry_name, ac.getEntryName());
44 } else if(c instanceof JarURLConnection) {
45 final JarURLConnection jc = (JarURLConnection) c;
46 if(AndroidVersion.isAvailable) {
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}
com.jogamp.common.net.AssetURLConnectionBase
Definition: AssetURLConnectionBase.java:15
com.jogamp.common.net.AssetURLConnectionBase.testAssetConnection
static void testAssetConnection(final URLConnection c, final String entry_name)
Definition: AssetURLConnectionBase.java:39
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test4_entry
static final String test_asset_test4_entry
Definition: AssetURLConnectionBase.java:37
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test1_url
static final String test_asset_test1_url
In gluegen.test.jar.
Definition: AssetURLConnectionBase.java:24
com.jogamp.common.net.AssetURLConnectionBase.test_asset_rt2_url
static final String test_asset_rt2_url
Definition: AssetURLConnectionBase.java:21
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test4a_url
static final String test_asset_test4a_url
Definition: AssetURLConnectionBase.java:35
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test2_rel
static final Uri.Encoded test_asset_test2_rel
Definition: AssetURLConnectionBase.java:26
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test2_entry
static final String test_asset_test2_entry
Definition: AssetURLConnectionBase.java:29
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test2a_url
static final String test_asset_test2a_url
Definition: AssetURLConnectionBase.java:27
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test4_rel
static final Uri.Encoded test_asset_test4_rel
Definition: AssetURLConnectionBase.java:34
com.jogamp.common.net.AssetURLConnectionBase.test_asset_rt_entry
static final String test_asset_rt_entry
Definition: AssetURLConnectionBase.java:19
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test3b_url
static final String test_asset_test3b_url
Definition: AssetURLConnectionBase.java:32
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test2b_url
static final String test_asset_test2b_url
Definition: AssetURLConnectionBase.java:28
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test3a_url
static final String test_asset_test3a_url
Definition: AssetURLConnectionBase.java:31
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test1_entry
static final String test_asset_test1_entry
Definition: AssetURLConnectionBase.java:25
com.jogamp.common.net.AssetURLConnectionBase.test_asset_rt_url
static final String test_asset_rt_url
In gluegen-rt.jar.
Definition: AssetURLConnectionBase.java:18
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test4b_url
static final String test_asset_test4b_url
Definition: AssetURLConnectionBase.java:36
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test3_rel
static final Uri.Encoded test_asset_test3_rel
Definition: AssetURLConnectionBase.java:30
com.jogamp.common.net.AssetURLConnectionBase.test_asset_test3_entry
static final String test_asset_test3_entry
Definition: AssetURLConnectionBase.java:33
com.jogamp.common.net.AssetURLConnection
See base class PiggybackURLConnection for motivation.
Definition: AssetURLConnection.java:72
com.jogamp.common.net.AssetURLConnection.getEntryName
String getEntryName()
Definition: AssetURLConnection.java:79
com.jogamp.common.net.Uri.Encoded
Immutable RFC3986 encoded string.
Definition: Uri.java:296
com.jogamp.common.net.Uri.Encoded.cast
static Encoded cast(final String encoded)
Casts the given encoded String by creating a new Encoded instance.
Definition: Uri.java:305
com.jogamp.common.net.Uri
This class implements an immutable Uri as defined by RFC 2396.
Definition: Uri.java:160
com.jogamp.common.os.AndroidVersion
Definition: AndroidVersion.java:37
com.jogamp.common.os.AndroidVersion.isAvailable
static final boolean isAvailable
Definition: AndroidVersion.java:38
com.jogamp.common.util.IOUtil
Definition: IOUtil.java:69
com.jogamp.common.util.IOUtil.close
static void close(final Closeable stream, final boolean throwRuntimeException)
Definition: IOUtil.java:1405
com.jogamp.junit.util.SingletonJunitCase
Definition: SingletonJunitCase.java:39