Browse Source

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
master
Antoine Levy-Lambert 22 years ago
parent
commit
760f5d26a1
1 changed files with 20 additions and 7 deletions
  1. +20
    -7
      src/testcases/org/apache/tools/ant/util/FileUtilsTest.java

+ 20
- 7
src/testcases/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -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"));
}

/**


Loading…
Cancel
Save