aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-10-18 16:10:30 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2011-10-18 16:10:30 +0000
commit85e2eebf17da1506fcdfe541261030e56253239c (patch)
treeba3ea4e0a45b3afae2e11a04a3db8599df7ebed9
parent3ad4da6d8cd5f11a8009c70f59d613b52cf4b50d (diff)
downloadjavassist-85e2eebf17da1506fcdfe541261030e56253239c.tar.gz
javassist-85e2eebf17da1506fcdfe541261030e56253239c.zip
unit test for JASSIST-145
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@592 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--build.xml19
-rw-r--r--src/test/javassist/JvstTest4.java18
-rw-r--r--src/test/test4/Aaload.java15
3 files changed, 40 insertions, 12 deletions
diff --git a/build.xml b/build.xml
index 594b42cd..3815e9d1 100644
--- a/build.xml
+++ b/build.xml
@@ -17,6 +17,7 @@
<property name="build.classes.dir" value="${build.dir}/classes"/>
<property name="test.src.dir" value="${basedir}/src/test"/>
<property name="test.build.dir" value="${basedir}/build/test-classes"/>
+ <property name="test.run.dir" value="${basedir}/runtest"/>
<property name="test.reports.dir" value = "${basedir}/build/test-output"/>
<property name="run.dir" value="${build.classes.dir}"/>
@@ -38,7 +39,7 @@
<path id="test.classpath">
<pathelement location="${test.build.dir}"/>
<pathelement location="${lib.dir}/junit.jar"/>
- <pathelement location="${build.classes.dir}"/>
+ <pathelement location="${build.classes.dir}"/>
</path>
<property name="test.classpath" refid="test.classpath"/>
@@ -50,7 +51,8 @@
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${test.build.dir}"/>
- <mkdir dir="${test.reports.dir}"/>
+ <mkdir dir="${test.reports.dir}"/>
+ <mkdir dir="${test.run.dir}"/>
</target>
<!-- =================================================================== -->
@@ -91,16 +93,11 @@
</javac>
</target>
- <target name="test" depends="test-compile">
- <junit fork="true" printsummary="true">
+ <target name="runtest" depends="test-compile">
+ <junit fork="true" printsummary="true" dir="${test.run.dir}">
<classpath refid="test.classpath"/>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest todir="${test.reports.dir}">
- <fileset dir="${test.build.dir}">
- <include name="**/*Test.*"/>
- </fileset>
- </batchtest>
+ <formatter type="xml" extension=".xml"/>
+ <test name="javassist.JvstTest" outfile="TestLog" />
</junit>
</target>
diff --git a/src/test/javassist/JvstTest4.java b/src/test/javassist/JvstTest4.java
index 016420d9..9ea09743 100644
--- a/src/test/javassist/JvstTest4.java
+++ b/src/test/javassist/JvstTest4.java
@@ -492,6 +492,9 @@ public class JvstTest4 extends JvstTestRoot {
cc = sloader.get("test4.NestedClass");
tab = cc.getNestedClasses();
+ for (CtClass c: tab) {
+ System.err.println(c.getName());
+ }
assertEquals(4, tab.length);
for (CtClass c: tab) {
String name = c.getName();
@@ -560,10 +563,23 @@ public class JvstTest4 extends JvstTestRoot {
fail("test4no was found!");
}
catch (CannotCompileException e) {
- System.err.println(e);
+ System.out.println(e);
}
cc.writeFile();
Object obj = make(cc.getName());
assertEquals(110, invoke(obj, "run"));
}
+
+ public void testAaload() throws Exception {
+ CtClass clazz = sloader.get("test4.Aaload");
+ CtMethod method = clazz.getMethod("narf", "()V");
+ method.instrument(new ExprEditor() {
+ @Override
+ public void edit(MethodCall call) throws CannotCompileException {
+ String name = call.getMethodName();
+ if (name.equals("addActionListener"))
+ call.replace("$0." + name + "($$);");
+ }
+ });
+ }
}
diff --git a/src/test/test4/Aaload.java b/src/test/test4/Aaload.java
new file mode 100644
index 00000000..5299b485
--- /dev/null
+++ b/src/test/test4/Aaload.java
@@ -0,0 +1,15 @@
+package test4;
+import java.awt.MenuItem;
+
+public class Aaload {
+ static void narf() {
+ String[] list = null;
+ for (int i = 0; i < list.length; i++) {
+ String name = list[i];
+ if (name.endsWith(".txt")) {
+ MenuItem item = new MenuItem(name);
+ item.addActionListener(null);
+ }
+ }
+ }
+}