Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 36477 invoked from network); 3 Apr 2005 18:09:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Apr 2005 18:09:21 -0000 Received: (qmail 89576 invoked by uid 500); 3 Apr 2005 18:09:18 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 89508 invoked by uid 500); 3 Apr 2005 18:09:17 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 89493 invoked by uid 99); 3 Apr 2005 18:09:17 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from smtpout02-04.prod.mesa1.secureserver.net (HELO smtpout02-04.prod.mesa1.secureserver.net) (64.202.165.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 03 Apr 2005 11:09:17 -0700 Received: (qmail 25534 invoked from network); 3 Apr 2005 18:09:14 -0000 Received: from unknown (24.13.84.182) by smtpout02-04.prod.mesa1.secureserver.net (64.202.165.194) with ESMTP; 03 Apr 2005 18:09:14 -0000 Message-ID: <42503149.3090501@javactivity.org> Date: Sun, 03 Apr 2005 13:09:13 -0500 From: Steve Cohen User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [net] [ftp] [patch] FTPTimestampParserImplTest.java and FTPClientConfigTest.java References: <424C37A2.6080604@apache.org> In-Reply-To: <424C37A2.6080604@apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Okay, now that I understand the problem in general terms, can you please provide stack traces or other information indicating where in the code failures are happening? Your patches provide me with a possible fix, but I need to understand fully the problem. Also if you could tell me the locale and other jvm properties that would help. I think there may be other, more standard fixes that I can apply, but I need to understand the problem fully. It would probably be better, if possible, if could provide a setUp() routine that puts the JVM into the same locale-state anywhere that yours is in by default. I will be non-responsive for several days, but will look at this when I return later in the week. Steve Neeme Praks wrote: > > Two patches to make the FTP timestamp parsing tests pass also on > non-english systems. > I'm not sure if this is the best way to fix those issues, though. > > Rgds, > Neeme > > > ------------------------------------------------------------------------ > > Index: FTPTimestampParserImplTest.java > =================================================================== > --- FTPTimestampParserImplTest.java (revision 159615) > +++ FTPTimestampParserImplTest.java (working copy) > @@ -15,6 +15,7 @@ > */ > package org.apache.commons.net.ftp.parser; > > +import java.text.DateFormatSymbols; > import java.text.ParseException; > import java.text.SimpleDateFormat; > import java.util.Calendar; > @@ -73,8 +74,19 @@ > > FTPTimestampParserImpl parser = new FTPTimestampParserImpl(); > > + // assume we are FTPing a server in Chicago, two hours ahead of > + // L. A. > + FTPClientConfig config = > + new FTPClientConfig(FTPClientConfig.SYST_UNIX); > + config.setDefaultDateFormatStr(FTPTimestampParser.DEFAULT_SDF); > + config.setRecentDateFormatStr(FTPTimestampParser.DEFAULT_RECENT_SDF); > + // 2 hours difference > + config.setServerTimeZoneId("America/Chicago"); > + parser.configure(config); > + > + > SimpleDateFormat sdf = > - new SimpleDateFormat(parser.getRecentDateFormatString()); > + new SimpleDateFormat(parser.getRecentDateFormatString(), parser.getRecentDateFormat().getDateFormatSymbols()); > // assume we're in the US Pacific Time Zone > TimeZone tzla = TimeZone.getTimeZone("America/Los_Angeles"); > sdf.setTimeZone(tzla); > @@ -84,17 +96,6 @@ > String fmtTimePlusThreeHours = sdf.format(threeHoursFromNow); > > > - // assume we are FTPing a server in Chicago, two hours ahead of > - // L. A. > - FTPClientConfig config = > - new FTPClientConfig(FTPClientConfig.SYST_UNIX); > - config.setDefaultDateFormatStr(FTPTimestampParser.DEFAULT_SDF); > - config.setRecentDateFormatStr(FTPTimestampParser.DEFAULT_RECENT_SDF); > - // 2 hours difference > - config.setServerTimeZoneId("America/Chicago"); > - parser.configure(config); > - > - > try { > Calendar parsed = parser.parseTimestamp(fmtTimePlusOneHour); > // the only difference should be the two hours > @@ -103,7 +104,7 @@ > (long)TWO_HOURS_OF_MILLISECONDS, > cal.getTime().getTime() - parsed.getTime().getTime()); > } catch (ParseException e){ > - fail("Unable to parse"); > + fail("Unable to parse " + fmtTimePlusOneHour); > } > > //but if the file's timestamp is THREE hours ahead of now, that should > @@ -123,13 +124,18 @@ > > public void testParser() { > FTPTimestampParserImpl parser = new FTPTimestampParserImpl(); > + Calendar cal = Calendar.getInstance(); > + cal.set(Calendar.YEAR, 2002); > + cal.set(Calendar.MONTH, 1); > + cal.set(Calendar.DAY_OF_MONTH, 22); > + SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy"); > try { > - parser.parseTimestamp("feb 22 2002"); > + parser.parseTimestamp(sdf.format(cal.getTime())); > } catch (ParseException e) { > fail("failed.to.parse.default"); > } > try { > - parser.parseTimestamp("f�v 22 2002"); > + parser.parseTimestamp("f�v 22 2002"); > fail("should.have.failed.to.parse.default"); > } catch (ParseException e) { > // this is the success case > @@ -140,14 +146,17 @@ > config.setRecentDateFormatStr("d MMM HH:mm"); > config.setServerLanguageCode("fr"); > parser.configure(config); > + DateFormatSymbols dfs = FTPClientConfig.lookupDateFormatSymbols("fr"); > + sdf = new SimpleDateFormat("MMM d yyyy", dfs); > try { > - parser.parseTimestamp("d�c 22 2002"); > + parser.parseTimestamp(sdf.format(cal.getTime())); > fail("incorrect.field.order"); > } catch (ParseException e) { > // this is the success case > } > + sdf = new SimpleDateFormat("d MMM yyyy", dfs); > try { > - parser.parseTimestamp("22 d�c 2002"); > + parser.parseTimestamp(sdf.format(cal.getTime())); > } catch (ParseException e) { > fail("failed.to.parse.french"); > } > @@ -159,27 +168,28 @@ > // this is the success case > } > try { > - parser.parseTimestamp("29 f�v 2002"); > + parser.parseTimestamp("29 f�v 2002"); > fail("nonexistent.date"); > } catch (ParseException e) { > // this is the success case > } > > try { > - parser.parseTimestamp("22 ao� 30:02"); > + parser.parseTimestamp("22 ao� 30:02"); > fail("bad.hour"); > } catch (ParseException e) { > // this is the success case > } > > try { > - parser.parseTimestamp("22 ao� 20:74"); > + parser.parseTimestamp("22 ao� 20:74"); > fail("bad.minute"); > } catch (ParseException e) { > // this is the success case > } > + sdf = new SimpleDateFormat("d MMM HH:mm", dfs); > try { > - parser.parseTimestamp("28 ao� 20:02"); > + parser.parseTimestamp(sdf.format(cal.getTime())); > } catch (ParseException e) { > fail("failed.to.parse.french.recent"); > } > > > ------------------------------------------------------------------------ > > Index: FTPClientConfigTest.java > =================================================================== > --- FTPClientConfigTest.java (revision 159615) > +++ FTPClientConfigTest.java (working copy) > @@ -67,6 +67,7 @@ > String tooLong = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|jan"; > String tooShort = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov"; > String fakeLang = "abc|def|ghi|jkl|mno|pqr|stu|vwx|yza|bcd|efg|hij"; > + String standard = "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec"; > > public void testSetShortMonthNames() { > } > @@ -153,12 +154,18 @@ > // should have failed > } > DateFormatSymbols dfs = null; > + DateFormatSymbols dfs2 = null; > try { > dfs = FTPClientConfig.getDateFormatSymbols(fakeLang); > } catch (Exception e){ > fail("rejected valid short month string"); > } > - SimpleDateFormat sdf1 = new SimpleDateFormat("MMM dd, yyyy"); > + try { > + dfs2 = FTPClientConfig.getDateFormatSymbols(standard); > + } catch (Exception e){ > + fail("rejected valid short month string"); > + } > + SimpleDateFormat sdf1 = new SimpleDateFormat("MMM dd, yyyy", dfs2); > SimpleDateFormat sdf2 = new SimpleDateFormat("MMM dd, yyyy", dfs); > > Date d1 = null; > @@ -166,7 +173,7 @@ > try { > d1 = sdf1.parse("dec 31, 2004"); > } catch (ParseException px) { > - fail("failed.to.parse.std"); > + fail("failed.to.parse.std " + px); > } > try { > d2 = sdf2.parse("hij 31, 2004"); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org