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
This commit is contained in:
Scokart Gilles 2009-01-24 13:05:51 +00:00
parent 566e104cb2
commit 5e5b863cb9
3 changed files with 71 additions and 0 deletions

View File

@ -80,6 +80,13 @@ under the License.
</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}"/>

View File

@ -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>

View File

@ -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");
}
}
}