git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1584506 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -18,6 +18,12 @@ | |||
| <project name="copydir-test" basedir="." default="test1"> | |||
| <import file="../buildfiletest-base.xml"/> | |||
| <target name="setUp"> | |||
| <mkdir dir="${output}" /> | |||
| </target> | |||
| <target name="test1"> | |||
| <copydir/> | |||
| </target> | |||
| @@ -36,9 +42,9 @@ | |||
| </target> | |||
| <target name="test5"> | |||
| <mkdir dir="../taskdefs.tmp" /> | |||
| <mkdir dir="${output}/taskdefs.tmp" /> | |||
| <copydir src="." | |||
| dest="../taskdefs.tmp"/> | |||
| dest="${output}/taskdefs.tmp"/> | |||
| </target> | |||
| <target name="test6"> | |||
| @@ -46,8 +52,5 @@ | |||
| dest="template.xml"/> | |||
| </target> | |||
| <target name="cleanup"> | |||
| <delete dir="../taskdefs.tmp" /> | |||
| </target> | |||
| </project> | |||
| @@ -18,6 +18,12 @@ | |||
| <project name="copyfile-test" basedir="." default="test1"> | |||
| <import file="../buildfiletest-base.xml"/> | |||
| <target name="setUp"> | |||
| <mkdir dir="${output}" /> | |||
| </target> | |||
| <target name="test1"> | |||
| <copyfile/> | |||
| </target> | |||
| @@ -37,18 +43,14 @@ | |||
| <target name="test5"> | |||
| <copyfile src="copyfile.xml" | |||
| dest="copyfile.tmp"/> | |||
| dest="${output}/copyfile.tmp"/> | |||
| </target> | |||
| <target name="test6"> | |||
| <delete file="testdir"/> | |||
| <mkdir dir="testdir" /> | |||
| <copyfile src="copyfile.xml" | |||
| dest="testdir" | |||
| <mkdir dir="${output}/testdir"/> | |||
| <copyfile src="copyfile.xml" | |||
| dest="${output}/testdir" | |||
| forceoverwrite="true" /> | |||
| </target> | |||
| <target name="cleanup"> | |||
| <delete dir="testdir" /> | |||
| </target> | |||
| </project> | |||
| @@ -18,8 +18,11 @@ | |||
| <project name="delete-test" basedir="." default="test1"> | |||
| <property name="dirname" value="taskdefs.tmp" /> | |||
| <property name="dir" location="${dirname}" /> | |||
| <import file="../buildfiletest-base.xml"/> | |||
| <property name="dir" location="${output}" /> | |||
| <basename property="dirname" file="${output}"/> | |||
| <macrodef name="expectabsent"> | |||
| <attribute name="target" default="${dir}"/> | |||
| @@ -187,6 +190,5 @@ | |||
| </target> | |||
| <target name="cleanup" depends="test4" /> | |||
| </project> | |||
| @@ -1,100 +0,0 @@ | |||
| <?xml version="1.0"?> | |||
| <!-- | |||
| Licensed to the Apache Software Foundation (ASF) under one or more | |||
| contributor license agreements. See the NOTICE file distributed with | |||
| this work for additional information regarding copyright ownership. | |||
| The ASF licenses this file to You under the Apache License, Version 2.0 | |||
| (the "License"); you may not use this file except in compliance with | |||
| the License. You may obtain a copy of the License at | |||
| http://www.apache.org/licenses/LICENSE-2.0 | |||
| Unless required by applicable law or agreed to in writing, software | |||
| distributed under the License is distributed on an "AS IS" BASIS, | |||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
| See the License for the specific language governing permissions and | |||
| limitations under the License. | |||
| --> | |||
| <project name="echo-test" basedir="." default="test1"> | |||
| <property name="dest.dir" location="echo.dest"/> | |||
| <target name="init"> | |||
| <mkdir dir="${dest.dir}" /> | |||
| </target> | |||
| <target name="clean"> | |||
| <delete dir="${dest.dir}"/> | |||
| </target> | |||
| <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> | |||
| <macrodef name="assertContains"> | |||
| <attribute name="expected" /> | |||
| <attribute name="actual" /> | |||
| <sequential> | |||
| <fail> | |||
| <condition> | |||
| <not> | |||
| <contains string="@{actual}" substring="@{expected}"></contains> | |||
| </not> | |||
| </condition> | |||
| Did not find @{expected} in @{actual} | |||
| </fail> | |||
| </sequential> | |||
| </macrodef> | |||
| <target name="testFile" depends="init"> | |||
| <echo file="${dest.dir}/echo.txt">Simple text</echo> | |||
| <loadfile srcfile="${dest.dir}/echo.txt" property="echo" /> | |||
| <assertContains actual="${echo}" expected="Simple text" /> | |||
| </target> | |||
| <target name="testAppend" depends="init"> | |||
| <echo file="${dest.dir}/echo.txt">Simple text</echo> | |||
| <echo file="${dest.dir}/echo.txt" append="true">Appended</echo> | |||
| <loadfile srcfile="${dest.dir}/echo.txt" property="echo"/> | |||
| <assertContains actual="${echo}" expected="Simple text"/> | |||
| <assertContains actual="${echo}" expected="Appended"/> | |||
| </target> | |||
| <target name="testEmptyEncoding" depends="init"> | |||
| <echo file="${dest.dir}/echo.txt" encoding="">Simple text</echo> | |||
| <loadfile srcfile="${dest.dir}/echo.txt" property="echo"/> | |||
| <assertContains actual="${echo}" expected="Simple text"/> | |||
| </target> | |||
| <target name="testUTF16Encoding" depends="init"> | |||
| <property name="char" value="©" /> | |||
| <echo file="${dest.dir}/echo16.txt" encoding="UTF-16">${char}</echo> | |||
| <loadfile srcfile="${dest.dir}/echo16.txt" property="echo16" encoding="UTF16"/> | |||
| <assertContains actual="${echo16}" expected="${char}"/> | |||
| </target> | |||
| <target name="testUTF8Encoding" depends="init"> | |||
| <property name="char" value="©" /> | |||
| <echo file="${dest.dir}/echo8.txt" encoding="UTF8">${char}</echo> | |||
| <loadfile srcfile="${dest.dir}/echo8.txt" property="echo" encoding="UTF8"/> | |||
| <assertContains actual="${echo}" expected="${char}"/> | |||
| </target> | |||
| </project> | |||
| @@ -18,11 +18,17 @@ | |||
| <project name="jar-test" basedir="." default="test1"> | |||
| <property name="tmp.jar" location="tmp.jar"/> | |||
| <property name="tmp.dir" location="jartmp"/> | |||
| <property name="tmp.zip" location="tmp.zip"/> | |||
| <property name="tmp1.dir" location="jartmp1"/> | |||
| <property name="tmp2.dir" location="jartmp2"/> | |||
| <import file="../buildfiletest-base.xml"/> | |||
| <target name="setUp"> | |||
| <mkdir dir="${output}" /> | |||
| </target> | |||
| <property name="tmp.jar" location="${output}/tmp.jar"/> | |||
| <property name="tmp.dir" location="${output}/jartmp"/> | |||
| <property name="tmp.zip" location="${output}/tmp.zip"/> | |||
| <property name="tmp1.dir" location="${output}/jartmp1"/> | |||
| <property name="tmp2.dir" location="${output}/jartmp2"/> | |||
| <target name="test1"> | |||
| <jar/> | |||
| @@ -181,15 +187,6 @@ | |||
| </jar> | |||
| </target> | |||
| <target name="cleanup"> | |||
| <delete file="${tmp.jar}" /> | |||
| <delete file="${tmp.jar}2" /> | |||
| <delete dir="${tmp.dir}"/> | |||
| <delete file="${tmp.zip}" /> | |||
| <delete dir="${tmp1.dir}"/> | |||
| <delete dir="${tmp2.dir}"/> | |||
| </target> | |||
| <target name="testCreateWithEmptyFilesetSetUp"> | |||
| <mkdir dir="${tmp1.dir}"/> | |||
| <mkdir dir="${tmp2.dir}"/> | |||
| @@ -30,10 +30,7 @@ public class CopydirTest extends BuildFileTest { | |||
| public void setUp() { | |||
| configureProject("src/etc/testcases/taskdefs/copydir.xml"); | |||
| } | |||
| public void tearDown() { | |||
| executeTarget("cleanup"); | |||
| executeTarget("setUp"); | |||
| } | |||
| public void test1() { | |||
| @@ -54,7 +51,7 @@ public class CopydirTest extends BuildFileTest { | |||
| public void test5() { | |||
| executeTarget("test5"); | |||
| java.io.File f = new java.io.File(getProjectDir(), "../taskdefs.tmp"); | |||
| java.io.File f = new java.io.File(getOutputDir(), "taskdefs.tmp"); | |||
| if (!f.exists() || !f.isDirectory()) { | |||
| fail("Copy failed"); | |||
| } | |||
| @@ -34,10 +34,7 @@ public class CopyfileTest extends BuildFileTest { | |||
| public void setUp() { | |||
| configureProject("src/etc/testcases/taskdefs/copyfile.xml"); | |||
| } | |||
| public void tearDown() { | |||
| executeTarget("cleanup"); | |||
| executeTarget("setUp"); | |||
| } | |||
| public void test1() { | |||
| @@ -58,10 +55,8 @@ public class CopyfileTest extends BuildFileTest { | |||
| public void test5() { | |||
| executeTarget("test5"); | |||
| java.io.File f = new java.io.File(getProjectDir(), "copyfile.tmp"); | |||
| if (f.exists()) { | |||
| f.delete(); | |||
| } else { | |||
| java.io.File f = new java.io.File(getOutputDir(), "copyfile.tmp"); | |||
| if (!f.exists()) { | |||
| fail("Copy failed"); | |||
| } | |||
| } | |||
| @@ -32,10 +32,6 @@ public class DeleteTest extends BuildFileTest { | |||
| configureProject("src/etc/testcases/taskdefs/delete.xml"); | |||
| } | |||
| public void tearDown() { | |||
| executeTarget("cleanup"); | |||
| } | |||
| public void test1() { | |||
| expectBuildException("test1", "required argument not specified"); | |||
| } | |||
| @@ -48,6 +48,7 @@ public class JarTest extends BuildFileTest { | |||
| public void setUp() { | |||
| configureProject("src/etc/testcases/taskdefs/jar.xml"); | |||
| executeTarget("setUp"); | |||
| } | |||
| public void tearDown() { | |||
| @@ -63,8 +64,11 @@ public class JarTest extends BuildFileTest { | |||
| } catch (IOException e) { | |||
| } | |||
| } | |||
| try { | |||
| super.tearDown(); | |||
| } catch (Exception exc) { | |||
| executeTarget("cleanup"); | |||
| } | |||
| } | |||
| public void test1() { | |||
| @@ -81,7 +85,7 @@ public class JarTest extends BuildFileTest { | |||
| public void test4() { | |||
| executeTarget("test4"); | |||
| File jarFile = new File(getProjectDir(), tempJar); | |||
| File jarFile = new File(getOutputDir(), tempJar); | |||
| assertTrue(jarFile.exists()); | |||
| } | |||
| @@ -95,7 +99,7 @@ public class JarTest extends BuildFileTest { | |||
| private void testNoRecreate(String secondTarget) { | |||
| executeTarget("test4"); | |||
| File jarFile = new File(getProjectDir(), tempJar); | |||
| File jarFile = new File(getOutputDir(), tempJar); | |||
| long jarModifiedDate = jarFile.lastModified(); | |||
| try { | |||
| Thread.sleep(2500); | |||
| @@ -132,10 +136,10 @@ public class JarTest extends BuildFileTest { | |||
| Thread.sleep(sleeptime); | |||
| } catch (InterruptedException e) { | |||
| } // end of try-catch | |||
| File jarFile = new File(getProjectDir(), tempJar); | |||
| File jarFile = new File(getOutputDir(), tempJar); | |||
| long jarModifiedDate = jarFile.lastModified(); | |||
| executeTarget(secondTarget); | |||
| jarFile = new File(getProjectDir(), tempJar); | |||
| jarFile = new File(getOutputDir(), tempJar); | |||
| assertTrue("jar has been recreated in " + secondTarget, | |||
| jarModifiedDate < jarFile.lastModified()); | |||
| } | |||
| @@ -144,10 +148,10 @@ public class JarTest extends BuildFileTest { | |||
| throws IOException, ManifestException { | |||
| executeTarget("testManifestStaysIntact"); | |||
| r1 = new FileReader(getProject() | |||
| .resolveFile(tempDir + "manifest")); | |||
| r2 = new FileReader(getProject() | |||
| .resolveFile(tempDir + "META-INF/MANIFEST.MF")); | |||
| r1 = new FileReader(new File(getOutputDir(), | |||
| tempDir + "manifest")); | |||
| r2 = new FileReader(new File(getOutputDir(), | |||
| tempDir + "META-INF/MANIFEST.MF")); | |||
| Manifest mf1 = new Manifest(r1); | |||
| Manifest mf2 = new Manifest(r2); | |||
| assertEquals(mf1, mf2); | |||
| @@ -197,7 +201,7 @@ public class JarTest extends BuildFileTest { | |||
| public void testUpdateIfOnlyManifestHasChanged() { | |||
| executeTarget("testUpdateIfOnlyManifestHasChanged"); | |||
| File jarXml = getProject().resolveFile(tempDir + "jar.xml"); | |||
| File jarXml = new File(getOutputDir(), tempDir + "jar.xml"); | |||
| assertTrue(jarXml.exists()); | |||
| } | |||
| @@ -206,7 +210,7 @@ public class JarTest extends BuildFileTest { | |||
| ZipFile archive = null; | |||
| try { | |||
| executeTarget("testIndexTests"); | |||
| archive = new ZipFile(getProject().resolveFile(tempJar)); | |||
| archive = new ZipFile(new File(getOutputDir(), tempJar)); | |||
| Enumeration e = archive.entries(); | |||
| int numberOfIndexLists = 0; | |||
| while (e.hasMoreElements()) { | |||
| @@ -228,7 +232,7 @@ public class JarTest extends BuildFileTest { | |||
| ZipFile archive = null; | |||
| try { | |||
| executeTarget("testIndexTests"); | |||
| archive = new ZipFile(getProject().resolveFile(tempJar)); | |||
| archive = new ZipFile(new File(getOutputDir(), tempJar)); | |||
| ZipEntry ze = archive.getEntry("META-INF/INDEX.LIST"); | |||
| InputStream is = archive.getInputStream(ze); | |||
| BufferedReader r = new BufferedReader(new InputStreamReader(is, | |||
| @@ -260,7 +264,7 @@ public class JarTest extends BuildFileTest { | |||
| } | |||
| public void testManifestOnlyJar() { | |||
| expectLogContaining("testManifestOnlyJar", "Building MANIFEST-only jar: "); | |||
| File manifestFile = getProject().resolveFile(tempDir + "META-INF" + File.separator + "MANIFEST.MF"); | |||
| File manifestFile = new File(getOutputDir(), tempDir + "META-INF" + File.separator + "MANIFEST.MF"); | |||
| assertTrue(manifestFile.exists()); | |||
| } | |||
| @@ -35,15 +35,12 @@ public class ProtectedJarMethodsTest extends BuildFileTest { | |||
| public void setUp() { | |||
| configureProject("src/etc/testcases/taskdefs/jar.xml"); | |||
| } | |||
| public void tearDown() { | |||
| executeTarget("cleanup"); | |||
| executeTarget("setUp"); | |||
| } | |||
| public void testGrabFilesAndDirs() throws IOException { | |||
| executeTarget("testIndexTests"); | |||
| String archive = getProject().resolveFile(tempJar).getAbsolutePath(); | |||
| String archive = getProject().getProperty(tempJar); | |||
| ArrayList dirs = new ArrayList(); | |||
| ArrayList files = new ArrayList(); | |||
| String[] expectedDirs = new String[] { | |||