]> source.dussan.org Git - aspectj.git/commitdiff
two harness test cases, for classpath (jar and dir)
authorwisberg <wisberg>
Mon, 6 Jan 2003 23:09:44 +0000 (23:09 +0000)
committerwisberg <wisberg>
Mon, 6 Jan 2003 23:09:44 +0000 (23:09 +0000)
and aspectpath.
Binaries are checked in, as are binary sources
and a build script.
Test specifications are in tests/ajcHarnessTests.xml.
(also checked in) with the build script

tests/harness/classpathTest/AspectMain.java [new file with mode: 0644]
tests/harness/classpathTest/Main.java [new file with mode: 0644]
tests/harness/classpathTest/classesDir/classfile/required/ClassFile.class [new file with mode: 0644]
tests/harness/classpathTest/classpath-src/aspectjar/testaspect/SignalMainRunnable.java [new file with mode: 0644]
tests/harness/classpathTest/classpath-src/build.xml [new file with mode: 0644]
tests/harness/classpathTest/classpath-src/classesDir/classfile/required/ClassFile.java [new file with mode: 0644]
tests/harness/classpathTest/classpath-src/classjar/jar/required/Global.java [new file with mode: 0644]
tests/harness/classpathTest/jars/required.jar [new file with mode: 0644]
tests/harness/classpathTest/jars/requiredAspects.jar [new file with mode: 0644]
tests/harness/classpathTest/readme.txt [new file with mode: 0644]

