aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/PR520.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/PR520.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/PR520.java')
-rw-r--r--tests/new/PR520.java101
1 files changed, 101 insertions, 0 deletions
diff --git a/tests/new/PR520.java b/tests/new/PR520.java
new file mode 100644
index 000000000..641d00cdc
--- /dev/null
+++ b/tests/new/PR520.java
@@ -0,0 +1,101 @@
+import org.aspectj.testing.Tester;
+
+/** @testcase for PR520 - NAB? */
+public class PR520 {
+ public static void main(String[] args) {
+ PR520 me = new PR520();
+ me.testValidThreeArgumentCall() ;
+ me.testValidThreeArgumentCallTwo();
+ Tester.checkAllEvents();
+ }
+
+ public void testValidThreeArgumentCall() {
+ for (int i = 0; i < Logger.PRIORITIES.length; i++) {
+ Logger.log(Logger.PRIORITIES[i],
+ Logger.API, "context=word_" + i);
+ }
+ }
+
+ public void testValidThreeArgumentCallTwo() {
+ Logger.log( Logger.EXCEPTION, Logger.API, "context=EXCEPTION" );
+ Logger.log( Logger.DEBUG, Logger.API, "context=DEBUG" );
+ Logger.log( Logger.DEBUG, Logger.API, "context=DEBUG-Exception",
+ new Exception( "bad bad boy" ) );
+ }
+ public static void signal(String s, String context) {
+ signal(context + ": " + s);
+ }
+ public static void signal(String s) {
+ System.err.println(s);
+ Tester.event(s);
+ }
+ private static final String[] EXPECTED;
+ static {
+ EXPECTED = new String[]
+ { "context=word_0"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=word_1"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=word_2"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=word_3"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=word_4"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=EXCEPTION"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=DEBUG"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String))"
+ , "context=DEBUG-Exception"
+ , "call(void Logger.log(Logger.ChromePriority, Unknown, String, Exception))"
+ };
+ Tester.expectEventsInString(EXPECTED);
+ }
+}
+
+class Unknown { }
+class Logger {
+ static class ChromePriority { }
+ public static final ChromePriority DEBUG;
+ public static final ChromePriority EXCEPTION;
+ public static final ChromePriority FATAL;
+ public static final ChromePriority INFO;
+ public static final ChromePriority WARN;
+ public static final Unknown API;
+ public static final Logger.ChromePriority[] PRIORITIES;
+
+ static {
+ API = new Unknown();
+ PRIORITIES = new Logger.ChromePriority[ 5 ];
+ DEBUG = new ChromePriority();
+ EXCEPTION = new ChromePriority();
+ FATAL = new ChromePriority();
+ INFO = new ChromePriority();
+ WARN = new ChromePriority();
+ PRIORITIES[ 0 ] = Logger.DEBUG;
+ PRIORITIES[ 1 ] = Logger.EXCEPTION;
+ PRIORITIES[ 2 ] = Logger.FATAL;
+ PRIORITIES[ 3 ] = Logger.INFO;
+ PRIORITIES[ 4 ] = Logger.WARN;
+ }
+ public static void log(ChromePriority p, Unknown q,
+ String message, Exception e) {
+ PR520.signal(message);
+ }
+ public static void log(ChromePriority p, Unknown q,
+ String message) {
+ PR520.signal(message);
+ }
+}
+
+aspect LoggerCategoryCreator {
+
+ pointcut allLoggingCalls()
+ : call(public void Logger.log(..));
+
+ void around(): allLoggingCalls() {
+ // s.b. no proceed() (i.e., replace) but testing invocation
+ proceed();
+ PR520.signal(thisJoinPointStaticPart.toString());
+ }
+}