ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/util CollectionUtilsTest.java
Date Thu, 04 Jul 2002 14:54:43 GMT
bodewig     2002/07/04 07:54:43

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Manifest.java
               src/main/org/apache/tools/ant/util Tag: ANT_15_BRANCH
                        CollectionUtils.java JavaEnvUtils.java
               src/testcases/org/apache/tools/ant Tag: ANT_15_BRANCH
                        DirectoryScannerTest.java
               src/testcases/org/apache/tools/ant/types/selectors Tag:
                        ANT_15_BRANCH DateSelectorTest.java
                        DependSelectorTest.java
  Added:       src/testcases/org/apache/tools/ant/util Tag: ANT_15_BRANCH
                        CollectionUtilsTest.java
  Log:
  Various JDK 1.1 fixes.
  
  * superfluous import of java.util.List in JavaEnvUtils
  
  * Manifest#equals relied on Hashtable#equals which isn't implemented
  in JDK 1.1 (accompanied the new helper method with a testcase for
  CollectionUtils).
  
  * A couple of selector tests relied on <touch> actually doing
  something.
  
  * At least on my box, JDK 1.1 will not delete a symbolic link -
  probably because it thinks it is a non-empty directory.  I've disabled
  the testcase that would create the link.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.5  +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java
  
  Index: Manifest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Manifest.java,v
  retrieving revision 1.33.2.4
  retrieving revision 1.33.2.5
  diff -u -r1.33.2.4 -r1.33.2.5
  --- Manifest.java	4 Jul 2002 11:24:10 -0000	1.33.2.4
  +++ Manifest.java	4 Jul 2002 14:54:42 -0000	1.33.2.5
  @@ -680,7 +680,7 @@
   
               Section rhsSection = (Section) rhs;
   
  -            return attributes.equals(rhsSection.attributes);
  +            return CollectionUtils.equals(attributes, rhsSection.attributes);
           }
       }
   
  @@ -988,7 +988,7 @@
               return false;
           }
   
  -        return sections.equals(rhsManifest.sections);
  +        return CollectionUtils.equals(sections, rhsManifest.sections);
       }
   
       /**
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +46 -2     jakarta-ant/src/main/org/apache/tools/ant/util/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/CollectionUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  --- CollectionUtils.java	4 Apr 2002 13:30:00 -0000	1.1
  +++ CollectionUtils.java	4 Jul 2002 14:54:43 -0000	1.1.2.1
  @@ -53,6 +53,7 @@
    */
   package org.apache.tools.ant.util;
   
  +import java.util.Dictionary;
   import java.util.Enumeration;
   import java.util.Vector;
   
  @@ -66,9 +67,9 @@
   public class CollectionUtils {
   
       /**
  -     * Believe it or not, Vector.equals() doesn't do any good in 1.1
  +     * Vector.equals() doesn't do any good in 1.1
        *
  -     * @since 1.1, Ant 1.5
  +     * @since Ant 1.5
        */
       public static boolean equals(Vector v1, Vector v2) {
           if (v1 == v2) {
  @@ -87,6 +88,49 @@
           Enumeration e2 = v2.elements();
           while (e1.hasMoreElements()) {
               if (!e1.nextElement().equals(e2.nextElement())) {
  +                return false;
  +            }
  +        }
  +        
  +        return true;
  +    }
  +
  +    /**
  +     * Hashtable.equals() doesn't do any good in 1.1
  +     *
  +     * <p>Follows the equals contract of Java 2's Map.</p>
  +     *
  +     * @since Ant 1.5
  +     */
  +    public static boolean equals(Dictionary d1, Dictionary d2) {
  +        if (d1 == d2) {
  +            return true;
  +        }
  +        
  +        if (d1 == null || d2 == null) {
  +            return false;
  +        }
  +
  +        if (d1.size() != d2.size()) {
  +            return false;
  +        }
  +
  +        Enumeration e1 = d1.keys();
  +        while (e1.hasMoreElements()) {
  +            Object key = e1.nextElement();
  +            Object value1 = d1.get(key);
  +            Object value2 = d2.get(key);
  +            if (value2 == null || !value1.equals(value2)) {
  +                return false;
  +            }
  +        }
  +        
  +        Enumeration e2 = d2.keys();
  +        while (e2.hasMoreElements()) {
  +            Object key = e2.nextElement();
  +            Object value1 = d2.get(key);
  +            Object value2 = d1.get(key);
  +            if (value2 == null || !value1.equals(value2)) {
                   return false;
               }
           }
  
  
  
  1.3.2.5   +0 -1      jakarta-ant/src/main/org/apache/tools/ant/util/JavaEnvUtils.java
  
  Index: JavaEnvUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/util/JavaEnvUtils.java,v
  retrieving revision 1.3.2.4
  retrieving revision 1.3.2.5
  diff -u -r1.3.2.4 -r1.3.2.5
  --- JavaEnvUtils.java	28 Jun 2002 06:10:47 -0000	1.3.2.4
  +++ JavaEnvUtils.java	4 Jul 2002 14:54:43 -0000	1.3.2.5
  @@ -56,7 +56,6 @@
   import org.apache.tools.ant.taskdefs.condition.Os;
   import java.io.File;
   import java.util.Vector;
  -import java.util.List;
   
   /**
    * A set of helper methods related to locating executables or checking
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.2   +7 -2      jakarta-ant/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java
  
  Index: DirectoryScannerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -r1.4.2.1 -r1.4.2.2
  --- DirectoryScannerTest.java	10 May 2002 12:53:58 -0000	1.4.2.1
  +++ DirectoryScannerTest.java	4 Jul 2002 14:54:43 -0000	1.4.2.2
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant;
   
   import org.apache.tools.ant.taskdefs.condition.Os;
  +import org.apache.tools.ant.util.JavaEnvUtils;
   
   import junit.framework.TestCase;
   import junit.framework.AssertionFailedError;
  @@ -72,7 +73,8 @@
   
   
       // keep track of what operating systems are supported here.
  -    private boolean supportsSymlinks = Os.isFamily("unix");
  +    private boolean supportsSymlinks = Os.isFamily("unix") 
  +        && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1);
   
       /**
        * Test case for setFollowLinks() and associated funtionality.
  @@ -154,7 +156,10 @@
                              !haveTaskdefsPackage);
                   
               } finally {
  -                (new File("src/main/org/apache/tools/ThisIsALink")).delete();
  +                File f = new File("src/main/org/apache/tools/ThisIsALink");
  +                if (!f.delete()) {
  +                    throw new RuntimeException("Failed to delete "+f);
  +                }
               } 
           }
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +24 -21    jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java
  
  Index: DateSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DateSelectorTest.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ DateSelectorTest.java	4 Jul 2002 14:54:43 -0000	1.1.2.2
  @@ -204,11 +204,13 @@
               results = selectionString(s);
               assertEquals("TTTTTTTTTTTT", results);
   
  -            s = (DateSelector)getInstance();
  -            s.setDatetime("11/21/2001 4:54 AM");
  -            s.setWhen(before);
  -            results = selectionString(s);
  -            assertEquals("TFTFFFFFFFFT", results);
  +            if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
  +                s = (DateSelector)getInstance();
  +                s.setDatetime("11/21/2001 4:54 AM");
  +                s.setWhen(before);
  +                results = selectionString(s);
  +                assertEquals("TFTFFFFFFFFT", results);
  +
   /*
               s = (DateSelector)getInstance();
               s.setDatetime("11/21/2001 4:55 AM");
  @@ -237,23 +239,24 @@
               results = selectionString(s);
               assertEquals("TTFFTFFFTTTT", results);
   */
  -            s = (DateSelector)getInstance();
  -            s.setDatetime("11/21/2001 4:56 AM");
  -            s.setWhen(after);
  -            results = selectionString(s);
  -            assertEquals("TFFTFTTTFFFT", results);
  +                s = (DateSelector)getInstance();
  +                s.setDatetime("11/21/2001 4:56 AM");
  +                s.setWhen(after);
  +                results = selectionString(s);
  +                assertEquals("TFFTFTTTFFFT", results);
   
  -            s = (DateSelector)getInstance();
  -            Parameter param1 = new Parameter();
  -            Parameter param2 = new Parameter();
  -            param1.setName("datetime");
  -            param1.setValue("11/21/2001 4:56 AM");
  -            param2.setName("when");
  -            param2.setValue("after");
  -            Parameter[] params = {param1,param2};
  -            s.setParameters(params);
  -            results = selectionString(s);
  -            assertEquals("TFFTFTTTFFFT", results);
  +                s = (DateSelector)getInstance();
  +                Parameter param1 = new Parameter();
  +                Parameter param2 = new Parameter();
  +                param1.setName("datetime");
  +                param1.setValue("11/21/2001 4:56 AM");
  +                param2.setName("when");
  +                param2.setValue("after");
  +                Parameter[] params = {param1,param2};
  +                s.setParameters(params);
  +                results = selectionString(s);
  +                assertEquals("TFFTFTTTFFFT", results);
  +            }
   
           }
           finally {
  
  
  
  1.1.2.2   +17 -15    jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java
  
  Index: DependSelectorTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DependSelectorTest.java	31 May 2002 22:31:31 -0000	1.1.2.1
  +++ DependSelectorTest.java	4 Jul 2002 14:54:43 -0000	1.1.2.2
  @@ -141,21 +141,23 @@
               results = selectionString(s);
               assertEquals("FFFFFFFFFFFF", results);
   
  -            s = (DependSelector)getInstance();
  -            s.setTargetdir(basedirname);
  -            m = s.createMapper();
  -            m.setType(merge);
  -            m.setTo("asf-logo.gif.gz");
  -            results = selectionString(s);
  -            assertEquals("TFFFFTTTFFFF", results);
  -
  -            s = (DependSelector)getInstance();
  -            s.setTargetdir(basedirname);
  -            m = s.createMapper();
  -            m.setType(merge);
  -            m.setTo("asf-logo.gif.bz2");
  -            results = selectionString(s);
  -            assertEquals("TTFTTTTTTTTT", results);
  +            if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
  +                s = (DependSelector)getInstance();
  +                s.setTargetdir(basedirname);
  +                m = s.createMapper();
  +                m.setType(merge);
  +                m.setTo("asf-logo.gif.gz");
  +                results = selectionString(s);
  +                assertEquals("TFFFFTTTFFFF", results);
  +                
  +                s = (DependSelector)getInstance();
  +                s.setTargetdir(basedirname);
  +                m = s.createMapper();
  +                m.setType(merge);
  +                m.setTo("asf-logo.gif.bz2");
  +                results = selectionString(s);
  +                assertEquals("TTFTTTTTTTTT", results);
  +            }
   
               s = (DependSelector)getInstance();
               s.setTargetdir(basedirname + "/tar/bz2");
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +139 -0    jakarta-ant/src/testcases/org/apache/tools/ant/util/Attic/CollectionUtilsTest.java
  
  
  
  

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


Mime
View raw message