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 2012/07/17 01:50:39 UTC

svn commit: r1362315 - /commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java

Author: sebb
Date: Mon Jul 16 23:50:39 2012
New Revision: 1362315

URL: http://svn.apache.org/viewvc?rev=1362315&view=rev
Log:
Avoid possible NPE

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

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java?rev=1362315&r1=1362314&r2=1362315&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java (original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/ftp/FTPClientConfigFunctionalTest.java Mon Jul 16 23:50:39 2012
@@ -143,18 +143,21 @@ public class FTPClientConfigFunctionalTe
             lastfile = thisfile;
         }
 
-        // test that notwithstanding any time zone differences, the newest file
-        // is older than now.
-        assertTrue(lastfile.getTimestamp().getTime().before(now));
-        Calendar first = firstfile.getTimestamp();
-
-        // test that the oldest is less than two days older than the newest
-        // and, in particular, that no files have been considered "future"
-        // by the parser and therefore been relegated to the same date a
-        // year ago.
-        first.add(Calendar.DATE, 2);
-        assertTrue(lastfile.getTimestamp().getTime().toString()+" before "+ first.getTime().toString(),lastfile.getTimestamp().before(first));
-
+        if (firstfile == null || lastfile == null)  {
+            fail("No files found");
+        } else {
+            // test that notwithstanding any time zone differences, the newest file
+            // is older than now.
+            assertTrue(lastfile.getTimestamp().getTime().before(now));
+            Calendar first = firstfile.getTimestamp();
+    
+            // test that the oldest is less than two days older than the newest
+            // and, in particular, that no files have been considered "future"
+            // by the parser and therefore been relegated to the same date a
+            // year ago.
+            first.add(Calendar.DATE, 2);
+            assertTrue(lastfile.getTimestamp().getTime().toString()+" before "+ first.getTime().toString(),lastfile.getTimestamp().before(first));
+        }
     }
 }