From 760f5d26a1695095eecf18a235013fb43c9621a5 Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Mon, 23 Jun 2003 16:18:00 +0000 Subject: [PATCH] Make FileUtilsTest pass on my machine (Windows 2000, JDK 1.4.1_02) 2 changes : - there was no luck with setting the date/time of a file to 123456 milliseconds since the epoch Instead, I set the date time of the file to current time + one day this works. - I changed the test toURI, specs beginning with / or \\ turn URIs beginning with file:///C:/ Note : I observed an error in the date/time returned by java and what I would expect theoretically under Win 2000 and JDK 1.4.1_02 of 16,344,000 (16 millions of milliseconds), slightly more than 4 and a half hours. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274693 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/util/FileUtilsTest.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java index 116b0e5c7..e5fa244fc 100644 --- a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java +++ b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java @@ -119,7 +119,12 @@ public class FileUtilsTest extends TestCase { } - fu.setFileLastModified(removeThis, 123456); + // number of milliseconds in a day + final int millisperday=24 * 3600 * 1000; + // in a previous version, the date of the file was set to 123456 + // milliseconds since 01.01.1970 + // it did not work on a computer running JDK 1.4.1_02 + Windows 2000 + fu.setFileLastModified(removeThis, secondModTime + millisperday); long thirdModTime = removeThis.lastModified(); try { Class.forName("java.lang.ThreadLocal"); @@ -421,17 +426,25 @@ public class FileUtilsTest extends TestCase { * test toUri */ public void testToURI() { + String dosRoot = null; + if (Os.isFamily("dos")) { + dosRoot = "C:/"; + } + else + { + dosRoot = ""; + } if (Os.isFamily("dos")) { assertEquals("file:///C:/foo", fu.toURI("c:\\foo")); } - assertEquals("file:///foo", fu.toURI("/foo")); + assertEquals("file:///" + dosRoot + "foo", fu.toURI("/foo")); assertEquals("file:./foo", fu.toURI("./foo")); - assertEquals("file:///foo", fu.toURI("\\foo")); + assertEquals("file:///" + dosRoot + "foo", fu.toURI("\\foo")); assertEquals("file:./foo", fu.toURI(".\\foo")); - assertEquals("file:///foo%20bar", fu.toURI("/foo bar")); - assertEquals("file:///foo%20bar", fu.toURI("\\foo bar")); - assertEquals("file:///foo%23bar", fu.toURI("/foo#bar")); - assertEquals("file:///foo%23bar", fu.toURI("\\foo#bar")); + assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("/foo bar")); + assertEquals("file:///" + dosRoot + "foo%20bar", fu.toURI("\\foo bar")); + assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("/foo#bar")); + assertEquals("file:///" + dosRoot + "foo%23bar", fu.toURI("\\foo#bar")); } /**