diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/Readme.txt | 2 | ||||
-rw-r--r-- | src/test/javassist/JvstTest.java | 12 | ||||
-rw-r--r-- | src/test/resources/Readme.txt | 12 | ||||
-rw-r--r-- | src/test/resources/simple.jar | bin | 0 -> 631 bytes |
4 files changed, 24 insertions, 2 deletions
diff --git a/src/test/Readme.txt b/src/test/Readme.txt index 0a0df2c8..3218a9d2 100644 --- a/src/test/Readme.txt +++ b/src/test/Readme.txt @@ -10,7 +10,7 @@ Maven > mv ./target/javassist*-GA.jar ./javaassist.jar 2) Check that ./src/test/javassist/JvstTestRoot.PATH and .JAR_PATH point to the compiled jar file. - The default is "../". + The default is "../../". 3) Run Tests diff --git a/src/test/javassist/JvstTest.java b/src/test/javassist/JvstTest.java index 436dc6de..bd68cf08 100644 --- a/src/test/javassist/JvstTest.java +++ b/src/test/javassist/JvstTest.java @@ -3,6 +3,7 @@ package javassist; import junit.framework.*; import java.io.File; import java.io.FileInputStream; +import java.io.InputStream; import java.lang.reflect.Method; import javassist.bytecode.*; import javassist.expr.*; @@ -83,7 +84,16 @@ public class JvstTest extends JvstTestRoot { } public void testJarClassPath() throws Exception { - // TODO: Verify that classes can be loaded from a JarClassPath + String jarFileName = "./simple.jar"; + ClassLoader classLoader = getClass().getClassLoader(); + File jarFile = new File(classLoader.getResource(jarFileName).getFile()); + assertTrue(jarFile.exists()); + + ClassPool pool = ClassPool.getDefault(); + ClassPath cp = pool.appendClassPath(jarFile.getAbsolutePath()); + InputStream is = cp.openClassfile("com.test.Test"); + assertNotNull(is); + is.close(); } public void testSubtype() throws Exception { diff --git a/src/test/resources/Readme.txt b/src/test/resources/Readme.txt index 6ce81b50..77790dc1 100644 --- a/src/test/resources/Readme.txt +++ b/src/test/resources/Readme.txt @@ -2,3 +2,15 @@ This directory contains files used by the unit tests. empty.jar: An empty, but valid, jar file. + +simple.jar: +Contains a single Java class + +``` +package com.test; + +public class Test { + public Test() { + } +} +``` diff --git a/src/test/resources/simple.jar b/src/test/resources/simple.jar Binary files differnew file mode 100644 index 00000000..e9455b92 --- /dev/null +++ b/src/test/resources/simple.jar |