diff options
author | Christian Melchior <christian@ilios.dk> | 2017-11-12 15:17:19 +0100 |
---|---|---|
committer | Christian Melchior <christian@ilios.dk> | 2017-11-12 15:17:19 +0100 |
commit | f4769c7ad702fa529a790106ea5c318a7af5c7b7 (patch) | |
tree | 34306d7bb7bf328a9d99d4a23695fd05cb7ddf6d /src/test/javassist/JvstTest.java | |
parent | 457934016fc5a8ba2135196d795c66e1dd25cb2c (diff) | |
download | javassist-f4769c7ad702fa529a790106ea5c318a7af5c7b7.tar.gz javassist-f4769c7ad702fa529a790106ea5c318a7af5c7b7.zip |
Remove close method on ClassPath. Add unit tests for new behaviour.
Diffstat (limited to 'src/test/javassist/JvstTest.java')
-rw-r--r-- | src/test/javassist/JvstTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/javassist/JvstTest.java b/src/test/javassist/JvstTest.java index d660a335..11cdbe96 100644 --- a/src/test/javassist/JvstTest.java +++ b/src/test/javassist/JvstTest.java @@ -1,6 +1,7 @@ package javassist; import junit.framework.*; +import java.io.File; import java.io.FileInputStream; import java.lang.reflect.Method; import javassist.bytecode.*; @@ -63,6 +64,27 @@ public class JvstTest extends JvstTestRoot { assertTrue("[class path: ]".equals(pool.toString())); } + public void testReleaseJarClassPathFileHandle() throws Exception { + String jarFileName = "./empty.jar"; + ClassLoader classLoader = getClass().getClassLoader(); + File jarFile = new File(classLoader.getResource(jarFileName).getFile()); + assertTrue(jarFile.exists()); + + // Prepare class pool and force it to open the Jar file + ClassPool pool = ClassPool.getDefault(); + ClassPath cp = pool.appendClassPath(jarFile.getAbsolutePath()); + assertNull(cp.openClassfile("nothere.Dummy")); + + // Assert that it is possible to delete the jar file. + // On Windows deleting an open file will fail, while on on Mac/Linux this is always possible. + // This check will thus only fail on Windos if the file is still open. + assertTrue(jarFile.delete()); + } + + public void testJarClassPath() throws Exception { + // TODO: Verify that classes can be loaded from a JarClassPath + } + public void testSubtype() throws Exception { CtClass cc = sloader.get("test1.Subtype"); assertTrue(cc.subtypeOf(cc)); |