You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2008/04/07 04:08:04 UTC
svn commit: r645342 -
/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Author: sebb
Date: Sun Apr 6 19:08:02 2008
New Revision: 645342
URL: http://svn.apache.org/viewvc?rev=645342&view=rev
Log:
Test case for NET-211
Modified:
commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java?rev=645342&r1=645341&r2=645342&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java (original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java Sun Apr 6 19:08:02 2008
@@ -227,7 +227,15 @@
* Check how short date is interpreted at a given time
*/
private void checkShortParse(String msg, Calendar now, Calendar input) throws ParseException {
+ checkShortParse(msg, now, input, false);
+ }
+
+ /*
+ * Check how short date is interpreted at a given time
+ */
+ private void checkShortParse(String msg, Calendar now, Calendar input, boolean lenient) throws ParseException {
FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
+ parser.setLenientFutureDates(true);
Format shortFormat = parser.getRecentDateFormat(); // It's expecting this format
Format longFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
@@ -325,6 +333,22 @@
fail("Should have failed to parse Feb 29th 1999");
} catch (ParseException expected) {
}
+ }
+
+ public void testParseDec31Lenient() throws Exception {
+ GregorianCalendar now = new GregorianCalendar(2007, Calendar.DECEMBER, 30, 12, 0);
+ checkShortParse("2007-12-30",now,now); // should always work
+ GregorianCalendar target = (GregorianCalendar) now.clone();
+ target.add(Calendar.DAY_OF_YEAR, +1); // tomorrow
+ checkShortParse("2007-12-31",now,target, true);
+ }
+
+ public void testParseJan01Lenient() throws Exception {
+ GregorianCalendar now = new GregorianCalendar(2007, Calendar.DECEMBER, 31, 12, 0);
+ checkShortParse("2007-12-31",now,now); // should always work
+ GregorianCalendar target = (GregorianCalendar) now.clone();
+ target.add(Calendar.DAY_OF_YEAR, +1); // tomorrow
+ checkShortParse("2008-1-1",now,target, true);
}
/**