diff options
author | aclement <aclement> | 2006-06-23 12:18:06 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-06-23 12:18:06 +0000 |
commit | 4a4240e2df9fd9a8aff80e7d92595ba2265286f8 (patch) | |
tree | e0d1832e3d956e537f3cef8edbb2e1486913189f /tests/multiIncremental | |
parent | 7f1b18423b266c344e3b262f9b59a6216c551b88 (diff) | |
download | aspectj-4a4240e2df9fd9a8aff80e7d92595ba2265286f8.tar.gz aspectj-4a4240e2df9fd9a8aff80e7d92595ba2265286f8.zip |
testcode for 148285
Diffstat (limited to 'tests/multiIncremental')
-rw-r--r-- | tests/multiIncremental/PR148285/base/Main.java | 48 | ||||
-rw-r--r-- | tests/multiIncremental/PR148285/inc1/Main.java | 29 | ||||
-rw-r--r-- | tests/multiIncremental/PR148285/inc1/Monitor.java | 23 |
3 files changed, 100 insertions, 0 deletions
diff --git a/tests/multiIncremental/PR148285/base/Main.java b/tests/multiIncremental/PR148285/base/Main.java new file mode 100644 index 000000000..ad0202ad0 --- /dev/null +++ b/tests/multiIncremental/PR148285/base/Main.java @@ -0,0 +1,48 @@ +package test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; + +public class Main { + public static void main(String[] args) { + new Main().foo(); + } + + @PerformenceMonitor(expected=1000) + public void foo() { + + } +} + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface PerformenceMonitor { + public int expected(); +} + +@Aspect +class Monitor { + @Pointcut("execution(@PerformenceMonitor * *(..)) && @annotation(monitoringAnnot)") + public void monitored(PerformenceMonitor monitoringAnnot) {} + + @Around("monitored(monitoringAnnot)") + public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformenceMonitor monitoringAnnot) { + long start = System.nanoTime(); + Object ret = pjp.proceed(); + long end = System.nanoTime(); + + if(end - start > monitoringAnnot.expected()) { + System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t" + + "Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start)); + } + return ret; + } + +} diff --git a/tests/multiIncremental/PR148285/inc1/Main.java b/tests/multiIncremental/PR148285/inc1/Main.java new file mode 100644 index 000000000..683d4a408 --- /dev/null +++ b/tests/multiIncremental/PR148285/inc1/Main.java @@ -0,0 +1,29 @@ +package test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; + +public class Main { + public static void main(String[] args) { + new Main().foo(); + } + + @PerformenceMonitor(expected=1000) + public void foo() { + + } +} + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +@interface PerformenceMonitor { + public int expected(); +} + diff --git a/tests/multiIncremental/PR148285/inc1/Monitor.java b/tests/multiIncremental/PR148285/inc1/Monitor.java new file mode 100644 index 000000000..a222a93d4 --- /dev/null +++ b/tests/multiIncremental/PR148285/inc1/Monitor.java @@ -0,0 +1,23 @@ +package test; + +import org.aspectj.lang.annotation.*; + +@Aspect +class Monitor { + @Pointcut("execution(@PerformenceMonitor * *(..)) && @annotation(monitoringAnnot)") + public void monitored(PerformenceMonitor monitoringAnnot) {} + + @Around("monitored(monitoringAnnot)") + public Object flagExpectationMismatch(ProceedingJoinPoint pjp, PerformenceMonitor monitoringAnnot) { + long start = System.nanoTime(); + Object ret = pjp.proceed(); + long end = System.nanoTime(); + + if(end - start > monitoringAnnot.expected()) { + System.out.println("Method " + pjp.getSignature().toShortString() + " took longer than expected\n\t" + +"Max expected = " + monitoringAnnot.expected() + ", actual = " + (end-start)); + } + return ret; + } + +} |