diff options
author | Sven Gothel <[email protected]> | 2011-09-20 05:49:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-09-20 05:49:36 +0200 |
commit | 61d3b2f9b60cbea2e9454b86cc559347943a578e (patch) | |
tree | e2c395dffa279b29646e7be6dcc40513b8b82145 /src/junit | |
parent | b12fe7f98a9b523129c310d46698f430d17a8138 (diff) |
Temp Cache: More control over the lifecycle, explicit TempJarCache initialization/usage only
Diffstat (limited to 'src/junit')
-rw-r--r-- | src/junit/com/jogamp/common/util/TestTempJarCache.java | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/junit/com/jogamp/common/util/TestTempJarCache.java b/src/junit/com/jogamp/common/util/TestTempJarCache.java index a0e0379..fca839b 100644 --- a/src/junit/com/jogamp/common/util/TestTempJarCache.java +++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java @@ -43,6 +43,7 @@ import org.junit.Test; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.NativeLibrary; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.cache.TempCacheReg; import com.jogamp.common.util.cache.TempFileCache; import com.jogamp.common.util.cache.TempJarCache; @@ -108,10 +109,14 @@ public class TestTempJarCache { @BeforeClass public static void init() { + // may already been initialized by other test + // Assert.assertFalse(TempCacheReg.isTempFileCacheUsed()); + Assert.assertTrue(TempFileCache.initSingleton()); + Assert.assertTrue(TempCacheReg.isTempFileCacheUsed()); + fileCache = new TempFileCache(); Assert.assertTrue(fileCache.isValid()); System.err.println("tmp dir: "+fileCache.getTempDir()); - } @Test @@ -149,7 +154,13 @@ public class TestTempJarCache { @Test public void testTempJarCache01LoadAllTestManifestAndClass() throws IOException { - Assert.assertTrue(TempJarCache.isValid()); + // may already been initialized by other test + // Assert.assertFalse(TempCacheReg.isTempJarCacheUsed()); + // Assert.assertFalse(TempJarCache.isInitialized()); + Assert.assertTrue(TempJarCache.initSingleton()); + Assert.assertTrue(TempCacheReg.isTempJarCacheUsed()); + Assert.assertTrue(TempJarCache.isInitialized()); + TempJarCache.addAll(JarUtil.getJarFile(GlueGenVersion.class.getName(), getClass().getClassLoader())); File f0 = new File(TempJarCache.getTempFileCache().getTempDir(), "META-INF/MANIFEST.MF"); @@ -204,6 +215,19 @@ public class TestTempJarCache { ClassLoader cl2 = new TestClassLoader(urls, null); ClassLoader cl3 = new TestClassLoader(urls, null); + Assert.assertFalse(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl2) + ).booleanValue()); + Assert.assertFalse(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl3) + ).booleanValue()); + Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "initSingleton", null, null, cl2) + ).booleanValue()); + Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "initSingleton", null, null, cl3) + ).booleanValue()); + Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl2) + ).booleanValue()); + Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl3) + ).booleanValue()); + Object fileCache2 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl2); Object fileCache3 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl3); |