You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stefan Bodewig <bo...@apache.org> on 2002/10/09 08:18:22 UTC
[NET] [PATCH] Make tests Locale independent
On 9 Oct 2002, <br...@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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>