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/etc/testcases/taskdefs/optional/net ftp.xml
Date Wed, 06 Aug 2003 12:24:43 GMT
antoine     2003/08/06 05:24:42

  Modified:    src/testcases/org/apache/tools/ant/taskdefs/optional/net
                        FTPTest.java
               src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
               src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Issue a warning message indicating that selectors within filesets
  are not supported in the ftp task when the fileset is remote
  (all actions except put)
  PR: 18280
  
  Revision  Changes    Path
  1.5       +36 -24    ant/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
  
  Index: FTPTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FTPTest.java	6 Aug 2003 10:58:24 -0000	1.4
  +++ FTPTest.java	6 Aug 2003 12:24:42 -0000	1.5
  @@ -54,14 +54,16 @@
   package org.apache.tools.ant.taskdefs.optional.net;
   
   import org.apache.tools.ant.BuildFileTest;
  +import org.apache.tools.ant.DirectoryScanner;
  +import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.taskdefs.optional.net.FTP;
   import org.apache.tools.ant.util.JavaEnvUtils;
   import org.apache.tools.ant.taskdefs.condition.Os;
   
   import java.io.File;
   import java.io.IOException;
  -import java.util.TreeSet;
  -import java.util.Iterator;
  +import java.util.Arrays;
  +
   import org.apache.commons.net.ftp.FTPClient;
   
   public class FTPTest extends BuildFileTest{
  @@ -203,7 +205,27 @@
               }
           }
       }
  -
  +    public void testGetWithSelector() {
  +        expectLogContaining("ftp-get-with-selector",
  +            "selectors are not supported in remote filesets");
  +        FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector");
  +        DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject());
  +        dsDestination.scan();
  +        String [] sortedDestinationDirectories = dsDestination.getIncludedDirectories();
  +        String [] sortedDestinationFiles = dsDestination.getIncludedFiles();
  +        for (int counter = 0; counter < sortedDestinationDirectories.length; counter++)
{
  +            sortedDestinationDirectories[counter] =
  +                sortedDestinationDirectories[counter].replace(File.separatorChar, '/');
  +        }
  +        for (int counter = 0; counter < sortedDestinationFiles.length; counter++) {
  +            sortedDestinationFiles[counter] =
  +                sortedDestinationFiles[counter].replace(File.separatorChar, '/');
  +        }
  +        FileSet fsSource =  (FileSet) getProject().getReference("fileset-source-without-selector");
  +        DirectoryScanner dsSource = fsSource.getDirectoryScanner(getProject());
  +        dsSource.scan();
  +        compareFiles(dsSource, sortedDestinationFiles, sortedDestinationDirectories);
  +    }
       public void testAllowSymlinks() {
           if (!supportsSymlinks) {
               return;
  @@ -501,7 +523,7 @@
   
       }
   
  -    private void compareFiles(FTP.FTPDirectoryScanner ds, String[] expectedFiles,
  +    private void compareFiles(DirectoryScanner ds, String[] expectedFiles,
                                 String[] expectedDirectories) {
           String includedFiles[] = ds.getIncludedFiles();
           String includedDirectories[] = ds.getIncludedDirectories();
  @@ -510,30 +532,20 @@
           assertEquals("directories present: ", expectedDirectories.length,
                        includedDirectories.length);
   
  -        TreeSet files = new TreeSet();
           for (int counter=0; counter < includedFiles.length; counter++) {
  -            files.add(includedFiles[counter].replace(File.separatorChar, '/'));
  +            includedFiles[counter] = includedFiles[counter].replace(File.separatorChar,
'/');
           }
  -        TreeSet directories = new TreeSet();
  +        Arrays.sort(includedFiles);
           for (int counter=0; counter < includedDirectories.length; counter++) {
  -            directories.add(includedDirectories[counter]
  -                            .replace(File.separatorChar, '/'));
  +            includedDirectories[counter] = includedDirectories[counter]
  +                            .replace(File.separatorChar, '/');
           }
  -
  -        String currentfile;
  -        Iterator i = files.iterator();
  -        int counter = 0;
  -        while (i.hasNext()) {
  -            currentfile = (String) i.next();
  -            assertEquals(expectedFiles[counter], currentfile);
  -            counter++;
  -        }
  -        String currentdirectory;
  -        Iterator dirit = directories.iterator();
  -        counter = 0;
  -        while (dirit.hasNext()) {
  -            currentdirectory = (String) dirit.next();
  -            assertEquals(expectedDirectories[counter], currentdirectory);
  +        Arrays.sort(includedDirectories);
  +        for (int counter=0; counter < includedFiles.length; counter++) {
  +            assertEquals(expectedFiles[counter], includedFiles[counter]);
  +        }
  +        for (int counter=0; counter < includedDirectories.length; counter++) {
  +            assertEquals(expectedDirectories[counter], includedDirectories[counter]);
               counter++;
           }
       }
  
  
  
  1.44      +5 -0      ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- FTP.java	6 Aug 2003 10:58:24 -0000	1.43
  +++ FTP.java	6 Aug 2003 12:24:42 -0000	1.44
  @@ -667,6 +667,11 @@
           if (action == SEND_FILES) {
               ds = fs.getDirectoryScanner(getProject());
           } else {
  +            // warn that selectors are not supported
  +            if (fs.getSelectors(getProject()).length != 0) {
  +                getProject().log("selectors are not supported in remote filesets",
  +                    Project.MSG_WARN);
  +            }
               ds = new FTPDirectoryScanner(ftp);
               fs.setupDirectoryScanner(ds, getProject());
               ds.scan();
  
  
  
  1.3       +22 -0     ant/src/etc/testcases/taskdefs/optional/net/ftp.xml
  
  Index: ftp.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/optional/net/ftp.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ftp.xml	6 Aug 2003 10:27:15 -0000	1.2
  +++ ftp.xml	6 Aug 2003 12:24:42 -0000	1.3
  @@ -6,18 +6,40 @@
       <property name="ftp.port" value="21" />
       <property name="ftp.password" value="sunshine" />
       <property name="tmp.dir" location="tmp"/>
  +    <property name="tmp.get.dir" location="tmp.get"/>
       <property name="ftp.filesep" value="/"/>
  +    <fileset dir="${tmp.get.dir}" id="fileset-destination-with-selector">
  +        <include name="alpha/**"/>
  +        <filename name="**/alpha.xml" />
  +    </fileset>
  +    <fileset dir="${tmp.dir}" id="fileset-source-without-selector">
  +        <include name="alpha/**"/>
  +    </fileset>
  +    <fileset dir="${tmp.get.dir}" id="fileset-destination-without-selector">
  +        <include name="alpha/**"/>
  +    </fileset>
       <target name="setup">
  +        <mkdir dir="${tmp.get.dir}"/>
           <mkdir dir="${tmp.dir}/alpha/beta/gamma"/>
           <touch file="${tmp.dir}/alpha/beta/gamma/gamma.xml"/>
           <touch file="${tmp.dir}/alpha/beta/beta.xml"/>
       </target>
  +    <target name="ftp-get-with-selector">
  +        <ftp action="get"
  +            server="${ftp.host}"
  +            userid="${ftp.user}"
  +            password="${ftp.password}"
  +            remotedir="${tmp.dir}">
  +            <fileset refid="fileset-destination-with-selector"/>
  +        </ftp>
  +    </target>
       <target name="children-of-excluded-dir-setup" depends="setup">
           <mkdir dir="${tmp.dir}/delta"/>
           <touch file="${tmp.dir}/delta/delta.xml"/>
       </target>
       <target name="cleanup">
           <delete dir="${tmp.dir}" quiet="true"/>
  +        <delete dir="${tmp.get.dir}" quiet="true"/>
       </target>
       <target name="symlink-setup" depends="setup">
           <mkdir dir="${tmp.dir}/epsilon/gamma"/>
  
  
  

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


Mime
View raw message