ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant PathTest.java
Date Fri, 14 Jul 2000 07:14:44 GMT
bodewig     00/07/14 00:14:44

  Modified:    src/main/org/apache/tools/ant Path.java
               src/main/org/apache/tools/ant/taskdefs Java.java
               src/testcases/org/apache/tools/ant PathTest.java
  Log:
  Remove duplicate entries in Path.
  
  Revision  Changes    Path
  1.2       +20 -2     jakarta-ant/src/main/org/apache/tools/ant/Path.java
  
  Index: Path.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Path.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Path.java	2000/07/13 16:35:04	1.1
  +++ Path.java	2000/07/14 07:14:42	1.2
  @@ -107,19 +107,37 @@
        */
       public void setLocation(String location) {
           if (location != null && location.length() > 0) {
  -            definition.addElement(translateFile(location));
  +            String element = translateFile(location);
  +            if (definition.indexOf(element) == -1) {
  +                definition.addElement(element);
  +            }
           }
       }
   
   
       /**
  +     * Append the contents of the other Path instance to this.
  +     */
  +    public void append(Path other) {
  +        String[] l = other.list();
  +        for (int i=0; i<l.length; i++) {
  +            if (definition.indexOf(l[i]) == -1) {
  +                definition.addElement(l[i]);
  +            }
  +        }
  +    }
  +
  +    /**
        * Parses a path definition and creates single PathElements.
        * @param path the path definition.
        */
       public void setPath(String path) {
           final Vector elements = translatePath(path);
           for (int i=0; i < elements.size(); i++) {
  -            definition.addElement(elements.elementAt(i));
  +            String element = (String) elements.elementAt(i);
  +            if (definition.indexOf(element) == -1) {
  +                definition.addElement(element);
  +            }
           }
       }
   
  
  
  
  1.10      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
  
  Index: Java.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Java.java	2000/07/13 16:35:06	1.9
  +++ Java.java	2000/07/14 07:14:42	1.10
  @@ -130,7 +130,7 @@
           if (this.classpath == null) {
               this.classpath = s;
           } else {
  -            this.classpath.setPath(s.toString());
  +            this.classpath.append(s);
           }
       }
       
  
  
  
  1.2       +33 -0     jakarta-ant/src/testcases/org/apache/tools/ant/PathTest.java
  
  Index: PathTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/PathTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PathTest.java	2000/07/13 16:35:08	1.1
  +++ PathTest.java	2000/07/14 07:14:43	1.2
  @@ -167,6 +167,39 @@
           p.setPath("\\d;\\e");
           l = p.list();
           assertEquals("5 after setPath", 5, l.length);
  +        p.append(new Path("\\f"));
  +        l = p.list();
  +        assertEquals("6 after append", 6, l.length);
  +    }
  +
  +    public void testEmpyPath() {
  +        Path p = new Path("");
  +        String[] l = p.list();
  +        assertEquals("0 after construction", 0, l.length);
  +        p.setLocation("");
  +        l = p.list();
  +        assertEquals("0 after setLocation", 0, l.length);
  +        p.setPath("");
  +        l = p.list();
  +        assertEquals("0 after setPath", 0, l.length);
  +        p.append(new Path());
  +        l = p.list();
  +        assertEquals("0 after append", 0, l.length);
  +    }
  +
  +    public void testUnique() {
  +        Path p = new Path("/a:/a");
  +        String[] l = p.list();
  +        assertEquals("1 after construction", 1, l.length);
  +        p.setLocation("\\a");
  +        l = p.list();
  +        assertEquals("1 after setLocation", 1, l.length);
  +        p.setPath("\\a;/a");
  +        l = p.list();
  +        assertEquals("1 after setPath", 1, l.length);
  +        p.append(new Path("/a;\\a:\\a"));
  +        l = p.list();
  +        assertEquals("1 after append", 1, l.length);
       }
   
   }
  
  
  

Mime
View raw message