aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/testsrc
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/testsrc')
-rw-r--r--bridge/testsrc/BridgeModuleTests.java3
-rw-r--r--bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java67
2 files changed, 70 insertions, 0 deletions
diff --git a/bridge/testsrc/BridgeModuleTests.java b/bridge/testsrc/BridgeModuleTests.java
index e0049f863..23e28ea60 100644
--- a/bridge/testsrc/BridgeModuleTests.java
+++ b/bridge/testsrc/BridgeModuleTests.java
@@ -14,6 +14,8 @@
// default package
+import org.aspectj.bridge.context.CompilationAndWeavingContextTest;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -23,6 +25,7 @@ public class BridgeModuleTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(BridgeModuleTests.class.getName());
suite.addTest(org.aspectj.bridge.BridgeTests.suite());
+ suite.addTestSuite(CompilationAndWeavingContextTest.class);
return suite;
}
diff --git a/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java b/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java
new file mode 100644
index 000000000..6e8c73e22
--- /dev/null
+++ b/bridge/testsrc/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java
@@ -0,0 +1,67 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer Initial implementation
+ * ******************************************************************/
+package org.aspectj.bridge.context;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ */
+public class CompilationAndWeavingContextTest extends TestCase {
+
+ public void testEnteringPhase() {
+ CompilationAndWeavingContext.enteringPhase(1,"XYZ");
+ assertEquals("when fiddling XYZ\n",CompilationAndWeavingContext.getCurrentContext());
+ }
+
+ public void testDoubleEntry() {
+ CompilationAndWeavingContext.enteringPhase(1,"XYZ");
+ CompilationAndWeavingContext.enteringPhase(2, "ABC");
+ assertEquals("when fiddling XYZ\nwhen mucking about with ABC\n",CompilationAndWeavingContext.getCurrentContext());
+ }
+
+ public void testEntryEntryExit() {
+ CompilationAndWeavingContext.enteringPhase(1,"XYZ");
+ ContextToken ct = CompilationAndWeavingContext.enteringPhase(2, "ABC");
+ CompilationAndWeavingContext.leavingPhase(ct);
+ assertEquals("when fiddling XYZ\n",CompilationAndWeavingContext.getCurrentContext());
+ }
+
+ public void testEntryExitTop() {
+ ContextToken ct = CompilationAndWeavingContext.enteringPhase(1,"XYZ");
+ CompilationAndWeavingContext.enteringPhase(2, "ABC");
+ CompilationAndWeavingContext.leavingPhase(ct);
+ assertEquals("",CompilationAndWeavingContext.getCurrentContext());
+ }
+
+
+ protected void setUp() throws Exception {
+ CompilationAndWeavingContext.reset();
+ CompilationAndWeavingContext.registerFormatter(1, new MyContextFormatter("fiddling "));
+ CompilationAndWeavingContext.registerFormatter(2, new MyContextFormatter("mucking about with "));
+ }
+
+ private static class MyContextFormatter implements ContextFormatter {
+
+ private String prefix;
+
+ public MyContextFormatter(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String formatEntry(int phaseId, Object data) {
+ return prefix + data.toString();
+ }
+
+ }
+}