GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
TestUrisWithAssetHandler.java
Go to the documentation of this file.
1package com.jogamp.common.net;
2
3import static com.jogamp.common.net.URIDumpUtil.showURX;
4
5import java.io.IOException;
6import java.net.URISyntaxException;
7
8import org.junit.Assert;
9import org.junit.BeforeClass;
10import org.junit.FixMethodOrder;
11import org.junit.Test;
12import org.junit.runners.MethodSorters;
13
14import com.jogamp.junit.util.SingletonJunitCase;
15
16@FixMethodOrder(MethodSorters.NAME_ASCENDING)
18
19 @BeforeClass
20 public static void assetRegistration() throws Exception {
21 try {
22 System.err.println("******* Asset URL Stream Handler Registration: PRE");
23 Assert.assertTrue("GenericURLStreamHandlerFactory.register() failed", AssetURLContext.registerHandler(TestUrisWithAssetHandler.class.getClassLoader()));
24 Assert.assertNotNull(AssetURLContext.getRegisteredHandler());
25 System.err.println("******* Asset URL Stream Handler Registration: POST");
26 } catch (final Exception e) {
27 setTestSupported(false);
28 throw e;
29 }
30 }
31
32 @Test
33 public void showURLComponents0() throws IOException, URISyntaxException {
34 showURX("file:///rootDir/file1.txt");
35 showURX("file://host/rootDir/file1.txt");
36 showURX("jar:file:/web1/file1.jar!/rootDir/file1.txt");
37 showURX("asset:gluegen-test/info.txt");
38 showURX("asset:/gluegen-test/info.txt");
39 showURX("http://domain.com/web1/index.html?lala=23&lili=24#anchor");
40 showURX("http://domain.com:1234/web1/index.html?lala=23&lili=24#anchor");
41 showURX("asset:jar:file:/web1/file1.jar!/rootDir/file1.txt");
42 showURX("asset:jar:file:/web1/file1.jar!/rootDir/./file1.txt");
43 showURX("asset:jar:file:/web1/file1.jar!/rootDir/dummyParent/../file1.txt");
44 }
45
46 public static void main(final String args[]) throws IOException {
47 final String tstname = TestUrisWithAssetHandler.class.getName();
48 org.junit.runner.JUnitCore.main(tstname);
49 }
50}
See PiggybackURLConnection for description and examples.
static boolean registerHandler(final ClassLoader cl)
Registers the generic URLStreamHandlerFactory via GenericURLStreamHandlerFactory#register() and if su...
static URLStreamHandler getRegisteredHandler()
Returns the asset handler previously set via registerHandler(ClassLoader), or null if none was set.