Submitted by: Nico Seessle <nico@seessle.de> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268018 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -308,10 +308,22 @@ | |||||
| <batchtest> | <batchtest> | ||||
| <fileset dir="${src.tests.dir}"> | <fileset dir="${src.tests.dir}"> | ||||
| <include name="**/*Test*" /> | <include name="**/*Test*" /> | ||||
| <exclude name="**/All*" /> | |||||
| <!-- abstract class, not a testcase --> | |||||
| <exclude name="org/apache/tools/ant/taskdefs/TaskdefsTest.java" /> | |||||
| <!-- these depend on order --> | |||||
| <exclude name="org/apache/tools/ant/taskdefs/GUnzipTest.java" /> | |||||
| <exclude name="org/apache/tools/ant/taskdefs/GzipTest.java" /> | |||||
| </fileset> | </fileset> | ||||
| </batchtest> | </batchtest> | ||||
| <test name="org.apache.tools.ant.taskdefs.GzipTest" /> | |||||
| <test name="org.apache.tools.ant.taskdefs.GUnzipTest" /> | |||||
| </junit> | </junit> | ||||
| <!-- clean up again --> | |||||
| <deltree dir="src/etc/testcases/taskdefs/taskdefs.tmp" /> | |||||
| <deltree dir="src/etc/testcases/taskdefs.tmp" /> | |||||
| </target> | </target> | ||||
| </project> | </project> | ||||
| @@ -0,0 +1,34 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="ant-test" basedir="."> | |||||
| <target name="all" depends="test1,test2,test3,test4"/> | |||||
| <target name="test1"> | |||||
| <ant antfile="ant.xml" dir="." target="test1"/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <antcall/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <antcall target="test3"/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <antcall target=""/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <antcall target="dummy"/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <ant antfile="ant.xml" dir="." target="dummy"/> | |||||
| </target> | |||||
| <target name="dummy"> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,9 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="antstructure-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <antstructure/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,81 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="available-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <available/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <available property="test"/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <available file="test"/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <available property="test" | |||||
| file="src/etc/testcases/taskdefs/this_file_does_not_exist"/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <available property="test" | |||||
| file="available.xml"/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <available property="test" | |||||
| resource="/org/apache/tools/ant/taskdefs/this_resource_does_not_exist"/> | |||||
| </target> | |||||
| <target name="test7"> | |||||
| <available property="test" | |||||
| resource="/org/apache/tools/ant/taskdefs/defaults.properties"/> | |||||
| </target> | |||||
| <target name="test8"> | |||||
| <available property="test" | |||||
| classname="org.apache.tools.ant.taskdefs.this_class_does_not_exist"/> | |||||
| </target> | |||||
| <target name="test9"> | |||||
| <available property="test" | |||||
| classname="org.apache.tools.ant.taskdefs.Ant"/> | |||||
| </target> | |||||
| <target name="test10"> | |||||
| <available property="test" | |||||
| file="available.xml" | |||||
| resource="/org/apache/tools/ant/taskdefs/defaults.properties" | |||||
| classname="org.apache.tools.ant.taskdefs.Ant"/> | |||||
| </target> | |||||
| <target name="test11"> | |||||
| <available property="test" | |||||
| file="src/etc/testcases/taskdefs/available.xml" | |||||
| resource="/org/apache/tools/ant/taskdefs/defaults.properties" | |||||
| classname="org.apache.tools.ant.taskdefs.this_class_does_not_exist"/> | |||||
| </target> | |||||
| <target name="test12"> | |||||
| <available property="" | |||||
| file="available.xml"/> | |||||
| </target> | |||||
| <target name="test13"> | |||||
| <available property="test" | |||||
| file=""/> | |||||
| </target> | |||||
| <target name="test14"> | |||||
| <available property="test" | |||||
| resource=""/> | |||||
| </target> | |||||
| <target name="test15"> | |||||
| <available property="test" | |||||
| classname=""/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,33 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="copydir-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <copydir/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <copydir src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <copydir dest=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <copydir src="." | |||||
| dest="."/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <mkdir dir="../taskdefs.tmp" /> | |||||
| <copydir src="." | |||||
| dest="../taskdefs.tmp"/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <copydir src="." | |||||
| dest="template.xml"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,32 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="copyfile-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <copyfile/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <copyfile src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <copyfile dest=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <copyfile src="template.xml" | |||||
| dest="template.xml"/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <copyfile src="copyfile.xml" | |||||
| dest="copyfile.tmp"/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <copyfile src="copyfile.xml" | |||||
| dest="testdir"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,28 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="delete-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <delete/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <copydir src="." | |||||
| dest="taskdefs.tmp"/> | |||||
| <delete file="taskdefs.tmp"/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <copydir src="." | |||||
| dest="taskdefs.tmp"/> | |||||
| <delete dir="taskdefs.tmp/ant.xml"/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <copydir src="." | |||||
| dest="taskdefs.tmp"/> | |||||
| <delete dir="taskdefs.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="deltree-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <deltree/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <deltree dir="src/etc/testcases/taskdefs.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,23 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="echo-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <echo/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <echo message="OUTPUT OF ECHO"/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <echo> | |||||
| This | |||||
| is | |||||
| a | |||||
| multiline | |||||
| message | |||||
| </echo> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="fail-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <fail/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <fail message="test"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,21 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="filter-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <filter/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <filter token=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <filter value=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <filter token="" value=""/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,29 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <get/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <get src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <get src="" dest=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <get src="" dest=""/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <get src="http://localhost" dest=""/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <get src="http://localhost" dest="get.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,18 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <gunzip/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <gunzip src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <gunzip src="gzip.tmp" | |||||
| dest="gzip.tmp2"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,25 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <gzip/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <gzip src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <gzip zipfile=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <gzip src="." zipfile=""/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <gzip src="." zipfile="gzip.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,17 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <mkdir/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <mkdir dir="template.xml"/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <mkdir dir="testdir.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,34 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <rename/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <rename src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <rename dest=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <rename src="testdir" | |||||
| dest="testdir"/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <rename src="template.xml" | |||||
| dest="."/> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <rename src="template.xml" | |||||
| dest="template.tmp"/> | |||||
| <rename src="template.tmp" | |||||
| dest="template.xml"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,26 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <replace/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <replace file=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <replace file="template.xml"/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <replace file="template.xml" token=""/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <replace file="template.xml" | |||||
| token="dont_want_to_really_replace_something"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,17 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <tar/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <tar tarfile=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <tar basedir=""/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,25 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <taskdef/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <taskdef name=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <taskdef classname=""/> | |||||
| </target> | |||||
| <target name="test4"> | |||||
| <taskdef name="" classname="oops"/> | |||||
| </target> | |||||
| <target name="test5"> | |||||
| <taskdef name="test" classname="org.apache.tools.ant.ProjectTest"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,14 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,17 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <unzip/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <unzip src=""/> | |||||
| </target> | |||||
| <target name="test3"> | |||||
| <unzip dest=""/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,13 @@ | |||||
| <?xml version="1.0"?> | |||||
| <project name="xxx-test" basedir="."> | |||||
| <target name="test1"> | |||||
| <zip/> | |||||
| </target> | |||||
| <target name="test2"> | |||||
| <zip zipfile="zip.tmp"/> | |||||
| </target> | |||||
| </project> | |||||
| @@ -0,0 +1,73 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class AntStructureTest extends TaskdefsTest { | |||||
| public AntStructureTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/antstructure.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,95 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class AntTest extends TaskdefsTest { | |||||
| public AntTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/ant.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "recursive call"); | |||||
| } | |||||
| // target must be specified | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| // Should fail since a recursion will occur... | |||||
| public void test3() { | |||||
| expectBuildException("test1", "recursive call"); | |||||
| } | |||||
| public void test4() { | |||||
| expectBuildException("test4", "target doesn't exist"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| } | |||||
| public void test6() { | |||||
| executeTarget("test6"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,160 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class AvailableTest extends TaskdefsTest { | |||||
| public AvailableTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/available.xml"); | |||||
| } | |||||
| // Nothing specified -> Fail | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| // Only property specified -> Fail | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| // Only file specified -> Fail | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| // file doesn't exist -> property 'test' == null | |||||
| public void test4() { | |||||
| executeTarget("test4"); | |||||
| assert(project.getProperty("test") == null); | |||||
| } | |||||
| // file does exist -> property 'test' == 'true' | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| assertEquals(project.getProperty("test"), "true"); | |||||
| } | |||||
| // resource doesn't exist -> property 'test' == null | |||||
| public void test6() { | |||||
| executeTarget("test6"); | |||||
| assert(project.getProperty("test") == null); | |||||
| } | |||||
| // resource does exist -> property 'test' == 'true' | |||||
| public void test7() { | |||||
| executeTarget("test7"); | |||||
| assertEquals(project.getProperty("test"), "true"); | |||||
| } | |||||
| // class doesn't exist -> property 'test' == null | |||||
| public void test8() { | |||||
| executeTarget("test8"); | |||||
| assert(project.getProperty("test") == null); | |||||
| } | |||||
| // class does exist -> property 'test' == 'true' | |||||
| public void test9() { | |||||
| executeTarget("test9"); | |||||
| assertEquals(project.getProperty("test"), "true"); | |||||
| } | |||||
| // All three specified and all three exist -> true | |||||
| public void test10() { | |||||
| executeTarget("test10"); | |||||
| assertEquals(project.getProperty("test"), "true"); | |||||
| } | |||||
| // All three specified but class missing -> null | |||||
| public void test11() { | |||||
| executeTarget("test11"); | |||||
| assertEquals(project.getProperty("test"), null); | |||||
| } | |||||
| // Specified property-name is "" -> true | |||||
| public void test12() { | |||||
| executeTarget("test12"); | |||||
| assertEquals(project.getProperty("test"), null); | |||||
| assertEquals(project.getProperty(""), "true"); | |||||
| } | |||||
| // Specified file is "" -> current directory should always exis :-) | |||||
| public void test13() { | |||||
| executeTarget("test13"); | |||||
| assertEquals(project.getProperty("test"), "true"); | |||||
| } | |||||
| // Specified resource is "" -> can such a thing exist? | |||||
| /* | |||||
| * returns non null IBM JDK 1.3 Linux | |||||
| */ | |||||
| // public void test14() { | |||||
| // executeTarget("test14"); | |||||
| // assertEquals(project.getProperty("test"), null); | |||||
| // } | |||||
| // Specified class is "" -> can not exist | |||||
| public void test15() { | |||||
| executeTarget("test15"); | |||||
| assertEquals(project.getProperty("test"), null); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,99 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class CopydirTest extends TaskdefsTest { | |||||
| public CopydirTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/copydir.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| public void test4() { | |||||
| expectLog("test4", "Warning: src == dest"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs.tmp"); | |||||
| if (!f.exists() || !f.isDirectory()) { | |||||
| fail("Copy failed"); | |||||
| } | |||||
| // We keep this, so we have something to delete in later tests :-) | |||||
| } | |||||
| public void test6() { | |||||
| expectBuildException("test6", "target is file"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,100 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class CopyfileTest extends TaskdefsTest { | |||||
| public CopyfileTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/copyfile.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| public void test4() { | |||||
| expectLog("test4", "Warning: src == dest"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs/copyfile.tmp"); | |||||
| if (f.exists()) { | |||||
| f.delete(); | |||||
| } else { | |||||
| fail("Copy failed"); | |||||
| } | |||||
| } | |||||
| /* | |||||
| public void test6() { | |||||
| expectBuildException("test6", "target is directory"); | |||||
| } | |||||
| */ | |||||
| } | |||||
| @@ -52,30 +52,34 @@ | |||||
| * <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
| */ | */ | ||||
| package org.apache.tools.ant.types; | |||||
| import junit.framework.Test; | |||||
| import junit.framework.TestCase; | |||||
| import junit.framework.TestSuite; | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | /** | ||||
| * Simple class to build a TestSuite out of the individual test classes. | |||||
| * | |||||
| * @author Stefan Bodewig <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | */ | ||||
| public class AllJUnitTests extends TestCase { | |||||
| public AllJUnitTests(String name) { | |||||
| public class DeleteTest extends TaskdefsTest { | |||||
| public DeleteTest(String name) { | |||||
| super(name); | super(name); | ||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/delete.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | } | ||||
| public static Test suite() { | |||||
| TestSuite suite = new TestSuite(CommandlineTest.class); | |||||
| suite.addTest(new TestSuite(CommandlineJavaTest.class)); | |||||
| suite.addTest(new TestSuite(EnumeratedAttributeTest.class)); | |||||
| suite.addTest(new TestSuite(PathTest.class)); | |||||
| suite.addTest(new TestSuite(PatternSetTest.class)); | |||||
| suite.addTest(new TestSuite(FileSetTest.class)); | |||||
| return suite; | |||||
| } | |||||
| public void test2() { | |||||
| executeTarget("test2"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "Not a directory"); | |||||
| } | |||||
| public void test4() { | |||||
| executeTarget("test4"); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,79 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class DeltreeTest extends TaskdefsTest { | |||||
| public DeltreeTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/deltree.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| // We try to delete the directory created in CopydirTest | |||||
| executeTarget("test2"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,87 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class EchoTest extends TaskdefsTest { | |||||
| public EchoTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/echo.xml"); | |||||
| } | |||||
| // Output an empty String | |||||
| public void test1() { | |||||
| expectOutput("test1", "\n"); | |||||
| } | |||||
| // Output 'OUTPUT OF ECHO' | |||||
| public void test2() { | |||||
| expectOutput("test2", "OUTPUT OF ECHO\n"); | |||||
| } | |||||
| public void test3() { | |||||
| expectOutput("test3", "This \n"+ | |||||
| " is\n"+ | |||||
| " a \n"+ | |||||
| " multiline\n"+ | |||||
| " message\n"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,77 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class FailTest extends TaskdefsTest { | |||||
| public FailTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/fail.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "it is required to fail :-)"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "it is required to fail :-)"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,86 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class FilterTest extends TaskdefsTest { | |||||
| public FilterTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/filter.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument missing"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument missing"); | |||||
| } | |||||
| public void test4() { | |||||
| executeTarget("test4"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class GUnzipTest extends TaskdefsTest { | |||||
| public GUnzipTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/gunzip.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "attribute src invalid"); | |||||
| } | |||||
| public void test3() { | |||||
| executeTarget("test3"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs/gzip.tmp2"); | |||||
| if (!f.exists()) { | |||||
| fail("gzip failed"); | |||||
| } else { | |||||
| f.delete(); | |||||
| f = new java.io.File("src/etc/testcases/taskdefs/gzip.tmp"); | |||||
| if (f.exists()) f.delete(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,101 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class GetTest extends TaskdefsTest { | |||||
| public GetTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/get.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument missing"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument missing"); | |||||
| } | |||||
| public void test4() { | |||||
| expectBuildException("test4", "src invalid"); | |||||
| } | |||||
| public void test5() { | |||||
| expectBuildException("test5", "dest invalid (or no http-server on local machine)"); | |||||
| } | |||||
| public void test6() { | |||||
| executeTarget("test6"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs/get.tmp"); | |||||
| if (!f.exists()) { | |||||
| fail("get failed"); | |||||
| } else { | |||||
| f.delete(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,95 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class GzipTest extends TaskdefsTest { | |||||
| public GzipTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/gzip.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument missing"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument missing"); | |||||
| } | |||||
| public void test4() { | |||||
| expectBuildException("test4", "attribute zipfile invalid"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs/gzip.tmp"); | |||||
| if (!f.exists()) { | |||||
| fail("gzip failed"); | |||||
| } | |||||
| // Keep for unzip | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class MkdirTest extends TaskdefsTest { | |||||
| public MkdirTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/mkdir.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| executeTarget("test2"); | |||||
| String log = getLog(); | |||||
| assert(log.indexOf("Warning: Specified directory is a file: ") > -1); | |||||
| } | |||||
| public void test3() { | |||||
| executeTarget("test3"); | |||||
| java.io.File f = new java.io.File("src/etc/testcases/taskdefs/testdir.tmp"); | |||||
| if (!f.exists() || !f.isDirectory()) { | |||||
| fail("mkdir failed"); | |||||
| } else { | |||||
| f.delete(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,91 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class RenameTest extends TaskdefsTest { | |||||
| public RenameTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/rename.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument missing"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument missing"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument missing"); | |||||
| } | |||||
| /* | |||||
| public void test4() { | |||||
| expectBuildException("test4", "source and destination the same"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| } | |||||
| */ | |||||
| public void test6() { | |||||
| executeTarget("test6"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class ReplaceTest extends TaskdefsTest { | |||||
| public ReplaceTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/replace.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| public void test4() { | |||||
| expectBuildException("test4", "empty token not allowed"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,82 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class TarTest extends TaskdefsTest { | |||||
| public TarTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/tar.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,89 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class TaskdefTest extends TaskdefsTest { | |||||
| public TaskdefTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/taskdef.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | |||||
| public void test4() { | |||||
| expectBuildException("test4", "classname specified doesn't exist"); | |||||
| } | |||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,224 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| import junit.framework.*; | |||||
| import org.apache.tools.ant.*; | |||||
| import java.io.*; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public abstract class TaskdefsTest extends TestCase { | |||||
| protected Project project; | |||||
| private StringBuffer logBuffer; | |||||
| private StringBuffer outBuffer; | |||||
| private BuildException buildException; | |||||
| public TaskdefsTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| protected String getLog() { | |||||
| return logBuffer.toString(); | |||||
| } | |||||
| protected void expectBuildException(String taskname, String cause) { | |||||
| try { | |||||
| executeTarget(taskname); | |||||
| } catch (org.apache.tools.ant.BuildException ex) { | |||||
| return; | |||||
| } | |||||
| fail("Should throw BuildException because: " + cause); | |||||
| } | |||||
| protected void expectOutput(String taskname, String output) { | |||||
| executeTarget(taskname); | |||||
| String realOutput = getOutput(); | |||||
| assertEquals(output, realOutput); | |||||
| } | |||||
| protected void expectLog(String taskname, String log) { | |||||
| executeTarget(taskname); | |||||
| String realLog = getLog(); | |||||
| assertEquals(log, realLog); | |||||
| } | |||||
| protected String getOutput() { | |||||
| StringBuffer cleanOut = new StringBuffer(); | |||||
| boolean cr = false; | |||||
| for (int i = 0; i < outBuffer.length(); i++) { | |||||
| char ch = outBuffer.charAt(i); | |||||
| if (ch == '\r') { | |||||
| cr = true; | |||||
| continue; | |||||
| } | |||||
| if (!cr) { | |||||
| cleanOut.append(ch); | |||||
| } else { | |||||
| if (ch == '\n') { | |||||
| cleanOut.append(ch); | |||||
| } else { | |||||
| cleanOut.append('\r').append(ch); | |||||
| } | |||||
| } | |||||
| } | |||||
| return cleanOut.toString(); | |||||
| } | |||||
| protected void configureProject(String filename) { | |||||
| project = new Project(); | |||||
| project.init(); | |||||
| project.setUserProperty( "ant.file" , new File(filename).getAbsolutePath() ); | |||||
| project.addBuildListener(new AntTestListener()); | |||||
| ProjectHelper.configureProject(project, new File(filename)); | |||||
| } | |||||
| protected void executeTarget(String targetName) { | |||||
| PrintStream sysOut = System.out; | |||||
| try { | |||||
| outBuffer = new StringBuffer(); | |||||
| sysOut.flush(); | |||||
| PrintStream out = new PrintStream(new AntOutputStream()); | |||||
| System.setOut(out); | |||||
| logBuffer = new StringBuffer(); | |||||
| buildException = null; | |||||
| project.executeTarget(targetName); | |||||
| } finally { | |||||
| System.setOut(sysOut); | |||||
| } | |||||
| } | |||||
| private class AntOutputStream extends java.io.OutputStream { | |||||
| public void write(int b) { | |||||
| outBuffer.append((char)b); | |||||
| } | |||||
| } | |||||
| private class AntTestListener implements BuildListener { | |||||
| /** | |||||
| * Fired before any targets are started. | |||||
| */ | |||||
| public void buildStarted(BuildEvent event) { | |||||
| } | |||||
| /** | |||||
| * Fired after the last target has finished. This event | |||||
| * will still be thrown if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void buildFinished(BuildEvent event) { | |||||
| } | |||||
| /** | |||||
| * Fired when a target is started. | |||||
| * | |||||
| * @see BuildEvent#getTarget() | |||||
| */ | |||||
| public void targetStarted(BuildEvent event) { | |||||
| //System.out.println("targetStarted " + event.getTarget().getName()); | |||||
| } | |||||
| /** | |||||
| * Fired when a target has finished. This event will | |||||
| * still be thrown if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void targetFinished(BuildEvent event) { | |||||
| //System.out.println("targetFinished " + event.getTarget().getName()); | |||||
| } | |||||
| /** | |||||
| * Fired when a task is started. | |||||
| * | |||||
| * @see BuildEvent#getTask() | |||||
| */ | |||||
| public void taskStarted(BuildEvent event) { | |||||
| //System.out.println("taskStarted " + event.getTask().getTaskName()); | |||||
| } | |||||
| /** | |||||
| * Fired when a task has finished. This event will still | |||||
| * be throw if an error occured during the build. | |||||
| * | |||||
| * @see BuildEvent#getException() | |||||
| */ | |||||
| public void taskFinished(BuildEvent event) { | |||||
| //System.out.println("taskFinished " + event.getTask().getTaskName()); | |||||
| } | |||||
| /** | |||||
| * Fired whenever a message is logged. | |||||
| * | |||||
| * @see BuildEvent#getMessage() | |||||
| * @see BuildEvent#getPriority() | |||||
| */ | |||||
| public void messageLogged(BuildEvent event) { | |||||
| if (event.getPriority() == Project.MSG_INFO || | |||||
| event.getPriority() == Project.MSG_ERR) | |||||
| { | |||||
| logBuffer.append(event.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -52,27 +52,31 @@ | |||||
| * <http://www.apache.org/>. | * <http://www.apache.org/>. | ||||
| */ | */ | ||||
| package org.apache.tools.ant; | |||||
| import junit.framework.Test; | |||||
| import junit.framework.TestCase; | |||||
| import junit.framework.TestSuite; | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | /** | ||||
| * Simple class to build a TestSuite out of the individual test classes. | |||||
| * | |||||
| * @author Stefan Bodewig <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | */ | ||||
| public class AllJUnitTests extends TestCase { | |||||
| public AllJUnitTests(String name) { | |||||
| public class UnzipTest extends TaskdefsTest { | |||||
| public UnzipTest(String name) { | |||||
| super(name); | super(name); | ||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/unzip.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| public void test3() { | |||||
| expectBuildException("test3", "required argument not specified"); | |||||
| } | } | ||||
| public static Test suite() { | |||||
| TestSuite suite = new TestSuite(IntrospectionHelperTest.class); | |||||
| suite.addTest(new TestSuite(org.apache.tools.ant.ProjectTest.class)); | |||||
| suite.addTest(org.apache.tools.ant.types.AllJUnitTests.suite()); | |||||
| return suite; | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,77 @@ | |||||
| /* | |||||
| * The Apache Software License, Version 1.1 | |||||
| * | |||||
| * Copyright (c) 2000 The Apache Software Foundation. All rights | |||||
| * reserved. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | |||||
| * modification, are permitted provided that the following conditions | |||||
| * are met: | |||||
| * | |||||
| * 1. Redistributions of source code must retain the above copyright | |||||
| * notice, this list of conditions and the following disclaimer. | |||||
| * | |||||
| * 2. Redistributions in binary form must reproduce the above copyright | |||||
| * notice, this list of conditions and the following disclaimer in | |||||
| * the documentation and/or other materials provided with the | |||||
| * distribution. | |||||
| * | |||||
| * 3. The end-user documentation included with the redistribution, if | |||||
| * any, must include the following acknowlegement: | |||||
| * "This product includes software developed by the | |||||
| * Apache Software Foundation (http://www.apache.org/)." | |||||
| * Alternately, this acknowlegement may appear in the software itself, | |||||
| * if and wherever such third-party acknowlegements normally appear. | |||||
| * | |||||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||||
| * Foundation" must not be used to endorse or promote products derived | |||||
| * from this software without prior written permission. For written | |||||
| * permission, please contact apache@apache.org. | |||||
| * | |||||
| * 5. Products derived from this software may not be called "Apache" | |||||
| * nor may "Apache" appear in their names without prior written | |||||
| * permission of the Apache Group. | |||||
| * | |||||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| * SUCH DAMAGE. | |||||
| * ==================================================================== | |||||
| * | |||||
| * This software consists of voluntary contributions made by many | |||||
| * individuals on behalf of the Apache Software Foundation. For more | |||||
| * information on the Apache Software Foundation, please see | |||||
| * <http://www.apache.org/>. | |||||
| */ | |||||
| package org.apache.tools.ant.taskdefs; | |||||
| /** | |||||
| * @author Nico Seessle <nico@seessle.de> | |||||
| */ | |||||
| public class ZipTest extends TaskdefsTest { | |||||
| public ZipTest(String name) { | |||||
| super(name); | |||||
| } | |||||
| public void setUp() { | |||||
| configureProject("src/etc/testcases/taskdefs/zip.xml"); | |||||
| } | |||||
| public void test1() { | |||||
| expectBuildException("test1", "required argument not specified"); | |||||
| } | |||||
| public void test2() { | |||||
| expectBuildException("test2", "required argument not specified"); | |||||
| } | |||||
| } | |||||