]> source.dussan.org Git - aspectj.git/commitdiff
Testcases for 145442 "The line number is missing for an advised class."
authormwebster <mwebster>
Tue, 11 Jul 2006 12:57:44 +0000 (12:57 +0000)
committermwebster <mwebster>
Tue, 11 Jul 2006 12:57:44 +0000 (12:57 +0000)
tests/bugs153/pr145442/hello/HelloWorld.java [new file with mode: 0644]
tests/bugs153/pr145442/hello/ThrowExceptionAfter.aj [new file with mode: 0644]
tests/bugs153/pr145442/hello/ThrowExceptionAround.aj [new file with mode: 0644]
tests/bugs153/pr145442/hello/ThrowExceptionBefore.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml

diff --git a/tests/bugs153/pr145442/hello/HelloWorld.java b/tests/bugs153/pr145442/hello/HelloWorld.java
new file mode 100644 (file)
index 0000000..a2bb9b0
--- /dev/null
@@ -0,0 +1,44 @@
+package hello;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+
+public class HelloWorld {
+
+       public void println () {
+               System.out.println("Hello World!");
+       }
+
+       private void testStackTrace () throws IOException {
+               try {
+                       println();
+               }
+               catch (Exception ex) {
+                       printRelevantStackEntries(ex,getClass().getName());
+               }
+       }
+       
+       private static void printRelevantStackEntries (Exception ex, String className) throws IOException {
+               ByteArrayOutputStream baos = new ByteArrayOutputStream();
+               PrintStream ps = new PrintStream(baos);
+               ex.printStackTrace(ps);
+               ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+               BufferedReader br = new BufferedReader(new InputStreamReader(bais));
+               String entry;
+               while ((entry = br.readLine()) != null) {
+                       if (entry.indexOf(className) != -1) {
+                               System.err.println(entry);
+                       }
+               }
+       }
+       
+       public static void main(String[] args) throws Exception {
+               new HelloWorld().testStackTrace();
+       }
+
+}
diff --git a/tests/bugs153/pr145442/hello/ThrowExceptionAfter.aj b/tests/bugs153/pr145442/hello/ThrowExceptionAfter.aj
new file mode 100644 (file)
index 0000000..f9d58fb
--- /dev/null
@@ -0,0 +1,8 @@
+package hello;
+
+public aspect ThrowExceptionAfter {
+
+       after () : execution(public void println()) {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/tests/bugs153/pr145442/hello/ThrowExceptionAround.aj b/tests/bugs153/pr145442/hello/ThrowExceptionAround.aj
new file mode 100644 (file)
index 0000000..a30cf0e
--- /dev/null
@@ -0,0 +1,8 @@
+package hello;
+
+public aspect ThrowExceptionAround {
+
+       void around () : execution(public void println()) {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/tests/bugs153/pr145442/hello/ThrowExceptionBefore.aj b/tests/bugs153/pr145442/hello/ThrowExceptionBefore.aj
new file mode 100644 (file)
index 0000000..f4dc9cb
--- /dev/null
@@ -0,0 +1,8 @@
+package hello;
+
+public aspect ThrowExceptionBefore {
+
+       before () : execution(public void println()) {
+               throw new UnsupportedOperationException();
+       }
+}
index 9033d22809ee3a780f95755cc3c1bed26e78ceaf..4878bb045d9033b03cfdb15d7ba636334bbefe8a 100644 (file)
@@ -19,7 +19,9 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
-  // public void testMissingLineNumbersInStacktrace_pr145442() { runTest("missing line numbers in stacktrace");}
+   public void testMissingLineNumbersInStacktraceBefore_pr145442() { runTest("missing line numbers in stacktrace before");}
+   public void testMissingLineNumbersInStacktraceAfter_pr145442() { runTest("missing line numbers in stacktrace after");}
+   public void testMissingLineNumbersInStacktraceAround_pr145442() { runTest("missing line numbers in stacktrace around");}
   // public void testArgnamesAndJavac_pr148381() { runTest("argNames and javac");}
   // public void testCFlowXMLAspectLTW_pr149096() { runTest("cflow xml concrete aspect"); }
   // public void testAmbiguousBinding_pr121805() { runTest("ambiguous binding");}
index 89da04f0153c883f66070261b673b9235c2971de..a8b4c6034da9da7c216f4b8724cf50db1a714396 100644 (file)
      <compile files="Complex.java"/>
     </ajc-test> 
     
-       <ajc-test dir="bugs153/pr145442" title="missing line numbers in stacktrace">
-     <compile files="MissingLineNumbers.java"/>
-     <run class="MissingLineNumbers"/>
+       <ajc-test dir="bugs153/pr145442" title="missing line numbers in stacktrace before">
+     <compile files="hello/HelloWorld.java hello/ThrowExceptionBefore.aj"/>
+     <run class="hello.HelloWorld">
+               <stderr>
+<!--           
+               <line text="hello.HelloWorld.println(HelloWorld.java:13)"/>
+-->            
+               <line text="hello.HelloWorld.println(HelloWorld.java)"/>
+               <line text="hello.HelloWorld.testStackTrace(HelloWorld.java:19)"/>
+               <line text="hello.HelloWorld.main(HelloWorld.java:41)"/>
+               </stderr>
+     </run>
+    </ajc-test> 
+    
+       <ajc-test dir="bugs153/pr145442" title="missing line numbers in stacktrace after">
+     <compile files="hello/HelloWorld.java hello/ThrowExceptionAfter.aj"/>
+     <run class="hello.HelloWorld">
+               <stderr>
+               <line text="hello.HelloWorld.println(HelloWorld.java:15)"/>
+               <line text="hello.HelloWorld.testStackTrace(HelloWorld.java:19)"/>
+               <line text="hello.HelloWorld.main(HelloWorld.java:41)"/>
+               </stderr>
+     </run>
+    </ajc-test> 
+    
+       <ajc-test dir="bugs153/pr145442" title="missing line numbers in stacktrace around">
+     <compile files="hello/HelloWorld.java hello/ThrowExceptionAround.aj" options="-XnoInline"/>
+     <run class="hello.HelloWorld">
+               <stderr>
+<!--           
+               <line text="hello.HelloWorld.println(HelloWorld.java:13)"/>
+-->            
+               <line text="hello.HelloWorld.println(HelloWorld.java:1)"/>
+               <line text="hello.HelloWorld.testStackTrace(HelloWorld.java:19)"/>
+               <line text="hello.HelloWorld.main(HelloWorld.java:41)"/>
+               </stderr>
+     </run>
     </ajc-test> 
     
        <ajc-test dir="bugs153/pr149322" title="can't find type on interface call 1">