cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-28 Thread scohen
scohen  2005/05/28 20:01:10

  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:
  convert serverLanguageCodeConfig attribute to use EnumeratedAttribute pattern
  
  Revision  ChangesPath
  1.18  +21 -5 
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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FTPTest.java  28 May 2005 17:05:44 -  1.17
  +++ FTPTest.java  29 May 2005 03:01:10 -  1.18
  @@ -25,6 +25,7 @@
   
   import org.apache.commons.net.ftp.FTPClient;
   import org.apache.tools.ant.BuildEvent;
  +import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.BuildFileTest;
   import org.apache.tools.ant.DefaultLogger;
   import org.apache.tools.ant.DirectoryScanner;
  @@ -661,7 +662,7 @@
*/
   public void testConfiguration1() {
   int[] expectedCounts = {
  -1,1,0,1,0,0
  +1,1,0,1,0,0,0
   };
   performConfigTest("configuration.1", expectedCounts);
   
  @@ -672,7 +673,7 @@
*/
   public void testConfiguration2() {
   int[] expectedCounts = {
  -1,0,0,1,1,0
  +1,0,0,1,1,0,0
   };
   performConfigTest("configuration.2", expectedCounts);
   
  @@ -683,17 +684,31 @@
*/
   public void testConfiguration3() {
   int[] expectedCounts = {
  -1,0,1,0,0,1
  +1,0,1,0,0,1,0
   };
   performConfigTest("configuration.3", expectedCounts);
   
   }
  +
  +public void testConfigurationLang() {
  +int[] expectedCounts = {
  +1,1,0,0,0,0,1
  +};
  +performConfigTest("configuration.lang.good", expectedCounts);
  +
  +try {
  +performConfigTest("configuration.lang.bad", expectedCounts);
  +fail("BuildException Expected");
  +} catch (Exception bx) {
  +assertTrue(bx instanceof BuildException); 
  +}
  +}
   /**
* Tests the systemTypeKey attribute.
*/
   public void testConfigurationNone() {
   int[] expectedCounts = {
  -0,0,0,0,0,0
  +0,0,0,0,0,0,0
   };
   performConfigTest("configuration.none", expectedCounts);

  @@ -706,7 +721,8 @@
   "custom config: system key = UNIX",
   "custom config: server time zone ID = " + 
getProject().getProperty("ftp.server.timezone"),
   "custom config: system key = WINDOWS",
  -"custom config: default date format = /MM/dd HH:mm" 
  +"custom config: default date format = /MM/dd HH:mm",
  +"custom config: server language code = de" 
   
   };
   LogCounter counter = new LogCounter();
  
  
  
  1.76  +42 -7 
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.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- FTP.java  28 May 2005 17:05:44 -  1.75
  +++ FTP.java  29 May 2005 03:01:10 -  1.76
  @@ -16,9 +16,6 @@
*/
   package org.apache.tools.ant.taskdefs.optional.net;
   
  -import org.apache.commons.net.ftp.FTPClient;
  -import org.apache.commons.net.ftp.FTPFile;
  -import org.apache.commons.net.ftp.FTPReply;
   import java.io.BufferedInputStream;
   import java.io.BufferedOutputStream;
   import java.io.BufferedWriter;
  @@ -29,16 +26,22 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.util.Collection;
   import java.util.Enumeration;
   import java.util.HashMap;
  -import java.util.Hashtable;
   import java.util.HashSet;
  +import java.util.Hashtable;
  +import java.util.Iterator;
   import java.util.Locale;
   import java.util.Map;
   import java.util.Set;
   import java.util.StringTokenizer;
   import java.util.Vector;
   
  +import org.apache.commons.net.ftp.FTPClient;
  +import org.apache.commons.net.ftp.FTPClientConfig;
  +import org.apache.commons.net.ftp.FTPFile;
  +import org.apache.commons.net.ftp.FTPReply;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Project;
  @@ -118,7 +121,7 @@
   private FTPSystemType systemTypeKey = FTPSystemTy

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-28 Thread scohen
scohen  2005/05/28 10:05:44

  Modified:src/main/org/apache/tools/ant/taskdefs/optional/net
FTPConfigurator.java FTP.java
   src/testcases/org/apache/tools/ant/taskdefs/optional/net
FTPTest.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Convert ftp task systemTypeKey and timestampGranularity attributes to using 
the EnumeratedAttribute pattern
  and add some JUnit tests of the new configuration stuff.
  
  Revision  ChangesPath
  1.3   +4 -1  
ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java
  
  Index: FTPConfigurator.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPConfigurator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FTPConfigurator.java  14 May 2005 13:14:14 -  1.2
  +++ FTPConfigurator.java  28 May 2005 17:05:44 -  1.3
  @@ -37,14 +37,17 @@
* @return the client as configured.
*/
   static FTPClient configure(FTPClient client, FTP task) {
  +task.log("custom configuration", Project.MSG_VERBOSE);
   FTPClientConfig config;
   String systemTypeKey = task.getSystemTypeKey(); 
  -if (systemTypeKey != null) {
  +if (systemTypeKey != null && !"".equals(systemTypeKey)) {
   config = new FTPClientConfig(systemTypeKey);
   task.log("custom config: system key = " 
   + systemTypeKey, Project.MSG_VERBOSE);
   } else {
   config = new FTPClientConfig();
  +task.log("custom config: system key = default (UNIX)", 
  +Project.MSG_VERBOSE);
   }
   
   String defaultDateFormatConfig = task.getDefaultDateFormatConfig();
  
  
  
  1.75  +91 -33
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.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- FTP.java  22 May 2005 18:48:42 -  1.74
  +++ FTP.java  28 May 2005 17:05:44 -  1.75
  @@ -101,6 +101,7 @@
   private boolean verbose = false;
   private boolean newerOnly = false;
   private long timeDiffMillis = 0;
  +private long granularityMillis = 0L;
   private boolean timeDiffAuto = false;
   private int action = SEND_FILES;
   private Vector filesets = new Vector();
  @@ -114,14 +115,13 @@
   private boolean preserveLastModified = false;
   private String chmod = null;
   private String umask = null;
  -private String systemTypeKey = null;
  +private FTPSystemType systemTypeKey = FTPSystemType.getDefault();
   private String defaultDateFormatConfig = null;
   private String recentDateFormatConfig = null;
   private String serverLanguageCodeConfig = null;
   private String serverTimeZoneConfig = null;
   private String shortMonthNamesConfig = null;
  -private String timestampGranularity = null;
  -private long serverTimestampGranularity = 0L;
  +private Granularity timestampGranularity = Granularity.getDefault();
   private boolean isConfigurationSet = false;
   
   protected static final String[] ACTION_STRS = {
  @@ -1268,8 +1268,8 @@
* the default value of null will be kept.
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
  -public void setSystemTypeKey(String systemKey) {
  -if (systemKey != null && !systemKey.equals(""))
  +public void setSystemTypeKey(FTPSystemType systemKey) {
  +if (systemKey != null && !systemKey.getValue().equals(""))
   {
   this.systemTypeKey = systemKey;
   configurationHasBeenSet();
  @@ -1361,7 +1361,7 @@
* @return Returns the systemTypeKey.
*/
   String getSystemTypeKey() {
  -return systemTypeKey;
  +return systemTypeKey.getValue();
   }
   /**
* @return Returns the defaultDateFormatConfig.
  @@ -1396,13 +1396,13 @@
   /**
* @return Returns the timestampGranularity.
*/
  -String getTimestampGranularity() {
  +Granularity getTimestampGranularity() {
   return timestampGranularity;
   }
   /**
* @param timestampGranularity The timestampGranularity to set.
*/
  -public void setTimestampGranularity(String timestampGranularity) {
  +public void setTimestampGranularity(Granularity timestampGranularity) {
   if (null == timestampGranularity || "".equals(timestampGranularity)) 
{
   return;
   }
  @@ -1517,29 +1517,8 @@
   }
   } else {
   if (this.newerOnl

Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-27 Thread Antoine Levy-Lambert

Steve Cohen wrote:

Antoine:  OK, I've taken a look.  Here is the problem, or maybe I 
don't understand EnumeratedAttribute fully.


In response to a suggestion of Steve Loughran the other day, I've 
implemented all of my new attributes with the convention that a value 
of "" means "Don't set the attribute - leave the default value in 
place". This was to accomodate Steve's suggestion of wanting 
property-file driven scripts.


Such a script would define

An optional property file could define

timestampGranularity=MINUTE

or

timestampGranularity=NONE.

If neither specified, the default to be used (whose value varies 
depending on the chosen action).


I'm having difficulty understanding how this convention would fit into 
the pattern of EnumeratedAttribute.  There may be such a way that I'm 
just not understanding.  I'm still open to whatever suggestions you 
might have on this score or alternative ideas to improve this code.



Hello Steve,

in this case, you can say that "" == TIMESTAMPGRANULARITY_DEFAULT
and document that DEFAULT is different depending upon the action put or 
get ?



Cheers,

Antoine


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-26 Thread Steve Loughran

Steve Cohen wrote:
Antoine:  OK, I've taken a look.  Here is the problem, or maybe I don't 
understand EnumeratedAttribute fully.


In response to a suggestion of Steve Loughran the other day, I've 
implemented all of my new attributes with the convention that a value of 
"" means "Don't set the attribute - leave the default value in place". 
This was to accomodate Steve's suggestion of wanting property-file 
driven scripts.


Such a script would define

An optional property file could define

timestampGranularity=MINUTE

or

timestampGranularity=NONE.

If neither specified, the default to be used (whose value varies 
depending on the chosen action).


I'm having difficulty understanding how this convention would fit into 
the pattern of EnumeratedAttribute.  There may be such a way that I'm 
just not understanding.  I'm still open to whatever suggestions you 
might have on this score or alternative ideas to improve this code.


Maybe I'll just have to accept that my needs arent going to be met. 
Since your last path to the task, I have dependency stuff working 
automatically against NT FTP and vsftpd, so arent going to be tweaking 
any of the other options. This is the best solution for me.


-stve

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-25 Thread Steve Cohen
Antoine:  OK, I've taken a look.  Here is the problem, or maybe I don't 
understand EnumeratedAttribute fully.


In response to a suggestion of Steve Loughran the other day, I've 
implemented all of my new attributes with the convention that a value of 
"" means "Don't set the attribute - leave the default value in place". 
This was to accomodate Steve's suggestion of wanting property-file 
driven scripts.


Such a script would define

An optional property file could define

timestampGranularity=MINUTE

or

timestampGranularity=NONE.

If neither specified, the default to be used (whose value varies 
depending on the chosen action).


I'm having difficulty understanding how this convention would fit into 
the pattern of EnumeratedAttribute.  There may be such a way that I'm 
just not understanding.  I'm still open to whatever suggestions you 
might have on this score or alternative ideas to improve this code.


Steve Cohen wrote:

Antoine Levy-Lambert wrote:


Hello Steve,

what about using a class derived from EnumeratedAttribute as type for 
timestampGranularity ?


Cheers,

Antoine


...


I'll take a look.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-25 Thread Steve Cohen

Antoine Levy-Lambert wrote:

Hello Steve,

what about using a class derived from EnumeratedAttribute as type for 
timestampGranularity ?


Cheers,

Antoine

[EMAIL PROTECTED] wrote:


scohen  2005/05/22 11:48:42

 Modified:src/main/org/apache/tools/ant/taskdefs/optional/net 
FTP.java

  src/etc/testcases/taskdefs/optional/net ftp.xml
 Log:
 Add new timestampGranularity attribute to account for the typical 
case in PUT operations where the client

 is HH:mm:ss and the ftp server is HH:mm.
 

 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




I'll take a look.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-22 Thread Antoine Levy-Lambert

Hello Steve,

what about using a class derived from EnumeratedAttribute as type for 
timestampGranularity ?


Cheers,

Antoine

[EMAIL PROTECTED] wrote:


scohen  2005/05/22 11:48:42

 Modified:src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
  src/etc/testcases/taskdefs/optional/net ftp.xml
 Log:
 Add new timestampGranularity attribute to account for the typical case in PUT 
operations where the client
 is HH:mm:ss and the ftp server is HH:mm.
 

 





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-22 Thread scohen
scohen  2005/05/22 11:48:42

  Modified:src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Add new timestampGranularity attribute to account for the typical case in PUT 
operations where the client
  is HH:mm:ss and the ftp server is HH:mm.
  
  Revision  ChangesPath
  1.74  +56 -4 
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.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- FTP.java  21 May 2005 13:02:02 -  1.73
  +++ FTP.java  22 May 2005 18:48:42 -  1.74
  @@ -81,6 +81,11 @@
   protected static final int RM_DIR = 6;
   /** return code of ftp - not implemented in commons-net version 1.0 */
   private static final int CODE_521 = 521;
  +
  +/** adjust uptodate calculations where server timestamps are HH:mm and 
client's
  + * are HH:mm:ss */
  +private static final long GRANULARITY_MINUTE = 6L;
  +
   /** Default port for FTP */
   public static final int DEFAULT_FTP_PORT = 21;
   
  @@ -115,6 +120,8 @@
   private String serverLanguageCodeConfig = null;
   private String serverTimeZoneConfig = null;
   private String shortMonthNamesConfig = null;
  +private String timestampGranularity = null;
  +private long serverTimestampGranularity = 0L;
   private boolean isConfigurationSet = false;
   
   protected static final String[] ACTION_STRS = {
  @@ -1387,6 +1394,21 @@
   return shortMonthNamesConfig;
   }
   /**
  + * @return Returns the timestampGranularity.
  + */
  +String getTimestampGranularity() {
  +return timestampGranularity;
  +}
  +/**
  + * @param timestampGranularity The timestampGranularity to set.
  + */
  +public void setTimestampGranularity(String timestampGranularity) {
  +if (null == timestampGranularity || "".equals(timestampGranularity)) 
{
  +return;
  +}
  +this.timestampGranularity = timestampGranularity;
  + }
  +/**
* Checks to see that all required parameters are set.
*
* @throws BuildException if the configuration is not valid.
  @@ -1493,7 +1515,32 @@
   for (int i = dsfiles.length - 1; i >= 0; i--) {
   rmDir(ftp, dsfiles[i]);
   }
  -}   else {
  +} else {
  +if (this.newerOnly) {
  + if (action == SEND_FILES) {
  + if 
("NONE".equalsIgnoreCase(this.timestampGranularity)) 
  + {
  + this.serverTimestampGranularity = 0L;
  + }
  + else if 
("MINUTE".equalsIgnoreCase(this.timestampGranularity)) 
  + {
  + this.serverTimestampGranularity = 
GRANULARITY_MINUTE;
  + } 
  + else 
  + {
  + this.serverTimestampGranularity = 
GRANULARITY_MINUTE;
  + }
  + } else if (action == GET_FILES) {
  + if 
("MINUTE".equalsIgnoreCase(this.timestampGranularity)) 
  + {
  + this.serverTimestampGranularity = 
GRANULARITY_MINUTE;
  + }
  + else 
  + {
  + this.serverTimestampGranularity = 0L;
  + }
  + }
  +}
   for (int i = 0; i < dsfiles.length; i++) {
   switch (action) {
   case SEND_FILES:
  @@ -1749,11 +1796,16 @@
   
   long remoteTimestamp = files[0].getTimestamp().getTime().getTime();
   long localTimestamp = localFile.lastModified();
  -
   if (this.action == SEND_FILES) {
  -return remoteTimestamp + timeDiffMillis >= localTimestamp;
  +return remoteTimestamp 
  + + this.timeDiffMillis 
  + + this.serverTimestampGranularity 
  + >= localTimestamp;
   } else {
  -return localTimestamp >= remoteTimestamp + timeDiffMillis;
  +return localTimestamp 
  + >= remoteTimestamp 
  + + this.timeDiffMillis
  + + this.serverTimestampGranularity;
   }
   }
   
  
  
  
  1.10  +2 -3  ant/src/etc/testcases/taskdefs/optional/net/ftp.xml
  
  Index: ftp.xml
  ===
  RCS file: /home/cvs/ant/sr

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-21 Thread scohen
scohen  2005/05/21 19:58:47

  Modified:src/testcases/org/apache/tools/ant/taskdefs/optional/net
FTPTest.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Added tests for the "newer" attribute in conjunction with the 
servertimezoneconfig attribute in the PUT and GET actions.
  
  Revision  ChangesPath
  1.16  +83 -0 
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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- FTPTest.java  30 Mar 2005 08:35:44 -  1.15
  +++ FTPTest.java  22 May 2005 02:58:47 -  1.16
  @@ -16,16 +16,23 @@
*/
   package org.apache.tools.ant.taskdefs.optional.net;
   
  +import org.apache.tools.ant.BuildEvent;
   import org.apache.tools.ant.BuildFileTest;
  +import org.apache.tools.ant.BuildListener;
  +import org.apache.tools.ant.BuildLogger;
  +import org.apache.tools.ant.DefaultLogger;
   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.util.regexp.RegexpMatcher;
  +import org.apache.tools.ant.util.regexp.RegexpMatcherFactory;
   import org.apache.tools.ant.taskdefs.condition.Os;
   
   import java.io.File;
   import java.io.IOException;
   import java.util.Arrays;
  +import java.util.Vector;
   
   import org.apache.commons.net.ftp.FTPClient;
   
  @@ -537,6 +544,82 @@
new String[] {"alpha/beta", "alpha/beta/gamma", 
"delta"});
   
   }
  +
  +/**
  + * This class enables the use of the log messages as a way of testing 
  + * the number of files actually transferred.
  + * It uses the ant regular expression mechanism to get a regex parser
  + * to parse the log output.
  + */
  +private class CountLogListener extends DefaultLogger {
  +private Vector lastMatchGroups = null;
  +private RegexpMatcher matcher = new 
RegexpMatcherFactory().newRegexpMatcher();
  +
  +/**
  + * The only constructor for a CountLogListener
  + * @param pattern a regular expression pattern.  It should have 
  + * one parenthesized group and that group should contain the
  + * number desired.
  + */
  +public CountLogListener(String pattern) {
  +super();
  +this.matcher.setPattern(pattern);
  +}
  +
  +
  +/* 
  + * @param event the build event that is being logged.
  + */
  +public void messageLogged(BuildEvent event) {
  +String message = event.getMessage();
  +if (this.matcher.matches(message)) {
  +lastMatchGroups = this.matcher.getGroups(message);
  +}
  +super.messageLogged(event);
  +}
  +
  +/**
  + * returns the desired number that results from parsing the log
  + * message
  + * @return the number of files indicated in the desired message or -1
  + * if a matching log message was never found.
  + */
  +public int getCount() {
  +if (this.lastMatchGroups == null) {
  +return -1;
  +}
  +return Integer.parseInt((String) this.lastMatchGroups.get(1));
  +}
  +}
  +
  +/**
  + * Tests the combination of the newer parameter and the 
  + * serverTimezoneConfig  parameter in the PUT action.  The default 
  + * configuration is an ftp server on localhost which formats 
  + * timestamps as GMT.
  + */
  +public void testTimezonePut() {
  +CountLogListener log = new CountLogListener("(\\d+) files? sent");
  +getProject().executeTarget("timed.test.setup");
  +getProject().addBuildListener(log);
  +getProject().executeTarget("timed.test.put.older");
  +assertEquals(1, log.getCount());
  +}
  +
  +/**
  + * Tests the combination of the newer parameter and the 
  + * serverTimezoneConfig  parameter in the GET action.  The default 
  + * configuration is an ftp server on localhost which formats 
  + * timestamps as GMT.
  + */
  +public void testTimezoneGet() {
  +CountLogListener log = new CountLogListener("(\\d+) files? 
retrieved");
  +getProject().executeTarget("timed.test.setup");
  +getProject().addBuildListener(log);
  +getProject().executeTarget("timed.test.get.older");
  +assertEquals(3, log.getCount());
  +}
  +
   /**
*  this test is inspired by a user reporting that deletions of 
directories with the ftp task do not w

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2005-05-21 Thread scohen
scohen  2005/05/21 06:03:08

  Modified:src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  add option to read properties file from the user's home directory as well as 
from the top of the ant tree, where it is vulnerable to being wiped out from cvs
  replace operations.
  
  Revision  ChangesPath
  1.8   +2 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ftp.xml   15 Oct 2003 18:49:53 -  1.7
  +++ ftp.xml   21 May 2005 13:03:08 -  1.8
  @@ -1,5 +1,7 @@
   
   
  +
  +
   
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-10-13 Thread antoine
antoine 2003/10/13 12:53:01

  Modified:src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
   src/testcases/org/apache/tools/ant/taskdefs/optional/net
FTPTest.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Merge from ANT_16_BRANCH
  
  Revision  ChangesPath
  1.53  +28 -24
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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- FTP.java  12 Sep 2003 20:32:29 -  1.52
  +++ FTP.java  13 Oct 2003 19:53:01 -  1.53
  @@ -1357,30 +1357,34 @@
   }
   bw = new BufferedWriter(new FileWriter(listing));
   }
  -
  -for (int i = 0; i < dsfiles.length; i++) {
  -switch (action) {
  -case SEND_FILES:
  -sendFile(ftp, dir, dsfiles[i]);
  -break;
  -case GET_FILES:
  -getFile(ftp, dir, dsfiles[i]);
  -break;
  -case DEL_FILES:
  -delFile(ftp, dsfiles[i]);
  -break;
  -case LIST_FILES:
  -listFile(ftp, bw, dsfiles[i]);
  -break;
  -case CHMOD:
  -doSiteCommand(ftp, "chmod " + chmod + " " + 
resolveFile(dsfiles[i]));
  -transferred++;
  -break;
  -case RM_DIR:
  -rmDir(ftp, dsfiles[i]);
  -break;
  -default:
  -throw new BuildException("unknown ftp action " + 
action);
  +if (action == RM_DIR) {
  +// to remove directories, start by the end of the list
  +// the trunk does not let itself be removed before the leaves
  +for (int i = dsfiles.length - 1; i >= 0; i--) {
  +rmDir(ftp, dsfiles[i]);
  +}
  +}   else {
  +for (int i = 0; i < dsfiles.length; i++) {
  +switch (action) {
  +case SEND_FILES:
  +sendFile(ftp, dir, dsfiles[i]);
  +break;
  +case GET_FILES:
  +getFile(ftp, dir, dsfiles[i]);
  +break;
  +case DEL_FILES:
  +delFile(ftp, dsfiles[i]);
  +break;
  +case LIST_FILES:
  +listFile(ftp, bw, dsfiles[i]);
  +break;
  +case CHMOD:
  +doSiteCommand(ftp, "chmod " + chmod + " " + 
resolveFile(dsfiles[i]));
  +transferred++;
  +break;
  +default:
  +throw new BuildException("unknown ftp action " + 
action);
  +}
   }
   }
   } finally {
  
  
  
  1.9   +6 -1  
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FTPTest.java  22 Aug 2003 10:48:08 -  1.8
  +++ FTPTest.java  13 Oct 2003 19:53:01 -  1.9
  @@ -570,7 +570,12 @@
new String[] {"alpha/beta", "alpha/beta/gamma", 
"delta"});
   
   }
  -
  +/**
  + *  this test is inspired by a user reporting that deletions of 
directories with the ftp task do not work
  + */
  +public void testFTPDelete() {
  +getProject().executeTarget("ftp-delete");
  +}
   private void compareFiles(DirectoryScanner ds, String[] expectedFiles,
 String[] expectedDirectories) {
   String includedFiles[] = ds.getIncludedFiles();
  
  
  
  1.6   +23 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ftp.xml   14 Aug 2003 17:23:22 -  1.5
  +++ ftp.xml   13 Oct 2003 19:53:01 -  1.6
  @@ -77,4 +77,27 @@
   
   
  +

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-10-13 Thread antoine
antoine 2003/10/13 12:37:02

  Modified:src/testcases/org/apache/tools/ant/taskdefs/optional/net
Tag: ANT_16_BRANCH FTPTest.java
   src/etc/testcases/taskdefs/optional/net Tag: ANT_16_BRANCH
ftp.xml
  Log:
  Added a testcase for the ftp task concerning the deletion of directories
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.8.2.1   +6 -1  
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.8
  retrieving revision 1.8.2.1
  diff -u -r1.8 -r1.8.2.1
  --- FTPTest.java  22 Aug 2003 10:48:08 -  1.8
  +++ FTPTest.java  13 Oct 2003 19:37:01 -  1.8.2.1
  @@ -570,7 +570,12 @@
new String[] {"alpha/beta", "alpha/beta/gamma", 
"delta"});
   
   }
  -
  +/**
  + *  this test is inspired by a user reporting that deletions of 
directories with the ftp task do not work
  + */
  +public void testFTPDelete() {
  +getProject().executeTarget("ftp-delete");
  +}
   private void compareFiles(DirectoryScanner ds, String[] expectedFiles,
 String[] expectedDirectories) {
   String includedFiles[] = ds.getIncludedFiles();
  
  
  
  No   revision
  No   revision
  1.5.2.1   +23 -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.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- ftp.xml   14 Aug 2003 17:23:22 -  1.5
  +++ ftp.xml   13 Oct 2003 19:37:02 -  1.5.2.1
  @@ -77,4 +77,27 @@
   
   
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-14 Thread antoine
antoine 2003/08/14 10:23:22

  Modified:src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  removed useless 
  
  Revision  ChangesPath
  1.5   +0 -1  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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ftp.xml   14 Aug 2003 14:47:54 -  1.4
  +++ ftp.xml   14 Aug 2003 17:23:22 -  1.5
  @@ -1,6 +1,5 @@
   
   
  -
   
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-14 Thread Antoine Levy-Lambert
Stefan Bodewig wrote

> > There is a small problem :
> >
> >  > server="${ftp.host}"
> > userid="${ftp.user}"
> > password="${ftp.password}"
> > remotedir="${tmp.dir}">
> > 
> >
> >
> > used not to follow symbolic links (in ant 1.5.3 and before)
>
> symlinks on the remote side?
>
> > now, it will follow symbolic links because the default for filesets
> > is to follow symbolic links.
> >
> > Is this OK
>
> Not sure.
>
> > the only possibility I see is to add a flag in AbstractFileSet to
> > find out whether followsymlinks has been *** explicitly *** set.
> > Makes the code fatter but would maintain compatibility of behavior
> > between ant 1.5.3 and ant 1.6
>
> An alternative (although a hacky one) invoke setFollowSymlinks with
> false in FTP#addFileset().  As it is addXYZ and not addConfiguredXYZ
> any explicitly set attribute would override it (as the attributes will
> get set after the invocation of add).  Hmm, wait, you only want to
> change the followsymlinks attribute if the fileset is a remote one,
> right?  You probably don't know that by the time addFileset gets
> invoked.
>
yes, the followsymlinks problem concerns the cases where the fileset is
remote, so all actions other than put.

> > Or can we say that the non following of symbolic links by the ftp
> > task was a bug,
>
> +0, I'm not really sure and I don't really know what the expected
> behavior would be.  I'd probably expect put and get to behave the same
> way, so the 1.5.x behavior would be wrong.
>
I am going to write in WHATSNEW under the section "changes that can break
existing environments" :

 task : followsymlinks="false" in nested fileset definitions is
explicitly required in order to exclude symbolic links.

Cheers,

Antoine



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-14 Thread Stefan Bodewig
On Thu, 14 Aug 2003, Antoine Levy-Lambert <[EMAIL PROTECTED]>
wrote:

> There is a small problem :
> 
>  server="${ftp.host}"
> userid="${ftp.user}"
> password="${ftp.password}"
> remotedir="${tmp.dir}">
> 
>
> 
> used not to follow symbolic links (in ant 1.5.3 and before)

symlinks on the remote side?

> now, it will follow symbolic links because the default for filesets
> is to follow symbolic links.
> 
> Is this OK

Not sure.

> the only possibility I see is to add a flag in AbstractFileSet to
> find out whether followsymlinks has been *** explicitly *** set.
> Makes the code fatter but would maintain compatibility of behavior
> between ant 1.5.3 and ant 1.6

An alternative (although a hacky one) invoke setFollowSymlinks with
false in FTP#addFileset().  As it is addXYZ and not addConfiguredXYZ
any explicitly set attribute would override it (as the attributes will
get set after the invocation of add).  Hmm, wait, you only want to
change the followsymlinks attribute if the fileset is a remote one,
right?  You probably don't know that by the time addFileset gets
invoked.

> Or can we say that the non following of symbolic links by the ftp
> task was a bug,

+0, I'm not really sure and I don't really know what the expected
behavior would be.  I'd probably expect put and get to behave the same
way, so the 1.5.x behavior would be wrong.

Stefan

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-14 Thread Antoine Levy-Lambert
I have just done some changes to the ftp task because I realized that the
task was not really supporting symbolic links, only the FTPDirectoryScanner
did.

There is a small problem :



   

used not to follow symbolic links (in ant 1.5.3 and before)

now, it will follow symbolic links because the default for filesets is to
follow symbolic links.

Is this OK or do I need to change this and how ?

the only possibility I see is to add a flag in AbstractFileSet to find out
whether followsymlinks has been *** explicitly *** set.
Makes the code fatter but would maintain compatibility of behavior between
ant 1.5.3 and ant 1.6

Or can we say that the non following of symbolic links by the ftp task was a
bug, and that the users who do not want to fetch the symbolic links can
alter their build files and set followsymlinks="false" in their fileset
definitions ?

Cheers,

Antoine

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 14, 2003 4:47 PM
Subject: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml


> antoine 2003/08/14 07:47:54
>
>   Modified:src/main/org/apache/tools/ant/types AbstractFileSet.java
>src/main/org/apache/tools/ant/taskdefs/optional/net
FTP.java
>src/testcases/org/apache/tools/ant/taskdefs/optional/net
> FTPTest.java
>src/etc/testcases/taskdefs/optional/net ftp.xml
>   Log:
>   Go on working on the followsymlinks support in the FTP task.
>   The scanner was working previously, but the retrieving of links was not
working
>   because the followsymlinks attribute was not passed through.
>
>   Revision  ChangesPath
>   1.26  +15 -0
ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
>
>   Index: AbstractFileSet.java
>   ===
>   RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
>   retrieving revision 1.25
>   retrieving revision 1.26
>   diff -u -r1.25 -r1.26
>   --- AbstractFileSet.java 13 Aug 2003 15:14:31 - 1.25
>   +++ AbstractFileSet.java 14 Aug 2003 14:47:54 - 1.26
>   @@ -330,6 +330,21 @@
>}
>
>/**
>   + * find out if the fileset wants to follow symbolic links
>   + *
>   + * @return  flag indicating whether or not symbolic links should be
followed
>   + *
>   + * @since ant 1.6
>   + */
>   +public boolean isFollowSymlinks() {
>   +if (isReference()) {
>   +return getRef(getProject()).isFollowSymlinks();
>   +} else {
>   +return followSymlinks;
>   +}
>   +}
>   +
>   +/**
> * sets the name used for this datatype instance.
> */
>protected String getDataTypeName() {
>
>
>
>   1.47  +2 -2
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.46
>   retrieving revision 1.47
>   diff -u -r1.46 -r1.47
>   --- FTP.java 14 Aug 2003 11:37:36 - 1.46
>   +++ FTP.java 14 Aug 2003 14:47:54 - 1.47
>   @@ -248,7 +248,6 @@
>ftp.changeToParentDirectory();
>return;
>}
>   -
>for (int i = 0; i < newfiles.length; i++) {
>FTPFile file = newfiles[i];
>if (!file.getName().equals(".")
>   @@ -662,7 +661,7 @@
> */
>protected int transferFiles(FTPClient ftp, FileSet fs)
> throws IOException, BuildException {
>   -FileScanner ds;
>   +DirectoryScanner ds;
>
>if (action == SEND_FILES) {
>ds = fs.getDirectoryScanner(getProject());
>   @@ -674,6 +673,7 @@
>}
>ds = new FTPDirectoryScanner(ftp);
>fs.setupDirectoryScanner(ds, getProject());
>   +ds.setFollowSymlinks(fs.isFollowSymlinks());
>ds.scan();
>}
>
>
>
>
>   1.6   +34 -0
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/FTPTe
st.java,v
>   retrieving revision 1.5
>   retrieving revision 1.6
>   diff -u -r1.5 -r1.6
>   --- FTPTest.java 6 Aug 2003 12:24:42 - 1.5
>   +++ FTPTest.java 14 Aug 2003 14:47:54 -000

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-14 Thread antoine
antoine 2003/08/14 07:47:54

  Modified:src/main/org/apache/tools/ant/types AbstractFileSet.java
   src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
   src/testcases/org/apache/tools/ant/taskdefs/optional/net
FTPTest.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  Go on working on the followsymlinks support in the FTP task.
  The scanner was working previously, but the retrieving of links was not 
working
  because the followsymlinks attribute was not passed through.
  
  Revision  ChangesPath
  1.26  +15 -0 
ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java
  
  Index: AbstractFileSet.java
  ===
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/types/AbstractFileSet.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AbstractFileSet.java  13 Aug 2003 15:14:31 -  1.25
  +++ AbstractFileSet.java  14 Aug 2003 14:47:54 -  1.26
  @@ -330,6 +330,21 @@
   }
   
   /**
  + * find out if the fileset wants to follow symbolic links
  + *
  + * @return  flag indicating whether or not symbolic links should be 
followed
  + *
  + * @since ant 1.6
  + */
  +public boolean isFollowSymlinks() {
  +if (isReference()) {
  +return getRef(getProject()).isFollowSymlinks();
  +} else {
  +return followSymlinks;
  +}
  +}
  +
  +/**
* sets the name used for this datatype instance.
*/
   protected String getDataTypeName() {
  
  
  
  1.47  +2 -2  
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.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- FTP.java  14 Aug 2003 11:37:36 -  1.46
  +++ FTP.java  14 Aug 2003 14:47:54 -  1.47
  @@ -248,7 +248,6 @@
   ftp.changeToParentDirectory();
   return;
   }
  -
   for (int i = 0; i < newfiles.length; i++) {
   FTPFile file = newfiles[i];
   if (!file.getName().equals(".")
  @@ -662,7 +661,7 @@
*/
   protected int transferFiles(FTPClient ftp, FileSet fs)
throws IOException, BuildException {
  -FileScanner ds;
  +DirectoryScanner ds;
   
   if (action == SEND_FILES) {
   ds = fs.getDirectoryScanner(getProject());
  @@ -674,6 +673,7 @@
   }
   ds = new FTPDirectoryScanner(ftp);
   fs.setupDirectoryScanner(ds, getProject());
  +ds.setFollowSymlinks(fs.isFollowSymlinks());
   ds.scan();
   }
   
  
  
  
  1.6   +34 -0 
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FTPTest.java  6 Aug 2003 12:24:42 -   1.5
  +++ FTPTest.java  14 Aug 2003 14:47:54 -  1.6
  @@ -226,6 +226,40 @@
   dsSource.scan();
   compareFiles(dsSource, sortedDestinationFiles, 
sortedDestinationDirectories);
   }
  +public void testGetFollowSymlinksTrue() {
  +if (!supportsSymlinks) {
  +return;
  +}
  +if (!loginSuceeded) {
  +return;
  +}
  +if (!changeRemoteDir(remoteTmpDir)) {
  +return;
  +}
  +getProject().executeTarget("ftp-get-directory-symbolic-link");
  +FileSet fsDestination = (FileSet) 
getProject().getReference("fileset-destination-without-selector");
  +DirectoryScanner dsDestination = 
fsDestination.getDirectoryScanner(getProject());
  +dsDestination.scan();
  +compareFiles(dsDestination, new String[] 
{"alpha/beta/gamma/gamma.xml"},
  +new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"});
  +}
  +public void testGetFollowSymlinksFalse() {
  +if (!supportsSymlinks) {
  +return;
  +}
  +if (!loginSuceeded) {
  +return;
  +}
  +if (!changeRemoteDir(remoteTmpDir)) {
  +return;
  +}
  +getProject().executeTarget("ftp-get-directory-no-symbolic-link");
  +FileSet fsDestination = (FileSet) 
getProject().getReference("fileset-destination-without-selector");
  +DirectoryScanner dsDestination = 
fsDestination.getDirectoryScanner(getProject());
  +dsDestination.scan(

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-06 Thread antoine
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  ChangesPath
  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 -   1.4
  +++ FTPTest.java  6 Aug 2003 12:24:42 -   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();
  -assertEqua

cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-06 Thread antoine
antoine 2003/08/06 03:27:15

  Modified:src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  use user.name as default for ftp.user
  new target for testing scanning a file which is a symbolic link
  
  Revision  ChangesPath
  1.2   +7 -16 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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ftp.xml   4 Aug 2003 22:23:57 -   1.1
  +++ ftp.xml   6 Aug 2003 10:27:15 -   1.2
  @@ -1,26 +1,13 @@
   
   
   
  +
   
   
   
   
   
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  -
  +
   
   
   
  @@ -32,11 +19,15 @@
   
   
   
  -
   
   
   
   
   
  +
  +
  +
  +
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-04 Thread Antoine Levy-Lambert
This test obviously requires a special setup :
   - availability of a local ftp server,
   - entering your password into a file called ftp.properties and located
in the ant root directory

The test is disabled by default in build.xml. :-)

The test is a clone of DirectoryScannerTest (maybe I could have simply
extended somehow DirectoryScannerTest).

2 tests are failing currently :
   - test3
   - testChildrenOfExcludedDirectory

I am going to fix the code of FTP.FTPDirectoryScanner to get these tests to
pass.
A next step will be to introduce in FTP.FTPDirectoryScanner the same sorts
of optimizations as in DirectoryScanner :
- follow only include patterns instead of scanning the whole basedir,
- do not follow directories if an exclude pattern = directoryname +
"/**"

Afterwards, I will close
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20103 (FileSet horrible
performance when dir has a large number of subdirs).  :-)

Cheers,

Antoine





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml

2003-08-04 Thread antoine
antoine 2003/08/04 15:23:57

  Modified:src/etc/testcases/taskdefs/exec exec.xml
  Added:   src/testcases/org/apache/tools/ant/taskdefs/optional/net
FTPTest.java
   src/etc/testcases/taskdefs/optional/net ftp.xml
  Log:
  new test for the ftp task
  requires ftp.properties in ant's root directory (with your password in it) 
and a local ftp server.
  The test is disabled by default in build.xml
  
  Revision  ChangesPath
  1.1  
ant/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
  
  Index: FTPTest.java
  ===
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *notice, this list of conditions and the following disclaimer in
   *the documentation and/or other materials provided with the
   *distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *any, must include the following acknowlegement:
   *   "This product includes software developed by the
   *Apache Software Foundation (http://www.apache.org/)."
   *Alternately, this acknowlegement may appear in the software itself,
   *if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "Ant" and "Apache Software
   *Foundation" must not be used to endorse or promote products derived
   *from this software without prior written permission. For written
   *permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *nor may "Apache" appear in their names without prior written
   *permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * 
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * .
   */
  package org.apache.tools.ant.taskdefs.optional.net;
  
  import org.apache.tools.ant.BuildFileTest;
  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 org.apache.commons.net.ftp.FTPClient;
  
  public class FTPTest extends BuildFileTest{
  // keep track of what operating systems are supported here.
  private boolean supportsSymlinks = Os.isFamily("unix")
  && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1);
  
  private FTPClient ftp;
  private FTP ftptask;
  private boolean connectionSucceeded = true;
  private boolean loginSuceeded = true;
  private String tmpDir = null;
  private String remoteTmpDir = null;
  private String ftpFileSep = null;
  private myFTP myFTPTask = new myFTP();
  
  public FTPTest(String name) {
  super(name);
  }
  public void setUp() {
  configureProject("src/etc/testcases/taskdefs/optional/net/ftp.xml");
  getProject().executeTarget("setup");
  tmpDir = getProject().getProperty("tmp.dir");
  ftp = new FTPClient();
  ftptask = new FTP();
  ftpFileSep = getProject().getProperty("ftp.filesep");
  ftptask.setSeparator(ftpFileSep);
  remoteTmpDir = ftptask.resolveFile(tmpDir);
  String remoteHost = getProject().getProperty("ftp.host");
  int port = Integer.parseInt(getProject().getProperty("ftp.port"));
  String remoteUser = getProject().getProp