commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r645439 - /commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/ftp/parser/FTPTimestampParserImplTest.java
Date Mon, 07 Apr 2008 10:07:49 GMT
Author: sebb
Date: Mon Apr  7 03:07:48 2008
New Revision: 645439

URL: http://svn.apache.org/viewvc?rev=645439&view=rev
Log:
Fix copy/paste error in checkShortParse()
Add Jan01 test
Ensure past short dates work with lenient true/false

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=645439&r1=645438&r2=645439&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
Mon Apr  7 03:07:48 2008
@@ -224,18 +224,21 @@
 	}
 	
     /*
-     * Check how short date is interpreted at a given time
+     * Check how short date is interpreted at a given time.
+     * Check both with and without lenient future dates
      */
     private void checkShortParse(String msg, Calendar now, Calendar input) throws ParseException
{
         checkShortParse(msg, now, input, false);
+        checkShortParse(msg, now, input, true);
     }
 
     /*
      * Check how short date is interpreted at a given time
+     * Check only using specified lenient future dates setting
      */
     private void checkShortParse(String msg, Calendar now, Calendar input, boolean lenient)
throws ParseException {
         FTPTimestampParserImpl parser = new FTPTimestampParserImpl();
-        parser.setLenientFutureDates(true);
+        parser.setLenientFutureDates(lenient);
         Format shortFormat = parser.getRecentDateFormat(); // It's expecting this format
         Format longFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
         
@@ -349,6 +352,14 @@
         GregorianCalendar target = (GregorianCalendar) now.clone();
         target.add(Calendar.DAY_OF_YEAR, +1); // tomorrow
         checkShortParse("2008-1-1",now,target, true);
+    }
+
+    public void testParseJan01() throws Exception {
+        GregorianCalendar now = new GregorianCalendar(2007, Calendar.JANUARY, 1, 12, 0);
+        checkShortParse("2007-01-01",now,now); // should always work
+        GregorianCalendar target = new GregorianCalendar(2006, Calendar.DECEMBER, 31, 12,
0);
+        checkShortParse("2006-12-31",now,target, true);
+        checkShortParse("2006-12-31",now,target, false);
     }
 
     /**



Mime
View raw message