]> source.dussan.org Git - aspectj.git/commitdiff
old test for done signal
authorwisberg <wisberg>
Thu, 27 Jan 2005 05:32:46 +0000 (05:32 +0000)
committerwisberg <wisberg>
Thu, 27 Jan 2005 05:32:46 +0000 (05:32 +0000)
taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java

index 25030c116eeb2d4dd806d508258691cbb077f505..c1361cde506f847f852b57c754ec482bf2b4d67c 100644 (file)
@@ -346,6 +346,18 @@ public class AjcTaskTest extends TestCase {
                return task;
        }
 
+    /** used in testMessageHolderClassName */
+    public static class InfoHolder extends MessageHandler {
+        public InfoHolder() {
+        }
+        public boolean handleMessage(IMessage message) {
+            if (0 == IMessage.INFO.compareTo(message.getKind())) {
+                AjcTaskTest.collectMessage(message.getMessage());
+            }
+            return true;
+        }
+    }
+
        /** used in testMessageHolderClassName */
        public static class Holder extends MessageHandler {
                public Holder() {
@@ -374,6 +386,38 @@ public class AjcTaskTest extends TestCase {
                assertEquals("messages", "e", result);
        }
 
+    public void testMessageHolderClassWithDoneSignal() {
+        AjcTask task = getTask("default.lst");
+        task.setFailonerror(false);
+        String DONE = "done";
+        task.setXDoneSignal(DONE);
+        MESSAGES.setLength(0);
+        runTest(
+            task,
+            null,
+            MessageHolderChecker.INFOS,
+            InfoHolder.class.getName());
+        final String result = MESSAGES.toString();
+        String temp = new String(result);
+        MESSAGES.setLength(0);
+        if (!temp.endsWith(DONE)) {
+            if (temp.length() > 20) {
+                temp = "..." + temp.substring(temp.length()-20, temp.length());
+            }
+            assertTrue(DONE + " is not suffix of \"" + temp + "\"", false);
+        }
+        // exactly one such message
+        temp = new String(result);
+        temp = temp.substring(0, temp.length()-DONE.length());
+        if (temp.endsWith(DONE)) {
+            temp = new String(result);
+            if (temp.length() > 20) {
+                temp = "..." + temp.substring(temp.length()-20, temp.length());
+            }
+            assertTrue(DONE + " signalled twice: \"" + temp + "\"", false);
+        }
+    }
+
        public void testDefaultListForkedNoTools() {
                AjcTask task = getTask("default.lst");
                task.setFork(true);