add test that fails if antunit doesn't support io demux

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/antunit/trunk@737355 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/etc/testcases/antunit.xml b/src/etc/testcases/antunit.xml
index e2e4cd3..3b49356 100644
--- a/src/etc/testcases/antunit.xml
+++ b/src/etc/testcases/antunit.xml
@@ -80,6 +80,13 @@
     </au:antunit>
   </target>
 
+  <target name="testSystemIoHandling">
+    <au:antunit>
+      <file file="antunit/java-io.xml" />
+      <au:plainlistener />
+    </au:antunit>  	
+  </target>
+ 
   <property name="reportsdir" location="../../../build/reports"/>
   <target name="antunit-dir">
     <mkdir dir="${reportsdir}"/>
diff --git a/src/etc/testcases/antunit/java-io.xml b/src/etc/testcases/antunit/java-io.xml
new file mode 100644
index 0000000..899bc28
--- /dev/null
+++ b/src/etc/testcases/antunit/java-io.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project name="java-io" default="all"
+         xmlns:au="antlib:org.apache.ant.antunit"
+         basedir="../../../..">
+
+  <target name="all">
+    <fail>Not a self-contained build file</fail>
+  </target>
+
+  <target name="testTaskHandlingOutput">
+  	<java classname="org.apache.ant.antunit.AntUnitTest$HelloWorld" 
+  	      outputproperty="propertyToSet"
+  	      classpath="build/test-classes"
+  	      failonerror="true" 
+  	/>
+    <au:assertEquals expected="HelloWorld" actual="${propertyToSet}" />
+  </target>
+
+</project>
diff --git a/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java b/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java
index 5bd8364..dedf9ba 100644
--- a/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java
+++ b/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java
@@ -19,7 +19,10 @@
  */
 package org.apache.ant.antunit;
 
+import java.io.PrintStream;
+
 import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.DemuxOutputStream;
 
 public class AntUnitTest extends BuildFileTest {
 
@@ -88,4 +91,26 @@
         executeTarget("testNewProject");
     }
 
+    public void testSystemIoHandling() {
+        PrintStream savedErr = System.err;
+        PrintStream savedOut = System.out;
+        try {
+            savedErr.flush();
+            savedOut.flush();
+            System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
+            System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
+            
+            project.executeTarget("testSystemIoHandling");
+            
+        } finally {
+            System.setOut(savedOut);
+            System.setErr(savedErr);
+        }
+    }
+    
+    public static class HelloWorld {
+        public static void main(String[] args) {
+            System.out.println("HelloWorld");
+        }
+    }
 }