commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject [NET] [PATCH] Make tests Locale independent
Date Wed, 09 Oct 2002 06:18:22 GMT
On 9 Oct 2002, <brekke@apache.org> wrote:

>   We were using the default string format for the Date object to
>   compare timestamps.

Still fails on my box.

Testcase: testParseFieldsOnFile took 0,033 sec
	FAILED
expected:<...n...> but was:<......>
junit.framework.ComparisonFailure: expected:<...n...> but was:<......>
	at org.apache.commons.net.ftp.ftp2.parser.EnterpriseUnixFTPEntryParserTest.testParseFieldsOnFile(EnterpriseUnixFTPEntryParserTest.java:147)

I'm running a different locale than you (mine is German) and live in a
different time-zone.

Throwing in 

        System.err.println(df.format(file.getTimestamp().getTime()));

before line 147 of EnterpriseUnixFTPEntryParserTest.java:147, I get
'Mo Aug 12 13:56:00 2002'.  With the trivial patch below, all tests
pass on my machine.

Stefan

Index: FTPParseTestFramework.java
===================================================================
RCS file: /home/cvspublic/jakarta-commons-sandbox/net/src/test/org/apache/commons/net/ftp/ftp2/parser/FTPParseTestFramework.java,v
retrieving revision 1.4
diff -u -r1.4 FTPParseTestFramework.java
--- FTPParseTestFramework.java	9 Oct 2002 05:11:19 -0000	1.4
+++ FTPParseTestFramework.java	9 Oct 2002 06:16:01 -0000
@@ -56,6 +56,7 @@
 import junit.framework.TestCase;
 
 import java.text.SimpleDateFormat;
+import java.util.Locale;
 import org.apache.commons.net.ftp.FTPFile;
 import org.apache.commons.net.ftp.ftp2.FTPFileEntryParser;
 
@@ -156,6 +157,6 @@
     {
         super.setUp();
         parser = getParser();
-        df = new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy");
+        df = new SimpleDateFormat("EEE MMM dd kk:mm:ss yyyy", Locale.US);
     }
 }


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message