aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AfterThrowingNotWoven.java
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/AfterThrowingNotWoven.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/AfterThrowingNotWoven.java')
-rw-r--r--tests/new/AfterThrowingNotWoven.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/new/AfterThrowingNotWoven.java b/tests/new/AfterThrowingNotWoven.java
new file mode 100644
index 000000000..4b583e890
--- /dev/null
+++ b/tests/new/AfterThrowingNotWoven.java
@@ -0,0 +1,50 @@
+import org.aspectj.testing.*;
+
+public class AfterThrowingNotWoven {
+ public static void main(String[] args) {
+ try {
+ new Server().doSomething();
+ } catch (FaultException fe) {
+ Tester.event("caught-in-main");
+ }
+ Tester.checkAllEvents();
+ }
+ static {
+ Tester.expectEvent("caught");
+ Tester.expectEvent("caught-in-main");
+ }
+}
+
+class Server {
+ public void doSomething() {
+ System.out.println("Doing something.");
+ throw new FaultException();
+ }
+}
+
+class DisabledException extends RuntimeException {}
+class FaultException extends RuntimeException {}
+
+aspect FaultHandler {
+
+ private boolean Server.disabled = false;
+
+ private void reportFault() {
+ System.out.println("Failure! Please fix it.");
+ }
+
+ public static void fixServer(Server s) {
+ s.disabled = false;
+ }
+
+ pointcut service(Server s): target(s) && call(public * *(..));
+
+ before(Server s): service(s) {
+ if (s.disabled) throw new DisabledException();
+ }
+
+ after(Server s) throwing (FaultException e): service(s) {
+ s.disabled = true;
+ Tester.event("caught");
+ }
+}