You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/06/19 13:43:01 UTC

svn commit: r669453 - /ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java

Author: bodewig
Date: Thu Jun 19 04:43:00 2008
New Revision: 669453

URL: http://svn.apache.org/viewvc?rev=669453&view=rev
Log:
Add a test that fails if we allow a logger to recursively log messages

Modified:
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java?rev=669453&r1=669452&r2=669453&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java Thu Jun 19 04:43:00 2008
@@ -245,6 +245,36 @@
         bft.expectLog("once", "once from buildfile");
     }
 
+    public void testOutputDuringMessageLoggedIsSwallowed()
+        throws InterruptedException {
+        final String FOO = "foo", BAR = "bar";
+        p.addBuildListener(new BuildListener() {
+                public void buildStarted(BuildEvent event) {}
+                public void buildFinished(BuildEvent event) {}
+                public void targetStarted(BuildEvent event) {}
+                public void targetFinished(BuildEvent event) {}
+                public void taskStarted(BuildEvent event) {}
+                public void taskFinished(BuildEvent event) {}
+                public void messageLogged(final BuildEvent actual) {
+                    assertEquals(FOO, actual.getMessage());
+                    // each of the following lines would cause an
+                    // infinite loop if the message wasn't swallowed
+                    System.err.println(BAR);
+                    System.out.println(BAR);
+                    p.log(BAR, Project.MSG_INFO);
+                }
+            });
+        final boolean[] done = new boolean[] {false};
+        Thread t = new Thread() {
+                public void run() {
+                    p.log(FOO, Project.MSG_INFO);
+                    done[0] = true;
+                }
+            };
+        t.start();
+        t.join(2000);
+        assertTrue("Expected logging thread to finish successfully", done[0]);
+    }
 
     private class DummyTaskPrivate extends Task {
         public DummyTaskPrivate() {}