]> source.dussan.org Git - aspectj.git/commitdiff
Bug 155033 "Use ajcore for LTW problems" (add ajcore LTW testcases)
authormwebster <mwebster>
Mon, 6 Nov 2006 13:50:14 +0000 (13:50 +0000)
committermwebster <mwebster>
Mon, 6 Nov 2006 13:50:14 +0000 (13:50 +0000)
16 files changed:
tests/bugs153/pr155033/Annotation.java [new file with mode: 0644]
tests/bugs153/pr155033/Aspect.aj [new file with mode: 0644]
tests/bugs153/pr155033/Class1.java [new file with mode: 0644]
tests/bugs153/pr155033/Class2.java [new file with mode: 0644]
tests/bugs153/pr155033/Class3.java [new file with mode: 0644]
tests/bugs153/pr155033/MultipleDumpTest.java [new file with mode: 0644]
tests/bugs153/pr155033/ant.xml [new file with mode: 0644]
tests/bugs153/pr155033/aop-multipledumponerror.xml [new file with mode: 0644]
tests/ltw/HelloWorld.java [deleted file]
tests/ltw/HelloWorldWithException.java [new file with mode: 0644]
tests/ltw/ant.xml
tests/ltw/aop-dumponerror.xml [new file with mode: 0644]
tests/ltw/server-helloworld.properties
tests/ltw/server-parentandchild.properties
tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml

