ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r669453 - /ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java
Date Thu, 19 Jun 2008 11:43:01 GMT
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() {}



Mime
View raw message