diff options
author | Christian Melchior <christian@ilios.dk> | 2017-11-13 11:25:16 +0100 |
---|---|---|
committer | Christian Melchior <christian@ilios.dk> | 2017-11-13 11:25:16 +0100 |
commit | 620a8be65bb786c77fc2016e9a53364f3d65260e (patch) | |
tree | 345f6df2546375b265dbdd97ce2477d58b016367 | |
parent | c90af6769e50aae20894250099708a2456b7ea1c (diff) | |
download | javassist-620a8be65bb786c77fc2016e9a53364f3d65260e.tar.gz javassist-620a8be65bb786c77fc2016e9a53364f3d65260e.zip |
Add missing unit 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 |