ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/testcases/org/apache/tools/ant/taskdefs GetTest.java
Date Fri, 25 Feb 2005 22:23:07 GMT
mbenson     2005/02/25 14:23:07

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Get.java
               src/etc/testcases/taskdefs get.xml
               src/testcases/org/apache/tools/ant/taskdefs GetTest.java
  Log:
  get with usetimestamp did not work on Java 1.2 .
  
  Revision  Changes    Path
  1.758     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.757
  retrieving revision 1.758
  diff -u -r1.757 -r1.758
  --- WHATSNEW	25 Feb 2005 11:34:10 -0000	1.757
  +++ WHATSNEW	25 Feb 2005 22:23:06 -0000	1.758
  @@ -345,6 +345,8 @@
   * <javac debug="false"> created an invalid command line when running
     the Symantec Java compiler.
   
  +* Get with usetimestamp did not work on Java 1.2.
  +
   Changes from Ant 1.6.1 to Ant 1.6.2
   ===================================
   
  
  
  
  1.48      +9 -2      ant/src/main/org/apache/tools/ant/taskdefs/Get.java
  
  Index: Get.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Get.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Get.java	6 Jan 2005 12:05:05 -0000	1.47
  +++ Get.java	25 Feb 2005 22:23:07 -0000	1.48
  @@ -21,6 +21,7 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.util.FileUtils;
  +import org.apache.tools.ant.util.JavaEnvUtils;
   
   import java.io.File;
   import java.io.FileOutputStream;
  @@ -137,7 +138,7 @@
           URLConnection connection = source.openConnection();
           //modify the headers
           //NB: things like user authentication could go in here too.
  -        if (useTimestamp && hasTimestamp) {
  +        if (hasTimestamp) {
               connection.setIfModifiedSince(timestamp);
           }
           // prepare Java 1.1 style credentials
  @@ -160,13 +161,19 @@
               HttpURLConnection httpConnection
                       = (HttpURLConnection) connection;
               if (httpConnection.getResponseCode()
  -                    == HttpURLConnection.HTTP_NOT_MODIFIED)  {
  +                    == HttpURLConnection.HTTP_NOT_MODIFIED
  +                //workaround:  doesn't work on 1.2
  +                || (hasTimestamp
  +                && JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)
  +                && timestamp > httpConnection.getLastModified())) {
                   //not modified so no file download. just return
                   //instead and trace out something so the user
                   //doesn't think that the download happened when it
                   //didn't
                   log("Not modified - so not downloaded", logLevel);
                   return false;
  +                // also, if timestamp is roughly >= now, HTTP_NOT_MODIFIED is _not_
  +                // returned... We may want to remove the 1.2 qualifier above.
               }
               // test for 401 result (HTTP only)
               if (httpConnection.getResponseCode()
  
  
  
  1.5       +44 -0     ant/src/etc/testcases/taskdefs/get.xml
  
  Index: get.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/get.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- get.xml	8 May 2001 09:35:27 -0000	1.4
  +++ get.xml	25 Feb 2005 22:23:07 -0000	1.5
  @@ -24,6 +24,50 @@
   
     <target name="test6">
       <get src="http://www.apache.org/" dest="get.tmp"/>
  +
  +    <fileset id="t6" file="get.tmp" />
  +    <pathconvert property="t6" refid="t6" setonempty="false" />
  +
  +    <fail message="get failed">
  +      <condition>
  +        <not>
  +          <isset property="t6" />
  +        </not>
  +      </condition>
  +    </fail>
  +  </target>
  +
  +  <target name="testUseTimestamp">
  +    <property name="pat" value="yyyyMMddHHmm" />
  +
  +    <tstamp>
  +      <format property="dt" pattern="${pat}" offset="-90" unit="second" />
  +    </tstamp>
  +
  +    <touch file="get.tmp" datetime="${dt}" pattern="${pat}" />
  +
  +    <get src="http://www.apache.org/" dest="get.tmp"
  +         usetimestamp="true" verbose="true" />
  +
  +    <fileset id="ts" file="get.tmp">
  +      <date when="equal" datetime="${dt}" pattern="${pat}" />
  +    </fileset>
  +
  +    <pathconvert property="ts" refid="ts" setonempty="false" />
  +
  +    <fail message="get w/ timestamp should have failed.">
  +      <condition>
  +        <not>
  +          <isset property="ts" />
  +        </not>
  +      </condition>
  +    </fail>
  +  </target>
  +
  +  <target name="cleanup">
  +    <delete>
  +      <fileset dir="${basedir}" includes="get.tmp" />
  +    </delete>
     </target>
   
   </project>
  
  
  
  1.12      +7 -6      ant/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java
  
  Index: GetTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- GetTest.java	9 Mar 2004 16:48:57 -0000	1.11
  +++ GetTest.java	25 Feb 2005 22:23:07 -0000	1.12
  @@ -32,6 +32,10 @@
           configureProject("src/etc/testcases/taskdefs/get.xml");
       }
   
  +    public void tearDown() {
  +        executeTarget("cleanup");
  +    }
  +
       public void test1() {
           expectBuildException("test1", "required argument missing");
       }
  @@ -54,13 +58,10 @@
   
       public void test6() {
           executeTarget("test6");
  -        java.io.File f = new File(getProjectDir(), "get.tmp");
  -        if (!f.exists()) {
  -            fail("get failed");
  -        } else {
  -            f.delete();
  -        }
  +    }
   
  +    public void testUseTimestamp() {
  +        executeTarget("testUseTimestamp");
       }
   
   }
  
  
  

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


Mime
View raw message