aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/src
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/src')
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/AbortException.java (renamed from bridge/src/org/aspectj/bridge/AbortException.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/Constants.java (renamed from bridge/src/org/aspectj/bridge/Constants.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/CountingMessageHandler.java (renamed from bridge/src/org/aspectj/bridge/CountingMessageHandler.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/ICommand.java (renamed from bridge/src/org/aspectj/bridge/ICommand.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/ILifecycleAware.java (renamed from bridge/src/org/aspectj/bridge/ILifecycleAware.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/IMessage.java (renamed from bridge/src/org/aspectj/bridge/IMessage.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/IMessageContext.java (renamed from bridge/src/org/aspectj/bridge/IMessageContext.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/IMessageHandler.java (renamed from bridge/src/org/aspectj/bridge/IMessageHandler.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/IMessageHolder.java (renamed from bridge/src/org/aspectj/bridge/IMessageHolder.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/IProgressListener.java (renamed from bridge/src/org/aspectj/bridge/IProgressListener.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/ISourceLocation.java (renamed from bridge/src/org/aspectj/bridge/ISourceLocation.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/Message.java (renamed from bridge/src/org/aspectj/bridge/Message.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/MessageHandler.java (renamed from bridge/src/org/aspectj/bridge/MessageHandler.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/MessageUtil.java (renamed from bridge/src/org/aspectj/bridge/MessageUtil.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/MessageWriter.java (renamed from bridge/src/org/aspectj/bridge/MessageWriter.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java (renamed from bridge/src/org/aspectj/bridge/ReflectionFactory.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/SourceLocation.java (renamed from bridge/src/org/aspectj/bridge/SourceLocation.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/Version.java (renamed from bridge/src/org/aspectj/bridge/Version.java)2
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java (renamed from bridge/src/org/aspectj/bridge/WeaveMessage.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java (renamed from bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/context/ContextFormatter.java (renamed from bridge/src/org/aspectj/bridge/context/ContextFormatter.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/context/ContextToken.java (renamed from bridge/src/org/aspectj/bridge/context/ContextToken.java)0
-rw-r--r--bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java (renamed from bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java)0
-rw-r--r--bridge/src/test/java/org/aspectj/bridge/CountingMessageHandlerTest.java82
-rw-r--r--bridge/src/test/java/org/aspectj/bridge/MessageTest.java321
-rw-r--r--bridge/src/test/java/org/aspectj/bridge/VersionTest.java60
-rw-r--r--bridge/src/test/java/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java67
27 files changed, 531 insertions, 1 deletions
diff --git a/bridge/src/org/aspectj/bridge/AbortException.java b/bridge/src/main/java/org/aspectj/bridge/AbortException.java
index acde7cd28..acde7cd28 100644
--- a/bridge/src/org/aspectj/bridge/AbortException.java
+++ b/bridge/src/main/java/org/aspectj/bridge/AbortException.java
diff --git a/bridge/src/org/aspectj/bridge/Constants.java b/bridge/src/main/java/org/aspectj/bridge/Constants.java
index 31f239678..31f239678 100644
--- a/bridge/src/org/aspectj/bridge/Constants.java
+++ b/bridge/src/main/java/org/aspectj/bridge/Constants.java
diff --git a/bridge/src/org/aspectj/bridge/CountingMessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/CountingMessageHandler.java
index 4ce550876..4ce550876 100644
--- a/bridge/src/org/aspectj/bridge/CountingMessageHandler.java
+++ b/bridge/src/main/java/org/aspectj/bridge/CountingMessageHandler.java
diff --git a/bridge/src/org/aspectj/bridge/ICommand.java b/bridge/src/main/java/org/aspectj/bridge/ICommand.java
index b77d58e59..b77d58e59 100644
--- a/bridge/src/org/aspectj/bridge/ICommand.java
+++ b/bridge/src/main/java/org/aspectj/bridge/ICommand.java
diff --git a/bridge/src/org/aspectj/bridge/ILifecycleAware.java b/bridge/src/main/java/org/aspectj/bridge/ILifecycleAware.java
index c5ac9b149..c5ac9b149 100644
--- a/bridge/src/org/aspectj/bridge/ILifecycleAware.java
+++ b/bridge/src/main/java/org/aspectj/bridge/ILifecycleAware.java
diff --git a/bridge/src/org/aspectj/bridge/IMessage.java b/bridge/src/main/java/org/aspectj/bridge/IMessage.java
index a32a631e6..a32a631e6 100644
--- a/bridge/src/org/aspectj/bridge/IMessage.java
+++ b/bridge/src/main/java/org/aspectj/bridge/IMessage.java
diff --git a/bridge/src/org/aspectj/bridge/IMessageContext.java b/bridge/src/main/java/org/aspectj/bridge/IMessageContext.java
index 2f5512a1d..2f5512a1d 100644
--- a/bridge/src/org/aspectj/bridge/IMessageContext.java
+++ b/bridge/src/main/java/org/aspectj/bridge/IMessageContext.java
diff --git a/bridge/src/org/aspectj/bridge/IMessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/IMessageHandler.java
index 6dcdfeafb..6dcdfeafb 100644
--- a/bridge/src/org/aspectj/bridge/IMessageHandler.java
+++ b/bridge/src/main/java/org/aspectj/bridge/IMessageHandler.java
diff --git a/bridge/src/org/aspectj/bridge/IMessageHolder.java b/bridge/src/main/java/org/aspectj/bridge/IMessageHolder.java
index fdf2a6779..fdf2a6779 100644
--- a/bridge/src/org/aspectj/bridge/IMessageHolder.java
+++ b/bridge/src/main/java/org/aspectj/bridge/IMessageHolder.java
diff --git a/bridge/src/org/aspectj/bridge/IProgressListener.java b/bridge/src/main/java/org/aspectj/bridge/IProgressListener.java
index 4326f7263..4326f7263 100644
--- a/bridge/src/org/aspectj/bridge/IProgressListener.java
+++ b/bridge/src/main/java/org/aspectj/bridge/IProgressListener.java
diff --git a/bridge/src/org/aspectj/bridge/ISourceLocation.java b/bridge/src/main/java/org/aspectj/bridge/ISourceLocation.java
index 7ad9423c2..7ad9423c2 100644
--- a/bridge/src/org/aspectj/bridge/ISourceLocation.java
+++ b/bridge/src/main/java/org/aspectj/bridge/ISourceLocation.java
diff --git a/bridge/src/org/aspectj/bridge/Message.java b/bridge/src/main/java/org/aspectj/bridge/Message.java
index a4f17072b..a4f17072b 100644
--- a/bridge/src/org/aspectj/bridge/Message.java
+++ b/bridge/src/main/java/org/aspectj/bridge/Message.java
diff --git a/bridge/src/org/aspectj/bridge/MessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java
index 6fd8539cc..6fd8539cc 100644
--- a/bridge/src/org/aspectj/bridge/MessageHandler.java
+++ b/bridge/src/main/java/org/aspectj/bridge/MessageHandler.java
diff --git a/bridge/src/org/aspectj/bridge/MessageUtil.java b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
index 6d85ea6f9..6d85ea6f9 100644
--- a/bridge/src/org/aspectj/bridge/MessageUtil.java
+++ b/bridge/src/main/java/org/aspectj/bridge/MessageUtil.java
diff --git a/bridge/src/org/aspectj/bridge/MessageWriter.java b/bridge/src/main/java/org/aspectj/bridge/MessageWriter.java
index 3fbeb91b0..3fbeb91b0 100644
--- a/bridge/src/org/aspectj/bridge/MessageWriter.java
+++ b/bridge/src/main/java/org/aspectj/bridge/MessageWriter.java
diff --git a/bridge/src/org/aspectj/bridge/ReflectionFactory.java b/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java
index 8eb65b3a0..8eb65b3a0 100644
--- a/bridge/src/org/aspectj/bridge/ReflectionFactory.java
+++ b/bridge/src/main/java/org/aspectj/bridge/ReflectionFactory.java
diff --git a/bridge/src/org/aspectj/bridge/SourceLocation.java b/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java
index 739dd52ab..739dd52ab 100644
--- a/bridge/src/org/aspectj/bridge/SourceLocation.java
+++ b/bridge/src/main/java/org/aspectj/bridge/SourceLocation.java
diff --git a/bridge/src/org/aspectj/bridge/Version.java b/bridge/src/main/java/org/aspectj/bridge/Version.java
index 835127c75..367efaf73 100644
--- a/bridge/src/org/aspectj/bridge/Version.java
+++ b/bridge/src/main/java/org/aspectj/bridge/Version.java
@@ -37,7 +37,7 @@ public class Version {
* Time text set by build script using SIMPLE_DATE_FORMAT.
* (if DEVELOPMENT version, invalid)
*/
- public static final String time_text = "Friday Nov 18, 2016 at 16:34:52 GMT";
+ public static final String time_text = "Tuesday Jan 15, 2019 at 00:53:54 GMT";
/**
* time in seconds-since-... format, used by programmatic clients.
diff --git a/bridge/src/org/aspectj/bridge/WeaveMessage.java b/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java
index 2c697a811..2c697a811 100644
--- a/bridge/src/org/aspectj/bridge/WeaveMessage.java
+++ b/bridge/src/main/java/org/aspectj/bridge/WeaveMessage.java
diff --git a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java
index 28a414acd..28a414acd 100644
--- a/bridge/src/org/aspectj/bridge/context/CompilationAndWeavingContext.java
+++ b/bridge/src/main/java/org/aspectj/bridge/context/CompilationAndWeavingContext.java
diff --git a/bridge/src/org/aspectj/bridge/context/ContextFormatter.java b/bridge/src/main/java/org/aspectj/bridge/context/ContextFormatter.java
index 9f1b591d7..9f1b591d7 100644
--- a/bridge/src/org/aspectj/bridge/context/ContextFormatter.java
+++ b/bridge/src/main/java/org/aspectj/bridge/context/ContextFormatter.java
diff --git a/bridge/src/org/aspectj/bridge/context/ContextToken.java b/bridge/src/main/java/org/aspectj/bridge/context/ContextToken.java
index 2415fa72e..2415fa72e 100644
--- a/bridge/src/org/aspectj/bridge/context/ContextToken.java
+++ b/bridge/src/main/java/org/aspectj/bridge/context/ContextToken.java
diff --git a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java b/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java
index c54ff6789..c54ff6789 100644
--- a/bridge/src/org/aspectj/bridge/context/PinpointingMessageHandler.java
+++ b/bridge/src/main/java/org/aspectj/bridge/context/PinpointingMessageHandler.java
diff --git a/bridge/src/test/java/org/aspectj/bridge/CountingMessageHandlerTest.java b/bridge/src/test/java/org/aspectj/bridge/CountingMessageHandlerTest.java
new file mode 100644
index 000000000..dc357a8b1
--- /dev/null
+++ b/bridge/src/test/java/org/aspectj/bridge/CountingMessageHandlerTest.java
@@ -0,0 +1,82 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.bridge;
+
+
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+/**
+ *
+ */
+public class CountingMessageHandlerTest extends TestCase {
+
+ private static final String ME
+ = "org.aspectj.bridge.CountingMessageHandlerTest"; // XXX
+
+ /** @param args ignored */
+ public static void main(String[] args) {
+ TestRunner.main(new String[] {ME});
+ }
+
+ /**
+ * Constructor for MessageTest.
+ * @param name
+ */
+ public CountingMessageHandlerTest(String name) {
+ super(name);
+ }
+
+ public void testSimpleWrapping() {
+ MessageHandler m = new MessageHandler();
+ CountingMessageHandler me = new CountingMessageHandler(m);
+ checkCountingMessageHandler(me);
+ }
+
+ public void testCounterWrapping() {
+ MessageHandler m = new MessageHandler();
+ CountingMessageHandler first = new CountingMessageHandler(m);
+ CountingMessageHandler me = new CountingMessageHandler(first);
+ checkCountingMessageHandler(me);
+ }
+
+ void checkCountingMessageHandler(CountingMessageHandler me) {
+ MessageUtil.warn(me, "warn 1");
+ assertTrue(!me.hasErrors());
+ assertEquals(0 , me.numMessages(IMessage.ERROR, false));
+ assertEquals(1 , me.numMessages(IMessage.WARNING, false));
+ assertEquals(0 , me.numMessages(IMessage.INFO, false));
+ assertEquals(0 , me.numMessages(IMessage.ERROR, true));
+ assertEquals(1 , me.numMessages(IMessage.WARNING, true));
+ assertEquals(1 , me.numMessages(IMessage.INFO, true));
+
+ MessageUtil.info(me, "info 1");
+ assertTrue(!me.hasErrors());
+ assertEquals(0 , me.numMessages(IMessage.ERROR, false));
+ assertEquals(1 , me.numMessages(IMessage.WARNING, false));
+ assertEquals(1 , me.numMessages(IMessage.INFO, false));
+ assertEquals(0 , me.numMessages(IMessage.ERROR, true));
+ assertEquals(1 , me.numMessages(IMessage.WARNING, true));
+ assertEquals(2 , me.numMessages(IMessage.INFO, true));
+
+ MessageUtil.error(me, "error 1");
+ assertTrue(me.hasErrors());
+ assertEquals(1 , me.numMessages(IMessage.ERROR, false));
+ assertEquals(1 , me.numMessages(IMessage.WARNING, false));
+ assertEquals(1 , me.numMessages(IMessage.INFO, false));
+ assertEquals(1 , me.numMessages(IMessage.ERROR, true));
+ assertEquals(2 , me.numMessages(IMessage.WARNING, true));
+ assertEquals(3 , me.numMessages(IMessage.INFO, true));
+ }
+}
diff --git a/bridge/src/test/java/org/aspectj/bridge/MessageTest.java b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java
new file mode 100644
index 000000000..be30c48ba
--- /dev/null
+++ b/bridge/src/test/java/org/aspectj/bridge/MessageTest.java
@@ -0,0 +1,321 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.bridge;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+/**
+ *
+ */
+public class MessageTest extends TestCase {
+
+ private static final String ME
+ = "org.aspectj.bridge.MessageTest"; // XXX
+
+ /** @param args ignored */
+ public static void main(String[] args) {
+ TestRunner.main(new String[] {ME});
+ }
+
+ /**
+ * Constructor for MessageTest.
+ * @param name
+ */
+ public MessageTest(String name) {
+ super(name);
+ }
+
+ <T> void checkListOrder(List<T> list, Comparator<T> c) { // XXX util
+ assertNotNull(list);
+ assertNotNull(c);
+ ListIterator<T> it = list.listIterator();
+ T last = null;
+ T current = null;
+ while (it.hasNext()) {
+ current = it.next();
+ if (null != last) {
+ int i = c.compare(last, current);
+ if (i > 0) {
+ assertTrue( last + " > " + current + " (" + i + ")", false);
+ }
+ }
+ last = current;
+ }
+ }
+
+ public void testKindOrder() {
+ // first briefly validate the checker
+ checkListOrder(Arrays.asList(new String[] { "a", "b", "C" }),
+ String.CASE_INSENSITIVE_ORDER);
+ checkListOrder(IMessage.KINDS, IMessage.Kind.COMPARATOR);
+ }
+
+ public void testKind_isSameOrLessThan() {
+ IMessage.Kind last;
+ IMessage.Kind next = null;
+ for (Iterator<IMessage.Kind> iter = IMessage.KINDS.iterator(); iter.hasNext();) {
+ last = next;
+ next = iter.next();
+ if (null == last) {
+ continue;
+ }
+ String label = "last: " + last + " next: " + next;
+ assertTrue(label, !next.isSameOrLessThan(null));
+ assertTrue(label, !next.isSameOrLessThan(last));
+ assertTrue(label, last.isSameOrLessThan(next));
+ assertTrue(label, next.isSameOrLessThan(next));
+ }
+ }
+
+ public void testMessageHandler() {
+ boolean handleMessageResult = true;
+ checkEmptyMessageHolder(new MessageHandler(handleMessageResult), handleMessageResult);
+ handleMessageResult = false;
+ checkEmptyMessageHolder(new MessageHandler(handleMessageResult), handleMessageResult);
+ }
+
+ public void checkEmptyMessageHolder(
+ IMessageHolder h,
+ final boolean handleMessageResult) {
+ // { INFO, DEBUG, WARNING, ERROR, FAIL, ABORT }));
+ assertNotNull(h);
+ assertTrue(!h.hasAnyMessage(null, true));
+ assertTrue(!h.hasAnyMessage(null, false));
+ assertTrue(!h.hasAnyMessage(IMessage.INFO, true));
+ assertTrue(!h.hasAnyMessage(IMessage.INFO, false));
+
+ assertTrue(handleMessageResult == h.handleMessage(make("error 1", IMessage.ERROR)));
+ assertTrue(handleMessageResult == h.handleMessage(make("error 2", IMessage.ERROR)));
+ assertTrue(handleMessageResult == h.handleMessage(make("fail 1", IMessage.FAIL)));
+ assertTrue(handleMessageResult == h.handleMessage(make("fail 2", IMessage.FAIL)));
+ assertTrue(handleMessageResult == h.handleMessage(make("debug 1", IMessage.DEBUG)));
+ assertTrue(handleMessageResult == h.handleMessage(make("debug 2", IMessage.DEBUG)));
+
+ assertTrue(h.hasAnyMessage(null, true));
+ assertTrue(h.hasAnyMessage(null, false));
+ assertTrue(h.hasAnyMessage(IMessage.ERROR, true));
+ assertTrue(h.hasAnyMessage(IMessage.ERROR, false));
+ assertTrue(h.hasAnyMessage(IMessage.FAIL, true));
+ assertTrue(h.hasAnyMessage(IMessage.FAIL, false));
+ assertTrue(h.hasAnyMessage(IMessage.DEBUG, true));
+ assertTrue(h.hasAnyMessage(IMessage.DEBUG, false));
+
+ assertTrue(!h.hasAnyMessage(IMessage.INFO, IMessageHolder.EQUAL));
+ assertTrue(!h.hasAnyMessage(IMessage.WARNING, IMessageHolder.EQUAL));
+ assertTrue(!h.hasAnyMessage(IMessage.ABORT, IMessageHolder.EQUAL));
+ assertTrue(h.hasAnyMessage(IMessage.INFO, IMessageHolder.ORGREATER));
+ assertTrue(h.hasAnyMessage(IMessage.WARNING, IMessageHolder.ORGREATER));
+ assertTrue(!h.hasAnyMessage(IMessage.ABORT, IMessageHolder.ORGREATER));
+
+ assertTrue(0 == h.numMessages(IMessage.INFO, IMessageHolder.EQUAL));
+ assertTrue(0 == h.numMessages(IMessage.WARNING, IMessageHolder.EQUAL));
+ assertTrue(0 == h.numMessages(IMessage.ABORT, IMessageHolder.EQUAL));
+
+ assertTrue(6 == h.numMessages(null, IMessageHolder.ORGREATER));
+ assertTrue(6 == h.numMessages(null, IMessageHolder.EQUAL));
+ assertTrue(6 == h.numMessages(IMessage.INFO, IMessageHolder.ORGREATER));
+ assertTrue(6 == h.numMessages(IMessage.DEBUG, IMessageHolder.ORGREATER));
+ assertTrue(4 == h.numMessages(IMessage.WARNING, IMessageHolder.ORGREATER));
+ assertTrue(4 == h.numMessages(IMessage.ERROR, IMessageHolder.ORGREATER));
+ assertTrue(2 == h.numMessages(IMessage.FAIL, IMessageHolder.ORGREATER));
+ assertTrue(0 == h.numMessages(IMessage.ABORT, IMessageHolder.ORGREATER));
+
+ }
+
+ public void testMessage() {
+ String input = "input";
+ Throwable thrown = null;
+ ISourceLocation sl = null;
+ Class<?> exClass = null;
+ String descriptor = "Message"; // for make(...)
+ IMessage.Kind kind = IMessage.INFO;
+
+ // -- kind variants
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ kind = IMessage.WARNING;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ kind = IMessage.ERROR;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ kind = IMessage.DEBUG;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ kind = IMessage.FAIL;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+
+ // -- throwable
+ kind = IMessage.FAIL;
+ thrown = new AbortException();
+ input = null;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+
+ // -- source location
+ kind = IMessage.WARNING;
+ thrown = null;
+ input = "type not found";
+ File f = new File("some/file.java"); // XXX unchecked
+ sl = new SourceLocation(f, 0, 0, 0);
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ sl = new SourceLocation(f, 1, 1, 0);
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+
+ // -- input error tests - null kind, null input (factory-dependent)
+ kind = null;
+ exClass = IllegalArgumentException.class;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ input = null;
+ kind = IMessage.INFO;
+ roundTrip(input, kind, thrown, sl, descriptor, exClass);
+ }
+
+ protected IMessage make(String message, IMessage.Kind kind) {
+ return new Message(message, kind, null, null);
+ }
+
+ /** make a Message per descriptor and input */
+ protected IMessage make(String input, IMessage.Kind kind,
+ Throwable thrown, ISourceLocation sourceLocation,
+ String descriptor) { // XXX ignored for now
+ return new Message(input, kind, thrown, sourceLocation);
+ }
+
+ /**
+ * Simple round-trip on the message
+ */
+ protected void roundTrip(String input, IMessage.Kind kind,
+ Throwable thrown, ISourceLocation sourceLocation,
+ String descriptor, Class<?> exClass) {
+ try {
+ IMessage m = make(input, kind, thrown, sourceLocation, descriptor);
+ if ((null == input) && (null != thrown)) {
+ input = thrown.getMessage();
+ }
+ roundTripCheck(m, input, kind, thrown, sourceLocation);
+ } catch (AssertionFailedError x) {
+ throw x;
+ } catch (Throwable t) {
+ assertTrue(null != exClass);
+ assertTrue(exClass.isAssignableFrom(t.getClass()));
+ }
+ }
+
+ protected void roundTripCheck(IMessage message, String input, IMessage.Kind kind,
+ Throwable thrown, ISourceLocation sourceLocation) {
+ IMessage m = message;
+ assertTrue("not null", null != m);
+ assertEquals(input, m.getMessage());
+ assertTrue(""+kind, kind == m.getKind());
+ assertTrue(""+thrown, equals(thrown, m.getThrown()));
+ assertTrue(""+sourceLocation,
+ equals(sourceLocation, m.getSourceLocation()));
+ String err = new KindTest().testKindSet(message, kind);
+ if (null != err) {
+ assertTrue(err, false);
+ }
+ }
+
+ protected static boolean equals(Object one, Object two) {
+ if (null == one) {
+ return (null == two);
+ } else if (null == two) {
+ return false;
+ } else {
+ return one.equals(two);
+ }
+ }
+}
+
+/** test correlation between message and enclosed kind */
+class KindTest {
+ /** order tracked in checkKindMethods() */
+ static final IMessage.Kind[] KINDS = new IMessage.Kind[]
+ { IMessage.ABORT, IMessage.DEBUG, IMessage.ERROR,
+ IMessage.INFO, IMessage.WARNING, IMessage.FAIL };
+
+ static final List<IMessage.Kind> KINDLIST = Arrays.asList(KINDS);
+
+ /** used to clear instance BitSet */
+ static final BitSet UNSET = new BitSet(KINDS.length);
+
+
+ final BitSet expected = new BitSet(KINDS.length);
+ IMessage.Kind kind = IMessage.INFO;
+
+ /** @return error if failed */
+ public String testKindSet(IMessage m, IMessage.Kind newKind) {
+ IMessage.Kind oldKind = this.kind;
+ String result = setKind(newKind);
+ if (null == result) {
+ result = checkKindSet(m, newKind);
+ }
+ if (null == result) {
+ result = checkExpectedKind(m);
+ }
+ return (null != result? result : setKind(oldKind));
+ }
+
+ /** @return error if failed */
+ private String setKind(IMessage.Kind kind) {
+ this.kind = kind;
+ int index = KINDLIST.indexOf(kind);
+ if (-1 == index) {
+ return "unknown kind: " + kind;
+ }
+ expected.and(UNSET);
+ expected.set(index);
+ return null;
+ }
+
+ /** @return error if failed */
+ String checkExpectedKind(IMessage m) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < KINDS.length; i++) {
+ if (expected.get(i) != checkKindMethods(m, i)) {
+ String s = "expected " + expected.get(i)
+ + " for is{Method} for " + KINDS[i];
+ result.append(s + "\n");
+ }
+ }
+ return (0 < result.length() ? result.toString() : null);
+ }
+
+ String checkKindSet(IMessage m, IMessage.Kind kind) {
+ if (kind != m.getKind()) {
+ return "expected kind " + kind + " got " + m.getKind();
+ }
+ return null;
+ }
+
+ /** @return true if index matches isFoo() reporting */
+ boolean checkKindMethods(IMessage m, int index) {
+ switch (index) {
+ case (0) : return m.isAbort();
+ case (1) : return m.isDebug();
+ case (2) : return m.isError();
+ case (3) : return m.isInfo();
+ case (4) : return m.isWarning();
+ case (5) : return m.isFailed();
+ default : throw new IllegalArgumentException("index=" + index);
+
+ }
+ }
+}
diff --git a/bridge/src/test/java/org/aspectj/bridge/VersionTest.java b/bridge/src/test/java/org/aspectj/bridge/VersionTest.java
new file mode 100644
index 000000000..cee4c8450
--- /dev/null
+++ b/bridge/src/test/java/org/aspectj/bridge/VersionTest.java
@@ -0,0 +1,60 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC).
+ * 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.bridge;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.aspectj.util.LangUtil;
+
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+/**
+ *
+ */
+public class VersionTest extends TestCase {
+
+ private static final String ME = "org.aspectj.bridge.VersionTest";
+
+ /** @param args ignored */
+ public static void main(String[] args) {
+ TestRunner.main(new String[] { ME });
+ }
+
+ /**
+ * Constructor for MessageTest.
+ *
+ * @param name
+ */
+ public VersionTest(String name) {
+ super(name);
+ }
+
+ public void testVersion() {
+ if (LangUtil.is11VMOrGreater()) {
+ return;
+ }
+ if (Version.time_text.equals("")) {
+ return; // dev build, we can only test this on the build server.
+ }
+ Date date = new Date(Version.getTime());
+ SimpleDateFormat format = new SimpleDateFormat(Version.SIMPLE_DATE_FORMAT, Locale.getDefault());
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ String timeString = format.format(date);
+ assertEquals(Version.time_text, timeString);
+ }
+}
diff --git a/bridge/src/test/java/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java b/bridge/src/test/java/org/aspectj/bridge/context/CompilationAndWeavingContextTest.java
new file mode 100644
index 000000000..825a52b61
--- /dev/null
+++ b/bridge/src/test/java/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 mucking about with ABC\nwhen fiddling XYZ\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();
+ }
+
+ }
+}