diff --git a/tests/harness/classpathTest/AspectMain.java b/tests/harness/classpathTest/AspectMain.java
new file mode 100644 (file)
index 0000000..cc7576a
--- /dev/null
@@ -0,0 +1,15 @@
+
+import org.aspectj.testing.Tester;
+import jar.required.Global;
+import classfile.required.ClassFile;
+
+public class AspectMain {
+    public static void main (String[] args) {
+        Tester.expectEvent("aspect");
+        Tester.check(ClassFile.isTrue(), "not ClassFile.isTrue()?");
+        Tester.check(Global.isTrue(), "not Global.isTrue()?");
+        // aspect advises this invocation, adds "aspect" event
+        new Runnable() { public void run(){}}.run();
+        Tester.checkAllEvents();
+    } 
+}
diff --git a/tests/harness/classpathTest/Main.java b/tests/harness/classpathTest/Main.java
new file mode 100644 (file)
index 0000000..f2c1e2f
--- /dev/null
@@ -0,0 +1,11 @@
+
+import org.aspectj.testing.Tester;
+import jar.required.Global;
+import classfile.required.ClassFile;
+
+public class Main {
+    public static void main (String[] args) {
+        Tester.check(ClassFile.isTrue(), "not ClassFile.isTrue()?");
+        Tester.check(Global.isTrue(), "not Global.isTrue()?");
+    } 
+}
diff --git a/tests/harness/classpathTest/classesDir/classfile/required/ClassFile.class b/tests/harness/classpathTest/classesDir/classfile/required/ClassFile.class
new file mode 100644 (file)
index 0000000..3093b68
Binary files /dev/null and b/tests/harness/classpathTest/classesDir/classfile/required/ClassFile.class differ
diff --git a/tests/harness/classpathTest/classpath-src/aspectjar/testaspect/SignalMainRunnable.java b/tests/harness/classpathTest/classpath-src/aspectjar/testaspect/SignalMainRunnable.java
new file mode 100644 (file)
index 0000000..74a75a0
--- /dev/null
@@ -0,0 +1,17 @@
+
+package testaspect;
+
+import org.aspectj.testing.Tester;
+
+public aspect SignalMainRunnable {
+
+    /**
+     * Signal Tester event "aspect" if a main method
+     * calls run() on a Runnable.
+     */
+    after() returning : withincode(public static void main(..))
+        && target(Runnable) && call(void run()) {
+        Tester.event("aspect");
+    }
+}
+
diff --git a/tests/harness/classpathTest/classpath-src/build.xml b/tests/harness/classpathTest/classpath-src/build.xml
new file mode 100644 (file)
index 0000000..1bbc6bd
--- /dev/null
@@ -0,0 +1,81 @@
+
+<!-- ========================================================================= -->
+<!-- Copyright (c) 2002 Wes Isberg                                             -->
+<!-- All rights reserved.                                                      -->
+<!-- This program and the accompanying materials are made available            -->
+<!-- under the terms of the Common Public License v1.0                         -->
+<!-- which accompanies this distribution and is available at                   -->
+<!-- http://www.eclipse.org/legal/cpl-v10.html                                 -->
+<!--                                                                           -->
+<!-- Contributors:                                                             -->
+<!--     Xerox/PARC     initial implementation                                 -->
+<!-- ========================================================================= -->
+
+<project name="classpath-test" default="all" basedir=".">
+
+
+    <target name="init.variables" 
+     description="setup variables - user defines aspectj.lib.dir">
+
+      <!-- required directories - run from examples or predefine -->
+      <property name="test.base.dir"
+            location="${basedir}/.."/> 
+      <property name="classes.dir"
+            location="${test.base.dir}/classesDir"/> 
+      <property name="jar.dir"
+            location="${test.base.dir}/jars"/> 
+
+       
+      <!-- caller must define aspectj.lib.dir -->
+      <property name="aspectj.lib.dir"
+            location="lib"/> 
+      <property name="aspectjrt.jar"
+            location="${aspectj.lib.dir}/aspectjrt.jar"/> 
+      <available file="${aspectjrt.jar}"
+             property="aspectjrt.jar.available"/>
+      <fail unless="aspectjrt.jar.available"
+           message="expecting aspectjrt.jar at ${aspectjrt.jar}"/>
+
+      <property name="aspectjtools.jar"
+            location="${aspectj.lib.dir}/aspectjtools.jar"/> 
+      <available file="${aspectjtools.jar}"
+             property="aspectjtools.jar.available"/>
+      <fail unless="aspectjtools.jar.available"
+           message="expecting aspectjtools.jar at ${aspectjtools.jar}"/>
+
+      <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
+          <classpath> 
+            <pathelement path="${aspectjtools.jar}"/> 
+          </classpath>
+      </taskdef>
+
+    </target>
+    <target name="all" depends="init.variables"
+     description="build classes, required.jar and requiredAspects.jar">
+        <iajc outjar="${jar.dir}/required.jar"
+           sourceroots="${test.base.dir}/classpath-src/classjar">
+           <classpath>
+               <pathelement path="${aspectjrt.jar}"/> 
+           </classpath>
+        </iajc>
+
+        <iajc outjar="${jar.dir}/requiredAspects.jar"
+           sourceroots="${test.base.dir}/classpath-src/aspectjar">
+           <classpath>
+               <pathelement path="${aspectjrt.jar}"/> 
+               <pathelement path="${test.base.dir}/../../../lib/test/testing-client.jar"/> 
+           </classpath>
+        </iajc>
+
+        <delete>
+           <fileset dir="${classes.dir}" includes="**/*"/>
+        </delete>
+        <iajc destdir="${classes.dir}"
+           sourceroots="${test.base.dir}/classpath-src/classesDir">
+           <classpath>
+               <pathelement path="${aspectjrt.jar}"/> 
+           </classpath>
+        </iajc>
+    </target>
+
+</project>
diff --git a/tests/harness/classpathTest/classpath-src/classesDir/classfile/required/ClassFile.java b/tests/harness/classpathTest/classpath-src/classesDir/classfile/required/ClassFile.java
new file mode 100644 (file)
index 0000000..ff03425
--- /dev/null
@@ -0,0 +1,8 @@
+
+package classfile.required;
+
+public class ClassFile {
+    public static boolean isTrue() {
+        return (0l < System.currentTimeMillis());
+    } 
+}
diff --git a/tests/harness/classpathTest/classpath-src/classjar/jar/required/Global.java b/tests/harness/classpathTest/classpath-src/classjar/jar/required/Global.java
new file mode 100644 (file)
index 0000000..60c95b4
--- /dev/null
@@ -0,0 +1,8 @@
+
+package jar.required;
+
+public class Global {
+    public static boolean isTrue() {
+        return (0l < System.currentTimeMillis());
+    } 
+}
diff --git a/tests/harness/classpathTest/jars/required.jar b/tests/harness/classpathTest/jars/required.jar
new file mode 100644 (file)
index 0000000..368789b
Binary files /dev/null and b/tests/harness/classpathTest/jars/required.jar differ
diff --git a/tests/harness/classpathTest/jars/requiredAspects.jar b/tests/harness/classpathTest/jars/requiredAspects.jar
new file mode 100644 (file)
index 0000000..9521769
Binary files /dev/null and b/tests/harness/classpathTest/jars/requiredAspects.jar differ
diff --git a/tests/harness/classpathTest/readme.txt b/tests/harness/classpathTest/readme.txt
new file mode 100644 (file)
index 0000000..c5eb338
--- /dev/null
@@ -0,0 +1,25 @@
+
+
+This contains artifacts for two harness test cases, 
+for classpath (jar and dir) and aspectpath.  
+
+Binaries are in jars/*, and classesDir/*, and 
+binary sources and a build script are in classpath-src.
+  
+Two test specifications are in tests/ajcHarnessTests.xml:
+
+    <ajc-test dir="harness/classpathTest"
+      title="specify jars and directories on classpath"
+      keywords="purejava">
+        <compile classpath="classesDir,jars/required.jar" 
+                 files="Main.java"/>
+        <run class="Main"/>
+    </ajc-test>
+
+    <ajc-test dir="harness/classpathTest"
+      title="specify aspectpath and classpath jars and directories">
+        <compile classpath="classesDir,jars/required.jar"
+                 aspectpath="jars/requiredAspects.jar"
+                 files="AspectMain.java"/>
+        <run class="AspectMain"/>
+    </ajc-test>