]> source.dussan.org Git - aspectj.git/commitdiff
tests for 151772, 125981: incorrect scope for dec soft reporting
authoraclement <aclement>
Fri, 22 Sep 2006 14:57:29 +0000 (14:57 +0000)
committeraclement <aclement>
Fri, 22 Sep 2006 14:57:29 +0000 (14:57 +0000)
tests/bugs153/pr125981/SampleTest.java [new file with mode: 0644]
tests/bugs153/pr151772/Softener.aj [new file with mode: 0644]
tests/bugs153/pr151772/Softener2.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/pr125981/SampleTest.java b/tests/bugs153/pr125981/SampleTest.java
new file mode 100644 (file)
index 0000000..3712281
--- /dev/null
@@ -0,0 +1,28 @@
+public class SampleTest {
+    public interface ByteReadingStrategy {
+        void readBytes(java.io.InputStream str);
+    }
+
+    public ByteReadingStrategy byteReadingStrategy;
+
+    private final ByteReadingStrategy offsetBuf = new ByteReadingStrategy() {
+        public void readBytes(java.io.InputStream str) {
+            str.read();
+        }
+    };
+
+   private class NamedByteReadingStrategy {
+        public void readBytes(java.io.InputStream str) {
+            str.read();
+        }
+    };
+
+    public void foo(){}
+}
+
+aspect Soften {
+    pointcut softenedTests() : 
+        within(SampleTest+) && execution(* *(..)) && !execution(* *(..) throws Exception+);
+
+    declare soft: Exception+: softenedTests();
+}
diff --git a/tests/bugs153/pr151772/Softener.aj b/tests/bugs153/pr151772/Softener.aj
new file mode 100644 (file)
index 0000000..4e021e1
--- /dev/null
@@ -0,0 +1,22 @@
+import java.sql.SQLException;
+
+public aspect Softener {
+
+       // expect this to soften the exception thrown
+       declare soft: Throwable : execution(* *.run());
+}
+
+class SoftenInner {
+    public static void main(String args[]) {
+        new SoftenInner().foo();
+    }
+
+    public void foo()  {
+        new Runnable() {
+            public void run() {
+                                       throw new SQLException("test");
+            }
+        }.run();
+    }
+
+}
diff --git a/tests/bugs153/pr151772/Softener2.aj b/tests/bugs153/pr151772/Softener2.aj
new file mode 100644 (file)
index 0000000..5e85551
--- /dev/null
@@ -0,0 +1,23 @@
+import java.sql.SQLException;
+
+public aspect Softener2 {
+
+       // don't expect this to soften the exception thrown
+       declare soft: Throwable: execution(* SoftenInner.foo());
+               
+}
+
+class SoftenInner {
+    public static void main(String args[]) {
+        new SoftenInner().foo();
+    }
+
+    public void foo()  {
+        new Runnable() {
+            public void run() {
+                                       throw new SQLException("test");
+            }
+        }.run();
+    }
+
+}
index 7e6c95f56864cf233f358c79f0dbc88b922c1c93..0c4e59e8d437368d2fd264c3d7cfc0c3d0df50a9 100644 (file)
@@ -95,6 +95,18 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("ensure LineNumberTable correct with generics, for each and continue");
   }
   
+  public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772() {
+         runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class");
+  }
+
+  public void testDeclareSoftDoesntAllowUndeclaredExInAnonInnerClass_pr151772_2() {
+         runTest("ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2");
+  }
+
+  public void testDeclareSoftAndInnerClasses_pr125981() {
+         runTest("declare soft and inner classes");
+  }
+  
   /////////////////////////////////////////
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
index 665c73c0f5ae54e34003c8403700c95fcc5e7894..451bf3a8097e18cdf03924b4e4a20dbab5b14e8e 100644 (file)
         </ant>
     </ajc-test>
 
+    <ajc-test dir="bugs153/pr151772" title="ensure declare soft doesn't allow undeclared exception in anonymous inner class">
+      <compile files="Softener.aj"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs153/pr151772" title="ensure declare soft doesn't allow undeclared exception in anonymous inner class - 2">
+      <compile files="Softener2.aj">
+               <message kind="error" line="18" text="Unhandled exception type SQLException"/>
+         </compile>    
+    </ajc-test>
+
+    <ajc-test dir="bugs153/pr125981" title="declare soft and inner classes">
+      <compile files="SampleTest.java"/>
+    </ajc-test>
+
 </suite>
\ No newline at end of file