diff --git a/tests/bugs153/pr155033/Annotation.java b/tests/bugs153/pr155033/Annotation.java
new file mode 100644 (file)
index 0000000..12f6811
--- /dev/null
@@ -0,0 +1 @@
+@interface Annotation {}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/Aspect.aj b/tests/bugs153/pr155033/Aspect.aj
new file mode 100644 (file)
index 0000000..60b1b57
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect Aspect {
+
+       declare @method : public static void main(String[]) : @Annotation;
+
+       before () : execution(public Class*.new()) {
+               System.out.println("? Aspect.before()");
+       }
+       
+}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/Class1.java b/tests/bugs153/pr155033/Class1.java
new file mode 100644 (file)
index 0000000..aae2faf
--- /dev/null
@@ -0,0 +1,8 @@
+public class Class1 /*implements MissingInterface*/ {
+       
+       @Annotation
+       public static void main(String[] args) {
+               System.out.println("? Class1.main()");
+               new Class1();
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/Class2.java b/tests/bugs153/pr155033/Class2.java
new file mode 100644 (file)
index 0000000..bfbd85e
--- /dev/null
@@ -0,0 +1,8 @@
+public class Class2 /*implements MissingInterface*/ {
+       
+       @Annotation
+       public static void main(String[] args) {
+               System.out.println("? Class2.main()");
+               new Class2();
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/Class3.java b/tests/bugs153/pr155033/Class3.java
new file mode 100644 (file)
index 0000000..9577464
--- /dev/null
@@ -0,0 +1,7 @@
+public class Class3 {
+       
+       public static void main(String[] args) {
+               System.out.println("? Class3.main()");
+               new Class3();
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/MultipleDumpTest.java b/tests/bugs153/pr155033/MultipleDumpTest.java
new file mode 100644 (file)
index 0000000..554460b
--- /dev/null
@@ -0,0 +1,24 @@
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class MultipleDumpTest {
+       
+       public static void main(String[] args) throws Exception {
+               System.out.println("? MultipleDumpTest.main()");
+               invokeMain("Class1",args);
+               invokeMain("Class2",args);
+               invokeMain("Class3",args);
+       }
+
+       private static void invokeMain (String className, String[] args) throws Exception
+       {
+               Class clazz = Class.forName(className);
+               Class[] paramTypes = new Class[1];
+               paramTypes[0] = args.getClass();
+       
+               Method method = clazz.getDeclaredMethod("main",paramTypes);
+               Object[] params = new Object[1];
+               params[0] = args;
+               method.invoke(null,params);
+       }
+}
\ No newline at end of file
diff --git a/tests/bugs153/pr155033/ant.xml b/tests/bugs153/pr155033/ant.xml
new file mode 100644 (file)
index 0000000..5995cb9
--- /dev/null
@@ -0,0 +1,27 @@
+<!-- ajc-ant script, not to be used from Ant commant line - see AntSpec -->
+<project name="ltw">
+
+    <!-- using this we can debug the forked VM -->
+    <property
+        name="jdwp"
+        value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
+       <property name="aj.bootpath" refid="aj.path"/>
+
+    <target name="multiple dump on error">
+        <copy file="aop-multipledumponerror.xml"
+              tofile="${aj.sandbox}/META-INF/aop.xml"/>
+        <java fork="yes" classname="MultipleDumpTest" failonerror="yes">
+            <classpath refid="aj.path"/>
+            <jvmarg value="-Dorg.aspectj.weaver.Dump.condition=error"/>
+               <sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
+            <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+<!--            <jvmarg line="${jdwp}"/>-->
+<!--           
+            <jvmarg value="-Dorg.aspectj.tracing.enabled=true"/>
+            <jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
+            <jvmarg value="-Dorg.aspectj.tracing.messages=true"/>
+-->            
+        </java>
+    </target>
+
+</project>
diff --git a/tests/bugs153/pr155033/aop-multipledumponerror.xml b/tests/bugs153/pr155033/aop-multipledumponerror.xml
new file mode 100644 (file)
index 0000000..c3c75fb
--- /dev/null
@@ -0,0 +1,4 @@
+<aspectj>
+    <!--<weaver options="-XmessageHandlerClass:AbortingMessageHandler -debug -XnoInline -Xlint:error"/>-->
+    <weaver options="-1.5 -Xlint:error"/>
+</aspectj>
\ No newline at end of file
diff --git a/tests/ltw/HelloWorld.java b/tests/ltw/HelloWorld.java
deleted file mode 100644 (file)
index 9c810cf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-public class HelloWorld {
-       
-       public static void main (String[] args) throws Exception {
-               System.out.println("Hello World!");
-               throw new Exception();
-       }
-       
-}
\ No newline at end of file
diff --git a/tests/ltw/HelloWorldWithException.java b/tests/ltw/HelloWorldWithException.java
new file mode 100644 (file)
index 0000000..b043000
--- /dev/null
@@ -0,0 +1,8 @@
+public class HelloWorldWithException {
+       
+       public static void main (String[] args) throws Exception {
+               System.out.println("Hello World!");
+               throw new Exception();
+       }
+       
+}
\ No newline at end of file
index e1cb0a6bde7310d52eae479b1e96475e6fc99130..dff2071e7424ec58592d68727d0cdcfc77329ab2 100644 (file)
@@ -8,7 +8,7 @@
        <property name="aj.bootpath" refid="aj.path"/>
 
     <target name="JDK14 LTW with XML">
-        <java fork="yes" classname="HelloWorld" failonerror="yes">
+        <java fork="yes" classname="HelloWorldWithException" failonerror="yes">
             <classpath refid="aj.path"/>
             <jvmarg value="-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
                <sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
@@ -24,7 +24,7 @@
     </target>
 
     <target name="JDK14 LTW with ASPECTPATH">
-        <java fork="yes" classname="HelloWorld" failonerror="yes">
+        <java fork="yes" classname="HelloWorldWithException" failonerror="yes">
             <classpath refid="aj.path"/>
             <jvmarg value="-Djava.system.class.loader=org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
                <sysproperty key="aj.class.path" path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar"/>
@@ -47,7 +47,7 @@
     <target name="override default path using -Dorg.aspectj.weaver.loadtime.configuration">
         <copy file="${aj.root}/tests/ltw/aop-orgaspectjweaverloadtimeconfiguration.xml"
               tofile="${aj.sandbox}/META-INF/aop-random.xml"/>
-        <java fork="yes" classname="HelloWorld" failonerror="yes">
+        <java fork="yes" classname="HelloWorldWithException" failonerror="yes">
             <classpath refid="aj.path"/>
             <classpath>
                 <pathelement path="${aj.sandbox}/hello.jar:${aj.sandbox}/handler.jar:${aj.sandbox}/tracing.jar"/>
@@ -68,7 +68,7 @@
             SecurityManager that will be loaded _before_ the class loader
             hierarch is fully initialized. -->
     <target name="NPE with custom agent">
-        <java fork="yes" classname="HelloWorld" failonerror="yes">
+        <java fork="yes" classname="HelloWorldWithException" failonerror="yes">
                
                <!-- Prepend custom URLClassLoader and append AspectJ
                     to bootclasspath -->
@@ -97,7 +97,7 @@
     <target name="simple LTW">
         <copy file="${aj.root}/tests/ltw/aop-simple.xml"
               tofile="${aj.sandbox}/META-INF/aop.xml"/>
-        <java fork="yes" classname="HelloWorld" failonerror="yes">
+        <java fork="yes" classname="HelloWorldWithException" failonerror="yes">
             <classpath refid="aj.path"/>
             <!-- use META-INF/aop.xml style -->
             <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
         </java>
     </target>
 
+    <target name="dump on error">
+        <copy file="${aj.root}/tests/ltw/aop-dumponerror.xml"
+              tofile="${aj.sandbox}/META-INF/aop.xml"/>
+        <java fork="yes" classname="HelloWorldWithException" failonerror="no">
+            <classpath refid="aj.path"/>
+            <jvmarg value="-Dorg.aspectj.weaver.Dump.condition=error"/>
+               <sysproperty key="org.aspectj.dump.directory" path="${aj.sandbox}"/>
+            <!-- use META-INF/aop.xml style -->
+            <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+<!--            <jvmarg line="${jdwp}"/>-->
+            <jvmarg value="-Dorg.aspectj.tracing.factory=default"/>
+        </java>
+    </target>
+
 </project>
diff --git a/tests/ltw/aop-dumponerror.xml b/tests/ltw/aop-dumponerror.xml
new file mode 100644 (file)
index 0000000..8115618
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+       <aspects>
+        <concrete-aspect name="SubAspect" extends="MissingAspect">
+               <pointcut name="scope" expression=""/>
+        </concrete-aspect>
+       </aspects>
+</aspectj>
\ No newline at end of file
index baf42dbe072f6469c4dbc037a125c35065f9fcf4..09ec740a732557d60046d04167a98ed2cb05cf3f 100644 (file)
@@ -2,4 +2,4 @@
 loader.application=Application,hello.jar;handler.jar
 
 # main=Class,Loader
-main=HelloWorld,Application
\ No newline at end of file
+main=HelloWorldWithException,Application
\ No newline at end of file
index d0a7af85eb7f742b89460c33a48f3dafd49e2330..b917f564e01a1974242b345b98c8aa1497ed39e5 100644 (file)
@@ -3,4 +3,4 @@ loader.parent=Parent,parent.jar
 loader.child=Child,child.jar,Parent
 
 # main=Class,Loader
-main=Child,Child
\ No newline at end of file
+main=HelloWorldWithException,Child
\ No newline at end of file
index 26759346819eaa28a96ffe0bd25f7bf94f84e90f..79f793b3297a8a1985222c788e4a6ec751d92b45 100644 (file)
@@ -150,13 +150,29 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
        
        public void testConfigutationSystemProperty_pr149289 () {
                runTest("override default path using -Dorg.aspectj.weaver.loadtime.configuration");
-                               
        }
        
        public void testSimpleLTW_pr159854 () {
                runTest("simple LTW");
-                               
        }
+       
+       public void testDumpOnError_pr155033 () {
+               runTest("dump on error");
+
+               File dir = getSandboxDirectory();
+        CountingFilenameFilter cff = new CountingFilenameFilter(".txt");
+        dir.listFiles(cff);
+        assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),1,cff.getCount());
+       }
+       
+       public void testMultipleDumpOnError_pr155033 () {
+               runTest("multiple dump on error");
+
+               File dir = getSandboxDirectory();
+        CountingFilenameFilter cff = new CountingFilenameFilter(".txt");
+        dir.listFiles(cff);
+        assertEquals("Missing ajcore file in " + dir.getAbsolutePath(),2,cff.getCount());
+       }
                
        /*
         * Allow system properties to be set and restored
index 59bb176bde25b1de831eb753fde64b1e0722785b..a58fc0b459b44775f032a3cd700e8e509dce2bba 100644 (file)
     </ajc-test>
 
        <ajc-test dir="ltw" title="JDK14 LTW with XML" keywords="ltw">
-        <compile files="HelloWorld.java" options="-outjar hello.jar"/>
+        <compile files="HelloWorldWithException.java" options="-outjar hello.jar"/>
         <compile files="ExceptionHandler.aj" options="-outxml -outjar handler.jar"/>
                <ant file="ant.xml" target="JDK14 LTW with XML" verbose="true">
                <stdout>
     </ajc-test>
     
        <ajc-test dir="ltw" title="JDK14 LTW with ASPECTPATH" keywords="ltw">
-        <compile files="HelloWorld.java" options="-outjar hello.jar"/>
+        <compile files="HelloWorldWithException.java" options="-outjar hello.jar"/>
         <compile files="ExceptionHandler.aj" options="-outjar handler.jar"/>
         <ant file="ant.xml" target="JDK14 LTW with ASPECTPATH" verbose="true">
                <stdout>
     </ajc-test>
     
        <ajc-test dir="ltw" title="TestServer with HelloWorld" keywords="ltw,server">
-        <compile files="HelloWorld.java" options="-outjar hello.jar"/>
+        <compile files="HelloWorldWithException.java" options="-outjar hello.jar"/>
         <compile files="ExceptionHandler.aj" options="-outxml -outjar handler.jar"/>
         <ant file="ant-server.xml" target="TestServer with HelloWorld" verbose="true">
                <stdout>
                </stdout>
         </ant>
     </ajc-test>
-    
+<!--    
        <ajc-test dir="ltw" title="TestServer with Parent and Child" keywords="ltw,server">
         <compile files="Parent.java" options="-outjar parent.jar"/>
         <compile files="Child.java" options="-classpath parent.jar -outjar child.jar"/>
                </stdout>
         </ant>
     </ajc-test>
+-->    
+       <ajc-test dir="ltw" title="TestServer with Parent and Child" keywords="ltw,server">
+        <compile files="HelloWorldWithException.java" options="-outjar child.jar"/>
+        <compile files="ExceptionHandler.aj" options="-outxml -outjar parent.jar"/>
+        <ant file="ant-server.xml" target="TestServer with Parent and Child" verbose="true">
+               <stdout>
+               <line text="Starting ..."/>
+               <line text="Running HelloWorld"/>
+               <line text="Hello World!"/>
+               <line text="Stopping ..."/>
+               </stdout>
+        </ant>
+    </ajc-test>
 
        <ajc-test dir="ltw" title="override default path using -Dorg.aspectj.weaver.loadtime.configuration" keywords="ltw">
-        <compile files="HelloWorld.java" options="-outjar hello.jar"/>
+        <compile files="HelloWorldWithException.java" options="-outjar hello.jar"/>
         <compile files="ExceptionHandler.aj" options="-outxml -outjar handler.jar"/>
         <compile files="Tracing.aj" options="-outxml -outjar tracing.jar"/>
                <ant file="ant.xml" target="override default path using -Dorg.aspectj.weaver.loadtime.configuration" verbose="true">
     </ajc-test>       
 
        <ajc-test dir="ltw" title="simple LTW" keywords="ltw">
-        <compile files="HelloWorld.java"/>
+        <compile files="HelloWorldWithException.java"/>
         <compile files="ExceptionHandler.aj" options="-outxml"/>
                <ant file="ant.xml" target="simple LTW" verbose="true">
                <stdout>
                </stdout>
         </ant>
     </ajc-test>
+
+       <ajc-test dir="ltw" title="dump on error" keywords="ltw">
+        <compile files="HelloWorldWithException.java"/>
+        <compile files="ExceptionHandler.aj" options="-outxml"/>
+               <ant file="ant.xml" target="dump on error" verbose="true">
+               <stdout>
+               <line text="Hello World!"/>
+               </stdout>
+        </ant>
+    </ajc-test>
+
+       <ajc-test dir="bugs153/pr155033" title="multiple dump on error" keywords="ltw">
+        <compile files="Annotation.java" options="-1.5"/>
+        <compile files="MultipleDumpTest.java, Class1.java, Class2.java, Class3.java" options="-1.5"/>
+        <compile files="Aspect.aj" options="-1.5 -outxml -Xlint:ignore"/>
+<!--        
+        <run class="MultipleDumpTest" ltw="aop-multipledumponerror.xml">
+               <stdout>
+               <line text="? AbortingMessageHandler.AbortingMessageHandler()"/>
+               </stdout>
+        </run>
+-->        
+               <ant file="ant.xml" target="multiple dump on error" verbose="true">
+               <stdout>
+               <line text="? MultipleDumpTest.main()"/>
+               <line text="? Class1.main()"/>
+               <line text="? Aspect.before()"/>
+               <line text="? Class2.main()"/>
+               <line text="? Aspect.before()"/>
+               <line text="? Class3.main()"/>
+               <line text="? Aspect.before()"/>
+               </stdout>
+        </ant>
+    </ajc-test>
     
     
\ No newline at end of file