Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 12550 invoked from network); 29 May 2005 03:01:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 May 2005 03:01:16 -0000 Received: (qmail 12746 invoked by uid 500); 29 May 2005 03:01:15 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 12449 invoked by uid 500); 29 May 2005 03:01:13 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 12434 invoked by uid 500); 29 May 2005 03:01:13 -0000 Received: (qmail 12427 invoked by uid 99); 29 May 2005 03:01:13 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 28 May 2005 20:01:11 -0700 Received: (qmail 12527 invoked by uid 1632); 29 May 2005 03:01:10 -0000 Date: 29 May 2005 03:01:10 -0000 Message-ID: <20050529030110.12526.qmail@minotaur.apache.org> From: scohen@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/etc/testcases/taskdefs/optional/net ftp.xml X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 Changes Path 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 -0000 1.17 +++ FTPTest.java 29 May 2005 03:01:10 -0000 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 = yyyy/MM/dd HH:mm" + "custom config: default date format = yyyy/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 -0000 1.75 +++ FTP.java 29 May 2005 03:01:10 -0000 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 = FTPSystemType.getDefault(); private String defaultDateFormatConfig = null; private String recentDateFormatConfig = null; - private String serverLanguageCodeConfig = null; + private LanguageCode serverLanguageCodeConfig = LanguageCode.getDefault(); private String serverTimeZoneConfig = null; private String shortMonthNamesConfig = null; private Granularity timestampGranularity = Granularity.getDefault(); @@ -1316,7 +1319,7 @@ * null or empty string, in which case ignored. * @see org.apache.commons.net.ftp.FTPClientConfig */ - public void setServerLanguageCodeConfig(String serverLanguageCode) { + public void setServerLanguageCodeConfig(LanguageCode serverLanguageCode) { if (serverLanguageCode != null && !serverLanguageCode.equals("")) { this.serverLanguageCodeConfig = serverLanguageCode; @@ -1379,7 +1382,7 @@ * @return Returns the serverLanguageCodeConfig. */ String getServerLanguageCodeConfig() { - return serverLanguageCodeConfig; + return serverLanguageCodeConfig.getValue(); } /** * @return Returns the serverTimeZoneConfig. @@ -2358,5 +2361,37 @@ return ftpst; } } + public static class LanguageCode extends EnumeratedAttribute { + + + private static final String[] VALID_LANGUAGE_CODES = + getValidLanguageCodes(); + + private static final String[] getValidLanguageCodes() { + Collection c = FTPClientConfig.getSupportedLanguageCodes(); + String[] ret = new String[c.size() + 1]; + int i = 0; + ret[i++] = ""; + for (Iterator it = c.iterator(); it.hasNext(); i++) { + ret[i] = (String) it.next(); + } + return ret; + } + + + /* + * @return the list of valid system types. + */ + public String[] getValues() { + return VALID_LANGUAGE_CODES; + } + + static final LanguageCode getDefault() { + LanguageCode lc = new LanguageCode(); + lc.setValue(""); + return lc; + } + } + } 1.12 +26 -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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ftp.xml 28 May 2005 17:05:44 -0000 1.11 +++ ftp.xml 29 May 2005 03:01:10 -0000 1.12 @@ -234,6 +234,32 @@ + + + + + + + + + +