29package com.jogamp.common.net;
32import java.io.IOException;
34import java.net.URISyntaxException;
36import java.net.URLClassLoader;
38import org.junit.Assert;
39import org.junit.FixMethodOrder;
41import org.junit.runners.MethodSorters;
43import com.jogamp.common.os.AndroidVersion;
44import com.jogamp.common.os.Platform;
45import com.jogamp.common.util.JarUtil;
46import com.jogamp.common.util.ReflectionUtil;
47import com.jogamp.junit.util.SingletonJunitCase;
48import com.jogamp.junit.util.MiscUtils;
72@FixMethodOrder(MethodSorters.NAME_ASCENDING)
74 static class TestClassLoader
extends URLClassLoader {
75 public TestClassLoader(
final URL[] urls) {
78 public TestClassLoader(
final URL[] urls,
final ClassLoader parent) {
86 testTempJarCacheOddJarPathImpl(
"simpletons/");
92 testTempJarCacheOddJarPathImpl(
"A$-B^-C~-D#-E]-F[-öä/");
116 testTempJarCacheOddJarPathImpl(
"Users/(ABC)abc/AppData/Local/Temp/");
118 private void testTempJarCacheOddJarPathImpl(
final String subPathUTF)
throws IOException, IllegalArgumentException, URISyntaxException {
121 final Uri.Encoded subPathEncoded =
new Uri.Encoded(subPathUTF, Uri.PATH_LEGAL);
122 final String reservedCharPathUnencoded =
"test/build/"+getClass().getSimpleName()+
"/"+getTestMethodName()+
"/"+subPathUTF;
123 final Uri.Encoded reservedCharPathEncoded = Uri.Encoded.cast(
"test/build/"+getClass().getSimpleName()+
"/"+getTestMethodName()+
"/").concat(subPathEncoded);
125 System.err.println(
"0 Unencoded: "+reservedCharPathUnencoded);
126 System.err.println(
"0 Encoded: "+reservedCharPathEncoded);
129 final Uri jarFileURI = JarUtil.getJarFileUri(Platform.class.getName(), getClass().getClassLoader());
130 System.err.println(
"1 jarFileURI: "+jarFileURI.toString());
132 final Uri.Encoded jarBasename = JarUtil.getJarBasename(jarFileURI);
133 System.err.println(
"2 jarBasename: "+jarBasename);
136 final Uri fileURI = jarFileURI.getContainedUri();
137 System.err.println(
"3 fileURI: "+fileURI.toString());
139 final Uri fileFolderURI = fileURI.getParent();
140 System.err.println(
"4 fileFolderURI: "+fileFolderURI.toString());
142 final Uri fileNewFolderURI = fileFolderURI.concat(reservedCharPathEncoded);
143 System.err.println(
"5 fileNewFolderURI: "+fileNewFolderURI.toString());
145 final File srcFolder = fileFolderURI.toFile();
146 final File dstFolder = fileNewFolderURI.toFile();
147 System.err.println(
"6 srcFolder: "+srcFolder.toString());
148 System.err.println(
"7 dstFolder: "+dstFolder.toString());
150 final MiscUtils.CopyStats copyStats = MiscUtils.copy(srcFolder, dstFolder, 1,
true);
151 copyStats.dump(
"Copy ",
true);
152 Assert.assertEquals(1, copyStats.totalFolders);
153 Assert.assertTrue(copyStats.totalBytes > 0);
154 Assert.assertEquals(0, copyStats.currentDepth);
156 final URI jarFileNewFolderURI =
new URI(fileNewFolderURI.toString()+jarBasename);
157 System.err.println(
"8 jarFileNewFolderURI: "+jarFileNewFolderURI.toString());
159 final URL[] urls =
new URL[] { jarFileNewFolderURI.toURL() };
160 System.err.println(
"url: "+urls[0]);
162 final ClassLoader cl =
new TestClassLoader(urls,
null);
163 ReflectionUtil.callStaticMethod(Platform.class.getName(),
"initSingleton",
null,
null, cl);
170 public static void main(
final String args[])
throws IOException {
172 org.junit.runner.JUnitCore.
main(tstname);
Bug 908: Automated test, launching GlueGen jar file from an odd pathname.
void test02TempJarCacheOddPath()
void test01TempJarCacheOddPath()
static void main(final String args[])
void test00TempJarCacheSimplePath()
static final boolean isAvailable