ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/util FileUtilsTest.java
Date Mon, 23 Jun 2003 16:18:02 GMT
antoine     2003/06/23 09:18:00

  Modified:    src/testcases/org/apache/tools/ant/util FileUtilsTest.java
  Log:
  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.
  
  Revision  Changes    Path
  1.17      +20 -7     ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
  
  Index: FileUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FileUtilsTest.java	19 May 2003 15:55:23 -0000	1.16
  +++ FileUtilsTest.java	23 Jun 2003 16:18:00 -0000	1.17
  @@ -119,7 +119,12 @@
           }
           
   
  -        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 @@
        * 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"));
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message