From 9da5bc1fe999caa924bd8dceafeff93ddf9d16a0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 23 Sep 2011 13:17:36 +0200 Subject: TempJarCache/JNILibLoaderBase: Validate the to be loader JarFile's Certificates if caller has any. Add Convenient JNILibLoaderBase.addNativeJarLibs(..) method. --- .../com/jogamp/common/util/TestTempJarCache.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/junit/com/jogamp/common') diff --git a/src/junit/com/jogamp/common/util/TestTempJarCache.java b/src/junit/com/jogamp/common/util/TestTempJarCache.java index fca839b..e1e47af 100644 --- a/src/junit/com/jogamp/common/util/TestTempJarCache.java +++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java @@ -41,6 +41,7 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.NativeLibrary; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempCacheReg; @@ -161,7 +162,7 @@ public class TestTempJarCache { Assert.assertTrue(TempCacheReg.isTempJarCacheUsed()); Assert.assertTrue(TempJarCache.isInitialized()); - TempJarCache.addAll(JarUtil.getJarFile(GlueGenVersion.class.getName(), getClass().getClassLoader())); + TempJarCache.addAll(GlueGenVersion.class, JarUtil.getJarFile(GlueGenVersion.class.getName(), getClass().getClassLoader())); File f0 = new File(TempJarCache.getTempFileCache().getTempDir(), "META-INF/MANIFEST.MF"); Assert.assertTrue(f0.exists()); @@ -179,7 +180,7 @@ public class TestTempJarCache { } @Test - public void testTempJarCache02LoadNativeLibrary() throws IOException { + public void testTempJarCache02AddNativeLibs() throws IOException { final String nativeJarName = "gluegen-rt-natives-"+Platform.getOSAndArch()+".jar"; final String libBaseName = "gluegen-rt"; final ClassLoader cl = getClass().getClassLoader(); @@ -190,7 +191,21 @@ public class TestTempJarCache { URL nativeJarURL = JarUtil.getJarURL(jarUrlRoot, nativeJarName); JarFile nativeJar = JarUtil.getJarFile(nativeJarURL, cl); - TempJarCache.addNativeLibs(nativeJar); + TempJarCache.addNativeLibs(TempJarCache.class, nativeJar); + String libFullPath = TempJarCache.findLibrary(libBaseName); + Assert.assertNotNull(libFullPath); + Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); + File f = new File(libFullPath); + Assert.assertTrue(f.exists()); + } + + @Test + public void testTempJarCache03AddNativeJarLibs() throws IOException { + final String libBaseName = "gluegen-rt"; + + JNILibLoaderBase.addNativeJarLibs(TempJarCache.class, libBaseName); + Assert.assertTrue(JNILibLoaderBase.isLoaded(libBaseName)); + String libFullPath = TempJarCache.findLibrary(libBaseName); Assert.assertNotNull(libFullPath); Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); -- cgit v1.2.3