You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gs...@apache.org on 2009/01/24 14:05:51 UTC

svn commit: r737355 - in /ant/antlibs/antunit/trunk/src: etc/testcases/antunit.xml etc/testcases/antunit/java-io.xml tests/junit/org/apache/ant/antunit/AntUnitTest.java

Author: gscokart
Date: Sat Jan 24 13:05:51 2009
New Revision: 737355

URL: http://svn.apache.org/viewvc?rev=737355&view=rev
Log:
add test that fails if antunit doesn't support io demux

Added:
    ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml   (with props)
Modified:
    ant/antlibs/antunit/trunk/src/etc/testcases/antunit.xml
    ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java

Modified: ant/antlibs/antunit/trunk/src/etc/testcases/antunit.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/etc/testcases/antunit.xml?rev=737355&r1=737354&r2=737355&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/etc/testcases/antunit.xml (original)
+++ ant/antlibs/antunit/trunk/src/etc/testcases/antunit.xml Sat Jan 24 13:05:51 2009
@@ -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}"/>

Added: ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml?rev=737355&view=auto
==============================================================================
--- ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml (added)
+++ ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml Sat Jan 24 13:05:51 2009
@@ -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>

Propchange: ant/antlibs/antunit/trunk/src/etc/testcases/antunit/java-io.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java
URL: http://svn.apache.org/viewvc/ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java?rev=737355&r1=737354&r2=737355&view=diff
==============================================================================
--- ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java (original)
+++ ant/antlibs/antunit/trunk/src/tests/junit/org/apache/ant/antunit/AntUnitTest.java Sat Jan 24 13:05:51 2009
@@ -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");
+        }
+    }
 }