bodewig 01/03/08 07:17:30
Modified: src/etc/testcases/taskdefs copy.xml copyfile.xml deltree.xml
get.xml
src/testcases/org/apache/tools/ant/taskdefs CopydirTest.java
CopyfileTest.java FilterTest.java GUnzipTest.java
GetTest.java GzipTest.java JarTest.java
MkdirTest.java TaskdefsTest.java
Added: src/testcases/org/apache/tools/ant/taskdefs CopyTest.java
Log:
Make testcases independent of current working directory - add one for <copy>.
Submitted by: David Rees <[EMAIL PROTECTED]>
Revision Changes Path
1.4 +11 -1 jakarta-ant/src/etc/testcases/taskdefs/copy.xml
Index: copy.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/copy.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- copy.xml 2000/12/18 15:43:51 1.3
+++ copy.xml 2001/03/08 15:17:18 1.4
@@ -3,7 +3,17 @@
<project name="copy-test" basedir="." default="test1">
<target name="test1">
- <copy file="copy.xml" todir="." overwrite="true"/>
+ <copy file="copy.xml" tofile="copytest1.tmp" />
</target>
+
+ <target name="test2">
+ <copy file="copy.xml" todir="copytest1dir" overwrite="true"/>
+ </target>
+
+ <target name="cleanup">
+ <delete file="copytest1.tmp"/>
+ <delete dir="copytest1dir"/>
+ </target>
+
</project>
1.3 +6 -1 jakarta-ant/src/etc/testcases/taskdefs/copyfile.xml
Index: copyfile.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/copyfile.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- copyfile.xml 2000/12/18 15:43:52 1.2
+++ copyfile.xml 2001/03/08 15:17:19 1.3
@@ -25,8 +25,13 @@
</target>
<target name="test6">
+ <mkdir dir="testdir" />
<copyfile src="copyfile.xml"
- dest="testdir"/>
+ dest="testdir"
+ forceoverwrite="true" />
</target>
+ <target name="cleanup">
+ <delete dir="testdir" />
+ </target>
</project>
1.3 +1 -1 jakarta-ant/src/etc/testcases/taskdefs/deltree.xml
Index: deltree.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/deltree.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- deltree.xml 2000/12/18 15:43:53 1.2
+++ deltree.xml 2001/03/08 15:17:19 1.3
@@ -7,7 +7,7 @@
</target>
<target name="test2">
- <deltree dir="src/etc/testcases/taskdefs.tmp"/>
+ <deltree dir="taskdefs.tmp"/>
</target>
</project>
1.3 +2 -2 jakarta-ant/src/etc/testcases/taskdefs/get.xml
Index: get.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/get.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- get.xml 2000/12/18 15:43:55 1.2
+++ get.xml 2001/03/08 15:17:19 1.3
@@ -19,11 +19,11 @@
</target>
<target name="test5">
- <get src="http://localhost" dest=""/>
+ <get src="http://www.apache.org" dest=""/>
</target>
<target name="test6">
- <get src="http://localhost" dest="get.tmp"/>
+ <get src="http://www.apache.org" dest="get.tmp"/>
</target>
</project>
1.4 +3 -1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopydirTest.java
Index: CopydirTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopydirTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CopydirTest.java 2001/01/03 14:18:49 1.3
+++ CopydirTest.java 2001/03/08 15:17:23 1.4
@@ -54,6 +54,8 @@
package org.apache.tools.ant.taskdefs;
+import java.io.File;
+
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
@@ -85,7 +87,7 @@
public void test5() {
executeTarget("test5");
- java.io.File f = new java.io.File("src/etc/testcases/taskdefs.tmp");
+ java.io.File f = new java.io.File(getProjectDir(),
"../taskdefs.tmp");
if (!f.exists() || !f.isDirectory()) {
fail("Copy failed");
}
1.4 +11 -1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopyfileTest.java
Index: CopyfileTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopyfileTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CopyfileTest.java 2001/01/03 14:18:49 1.3
+++ CopyfileTest.java 2001/03/08 15:17:23 1.4
@@ -54,11 +54,17 @@
package org.apache.tools.ant.taskdefs;
+import java.io.File;
+
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
public class CopyfileTest extends TaskdefsTest {
+ public void test6() {
+ expectBuildException("test6", "target is directory");
+ }
+
public CopyfileTest(String name) {
super(name);
}
@@ -67,6 +73,10 @@
configureProject("src/etc/testcases/taskdefs/copyfile.xml");
}
+ public void tearDown() {
+ executeTarget("cleanup");
+ }
+
public void test1() {
expectBuildException("test1", "required argument not specified");
}
@@ -85,7 +95,7 @@
public void test5() {
executeTarget("test5");
- java.io.File f = new
java.io.File("src/etc/testcases/taskdefs/copyfile.tmp");
+ java.io.File f = new java.io.File(getProjectDir(), "copyfile.tmp");
if (f.exists()) {
f.delete();
} else {
1.4 +9 -11
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java
Index: FilterTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilterTest.java 2001/01/03 14:18:49 1.3
+++ FilterTest.java 2001/03/08 15:17:24 1.4
@@ -64,15 +64,13 @@
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
public class FilterTest extends TaskdefsTest {
-
- private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/";
-
+
public FilterTest(String name) {
super(name);
}
public void setUp() {
- configureProject(TASKDEFS_DIR + "filter.xml");
+ configureProject("src/etc/testcases/taskdefs/filter.xml");
}
public void test1() {
@@ -94,32 +92,32 @@
public void test5() {
executeTarget("test5");
assertEquals("2000",
- getFilteredFile("5", TASKDEFS_DIR + "filtered.tmp"));
+ getFilteredFile("5", "filtered.tmp"));
}
-
+
public void test6() {
executeTarget("test6");
assertEquals("2000",
- getFilteredFile("6", TASKDEFS_DIR +
"taskdefs.tmp/filter1.txt"));
+ getFilteredFile("6", "taskdefs.tmp/filter1.txt"));
}
public void test7() {
executeTarget("test7");
assertEquals("<%@ include file=\"root/some/include.jsp\"%>",
- getFilteredFile("7", TASKDEFS_DIR + "filtered.tmp"));
+ getFilteredFile("7", "filtered.tmp"));
}
-
+
public void test8() {
executeTarget("test8");
assertEquals("<%@ include file=\"root/some/include.jsp\"%>",
- getFilteredFile("8", TASKDEFS_DIR +
"taskdefs.tmp/filter2.txt"));
+ getFilteredFile("8", "taskdefs.tmp/filter2.txt"));
}
private String getFilteredFile(String testNumber, String filteredFile) {
String line = null;
- File f = new File(filteredFile);
+ File f = new File(getProjectDir(), filteredFile);
if (!f.exists()) {
fail("filter test"+testNumber+" failed");
} else {
1.3 +5 -3
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java
Index: GUnzipTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GUnzipTest.java 2001/01/03 14:18:49 1.2
+++ GUnzipTest.java 2001/03/08 15:17:24 1.3
@@ -52,7 +52,9 @@
* <http://www.apache.org/>.
*/
-package org.apache.tools.ant.taskdefs;
+ package org.apache.tools.ant.taskdefs;
+
+ import java.io.File;
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
@@ -77,12 +79,12 @@
public void test3() {
executeTarget("test3");
- java.io.File f = new
java.io.File("src/etc/testcases/taskdefs/gzip.tmp2");
+ java.io.File f = new File(getProjectDir(), "gzip.tmp2");
if (!f.exists()) {
fail("gzip failed");
} else {
f.delete();
- f = new java.io.File("src/etc/testcases/taskdefs/gzip.tmp");
+ f = new File(getProjectDir(), "gzip.tmp");
if (f.exists()) f.delete();
}
}
1.4 +5 -6
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java
Index: GetTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GetTest.java 2001/02/18 19:25:56 1.3
+++ GetTest.java 2001/03/08 15:17:24 1.4
@@ -54,6 +54,8 @@
package org.apache.tools.ant.taskdefs;
+import java.io.File;
+
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
@@ -84,21 +86,18 @@
}
public void test5() {
- // We can't expect a build-system to have a webserver installed...
- //expectBuildException("test5", "dest invalid (or no http-server on
local machine)");
+ expectBuildException("test5", "dest invalid (or no http-server on
local machine)");
}
public void test6() {
- // We can't expect a build-system to have a webserver installed...
-/*
executeTarget("test6");
- java.io.File f = new
java.io.File("src/etc/testcases/taskdefs/get.tmp");
+ java.io.File f = new File(getProjectDir(), "get.tmp");
if (!f.exists()) {
fail("get failed");
} else {
f.delete();
}
-*/
+
}
}
1.3 +3 -1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java
Index: GzipTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GzipTest.java 2001/01/03 14:18:49 1.2
+++ GzipTest.java 2001/03/08 15:17:25 1.3
@@ -54,6 +54,8 @@
package org.apache.tools.ant.taskdefs;
+import java.io.File;
+
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
@@ -85,7 +87,7 @@
public void test5() {
executeTarget("test5");
- java.io.File f = new
java.io.File("src/etc/testcases/taskdefs/gzip.tmp");
+ java.io.File f = new java.io.File(getProjectDir(), "gzip.tmp");
if (!f.exists()) {
fail("gzip failed");
}
1.3 +3 -3
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java
Index: JarTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JarTest.java 2001/01/03 14:18:49 1.2
+++ JarTest.java 2001/03/08 15:17:25 1.3
@@ -63,7 +63,7 @@
public class JarTest extends TaskdefsTest {
private static long jarModifiedDate;
- private static String tempJar = "src/etc/testcases/taskdefs/tmp.jar";
+ private static String tempJar = "tmp.jar";
public JarTest(String name) {
super(name);
@@ -87,14 +87,14 @@
public void test4() {
executeTarget("test4");
- File jarFile = new File(tempJar);
+ File jarFile = new File(getProjectDir(), tempJar);
assert(jarFile.exists());
jarModifiedDate = jarFile.lastModified();
}
public void XXXtest5() {
executeTarget("test5");
- File jarFile = new File(tempJar);
+ File jarFile = new File(getProjectDir(), tempJar);
assertEquals(jarModifiedDate, jarFile.lastModified());
}
}
1.4 +5 -6
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java
Index: MkdirTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MkdirTest.java 2001/01/03 14:18:49 1.3
+++ MkdirTest.java 2001/03/08 15:17:25 1.4
@@ -1,3 +1,5 @@
+package org.apache.tools.ant.taskdefs;
+
/*
* The Apache Software License, Version 1.1
*
@@ -52,8 +54,6 @@
* <http://www.apache.org/>.
*/
-package org.apache.tools.ant.taskdefs;
-
/**
* @author Nico Seessle <[EMAIL PROTECTED]>
*/
@@ -61,8 +61,8 @@
public MkdirTest(String name) {
super(name);
- }
-
+ }
+
public void setUp() {
configureProject("src/etc/testcases/taskdefs/mkdir.xml");
}
@@ -77,12 +77,11 @@
public void test3() {
executeTarget("test3");
- java.io.File f = new
java.io.File("src/etc/testcases/taskdefs/testdir.tmp");
+ java.io.File f = new java.io.File(getProjectDir(), "testdir.tmp");
if (!f.exists() || !f.isDirectory()) {
fail("mkdir failed");
} else {
f.delete();
}
}
-
}
1.5 +16 -6
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java
Index: TaskdefsTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TaskdefsTest.java 2001/02/18 13:44:43 1.4
+++ TaskdefsTest.java 2001/03/08 15:17:25 1.5
@@ -79,12 +79,7 @@
}
protected void expectBuildException(String taskname, String cause) {
- try {
- executeTarget(taskname);
- } catch (org.apache.tools.ant.BuildException ex) {
- return;
- }
- fail("Should throw BuildException because: " + cause);
+ expectSpecificBuildException(taskname, cause, null);
}
protected void expectOutput(String taskname, String output) {
@@ -170,6 +165,21 @@
}
+ protected File getProjectDir() {
+ return project.getBaseDir();
+ }
+
+ protected void expectSpecificBuildException(String taskname, String
cause, String msg) {
+ try {
+ executeTarget(taskname);
+ } catch (org.apache.tools.ant.BuildException ex) {
+ if ((null != msg) && (ex.getMessage() != msg)) {
+ fail("Should throw BuildException because '" + cause + "'
with message '" + msg + "' (received message '" + ex.getMessage() + "'
instead)");
+ }
+ return;
+ }
+ fail("Should throw BuildException because: " + cause);
+ }
private class AntOutputStream extends java.io.OutputStream {
public void write(int b) {
outBuffer.append((char)b);
1.1
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
Index: CopyTest.java
===================================================================
/*
* 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", "Ant", 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 [EMAIL PROTECTED]
*
* 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;
/**
* Tests FileSet using the Copy task.
*
* @author David Rees <[EMAIL PROTECTED]>
*/
public class CopyTest extends TaskdefsTest {
public CopyTest(String name) {
super(name);
}
public void setUp() {
configureProject("src/etc/testcases/taskdefs/copy.xml");
}
public void test1() {
executeTarget("test1");
java.io.File f = new java.io.File(getProjectDir(), "copytest1.tmp");
if ( !f.exists()) {
fail("Copy failed");
}
}
public void tearDown() {
executeTarget("cleanup");
}
public void test2() {
executeTarget("test2");
java.io.File f = new java.io.File(getProjectDir(),
"copytest1dir/copy.xml");
if ( !f.exists()) {
fail("Copy failed");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]