From 5e5b863cb9157144ba8fb7d4c08e75f585f8331c Mon Sep 17 00:00:00 2001 From: Scokart Gilles Date: Sat, 24 Jan 2009 13:05:51 +0000 Subject: [PATCH] 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 --- src/etc/testcases/antunit.xml | 7 ++++ src/etc/testcases/antunit/java-io.xml | 39 +++++++++++++++++++ .../org/apache/ant/antunit/AntUnitTest.java | 25 ++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/etc/testcases/antunit/java-io.xml 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 @@ under the License. + + + + + + + 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 @@ + + + + + + + + Not a self-contained build file + + + + + + + + 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 @@ public class AntUnitTest extends BuildFileTest { 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"); + } + } }