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 2014/12/11 16:58:34 UTC

svn commit: r1644685 - /commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java

Author: sebb
Date: Thu Dec 11 15:58:34 2014
New Revision: 1644685

URL: http://svn.apache.org/r1644685
Log:
Need to check all significant units are set ...

Modified:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java?rev=1644685&r1=1644684&r2=1644685&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java (original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/parser/FTPParseTestFramework.java Thu Dec 11 15:58:34 2014
@@ -171,10 +171,18 @@ public abstract class FTPParseTestFramew
         assertNotNull("Could not parse "+listEntry, file);
         Calendar stamp = file.getTimestamp();
         assertNotNull("Failed to parse time in "+listEntry, stamp);
-        assertTrue("Expected set "+expectedPrecision+" in "+listEntry, stamp.isSet(expectedPrecision.unit));
         final int ordinal = expectedPrecision.ordinal();
+        final CalendarUnit[] values = CalendarUnit.values();
+        // Check expected unit and all more significant ones are set
+        // This is needed for FTPFile.toFormattedString() to work correctly
+        for(int i = ordinal; i < values.length; i++) {
+            CalendarUnit unit = values[i];
+            assertTrue("Expected set "+unit+" in "+listEntry, stamp.isSet(unit.unit));            
+        }
+        // Check previous entry (if any) is not set
+        // This is also needed for FTPFile.toFormattedString() to work correctly
         if (ordinal > 0) {
-            final CalendarUnit prevUnit = CalendarUnit.values()[ordinal-1];
+            final CalendarUnit prevUnit = values[ordinal-1];
             assertFalse("Expected not set "+prevUnit+" in "+listEntry, stamp.isSet(prevUnit.unit));            
         }
     }