Browse Source

Add missing unit test

tags/rel_3_23_0_ga
Christian Melchior 6 years ago
parent
commit
620a8be65b

+ 1
- 1
src/test/Readme.txt View File

@@ -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


+ 11
- 1
src/test/javassist/JvstTest.java View File

@@ -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 {

+ 12
- 0
src/test/resources/Readme.txt View File

@@ -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() {
}
}
```

BIN
src/test/resources/simple.jar View File


Loading…
Cancel
Save