From 48aa9d115e6de65ae08b8828117471b34a281f79 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Sat, 8 Dec 2001 07:36:16 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270096 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/CopyTest.java | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java index 2f8df2d64..77b3341d9 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java @@ -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 class CopyTest extends BuildFileTest { 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 class CopyTest extends BuildFileTest { 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()