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:07:05 UTC
svn commit: r645341 -
/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Author: sebb
Date: Sun Apr 6 19:07:03 2008
New Revision: 645341
URL: http://svn.apache.org/viewvc?rev=645341&view=rev
Log:
Test case for NET-211
Modified:
commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Modified: commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java?rev=645341&r1=645340&r2=645341&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java (original)
+++ commons/proper/net/trunk/src/test/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java Sun Apr 6 19:07:03 2008
@@ -138,7 +138,7 @@
// the only difference should be the two hours
// difference, no rolling back a year should occur.
assertEquals("no.rollback.because.of.time.zones",
- (long)TWO_HOURS_OF_MILLISECONDS,
+ TWO_HOURS_OF_MILLISECONDS,
cal.getTime().getTime() - parsed.getTime().getTime());
} catch (ParseException e){
fail("Unable to parse " + fmtTimePlusOneHour);
@@ -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(lenient);
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);
}
/**