stevel 01/12/07 23:36:16
Modified: src/testcases/org/apache/tools/ant/taskdefs CopyTest.java
Log:
Added a test for time dependent copy -and the ability to override it.
This is long for a test (=harder to tell which assert failed), but if you are going to sleep
between touches then you should make the most of the test.
Revision Changes Path
1.3 +34 -2 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java
Index: CopyTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CopyTest.java 2001/11/14 12:25:30 1.2
+++ CopyTest.java 2001/12/08 07:36:16 1.3
@@ -55,6 +55,8 @@
package org.apache.tools.ant.taskdefs;
import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.Project;
+import java.io.File;
/**
* Tests FileSet using the Copy task.
@@ -73,7 +75,7 @@
public void test1() {
executeTarget("test1");
- java.io.File f = new java.io.File(getProjectDir(), "copytest1.tmp");
+ File f = new File(getProjectDir(), "copytest1.tmp");
if ( !f.exists()) {
fail("Copy failed");
}
@@ -85,9 +87,39 @@
public void test2() {
executeTarget("test2");
- java.io.File f = new java.io.File(getProjectDir(), "copytest1dir/copy.xml");
+ File f = new File(getProjectDir(), "copytest1dir/copy.xml");
if ( !f.exists()) {
fail("Copy failed");
}
+ }
+
+ public void test3() {
+ executeTarget("test3");
+ File file3 = new File(getProjectDir(), "copytest3.tmp");
+ assertTrue(file3.exists());
+ File file3a = new File(getProjectDir(), "copytest3a.tmp");
+ assertTrue(file3a.exists());
+ File file3b = new File(getProjectDir(), "copytest3b.tmp");
+ assertTrue(file3b.exists());
+ File file3c = new File(getProjectDir(), "copytest3c.tmp");
+ assertTrue(file3c.exists());
+
+ //file length checks rely on touch generating a zero byte file
+ if(file3.length()==0) {
+ fail("could not overwrite an existing, older file");
+ }
+ if(file3c.length()!=0) {
+ fail("could not force overwrite an existing, newer file");
+ }
+ if(file3b.length()==0) {
+ fail("unexpectedly overwrote an existing, newer file");
+ }
+
+ //file time checks for java1.2+
+ if (Project.getJavaVersion() != Project.JAVA_1_1) {
+ assertTrue(file3a.lastModified()==file3.lastModified());
+ assertTrue(file3c.lastModified()<file3a.lastModified());
+ }
+
}
}
--
To unsubscribe, e-mail: <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
|