Selaa lähdekoodia

HDFS-2509. Add a test for DistributedFileSystem.getFileChecksum(..) on directories or non existing files. Contributed by Uma Maheswara Rao G

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1190677 13f79535-47bb-0310-9956-ffa450edef68
Tsz-wo Sze 13 vuotta sitten
vanhempi
commit
c8ac31e9a0

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -828,6 +828,9 @@ Release 0.23.0 - Unreleased
     HDFS-2493. Remove reference to FSNamesystem in blockmanagement classes.
     (szetszwo)
 
+    HDFS-2509. Add a test for DistributedFileSystem.getFileChecksum(..) on
+    directories or non existing files.  (Uma Maheswara Rao G via szetszwo)
+
   OPTIMIZATIONS
 
     HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

+ 20 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java

@@ -412,6 +412,26 @@ public class TestDistributedFileSystem {
     final UserGroupInformation ugi = UserGroupInformation.createUserForTesting(
         current.getShortUserName() + "x", new String[]{"user"});
     
+    try {
+      ((DistributedFileSystem) hdfs).getFileChecksum(new Path(
+          "/test/TestNonExistingFile"));
+      fail("Expecting FileNotFoundException");
+    } catch (FileNotFoundException e) {
+      assertTrue("Not throwing the intended exception message", e.getMessage()
+          .contains("File does not exist: /test/TestNonExistingFile"));
+    }
+    
+    try {
+      Path path = new Path(
+      "/test/TestExistingDir/");
+      hdfs.mkdirs(path);
+      ((DistributedFileSystem) hdfs).getFileChecksum(path);
+      fail("Expecting FileNotFoundException");
+    } catch (FileNotFoundException e) {
+      assertTrue("Not throwing the intended exception message", e.getMessage()
+          .contains("File does not exist: /test/TestExistingDir"));
+    }
+    
     //hftp
     final String hftpuri = "hftp://" + nnAddr;
     System.out.println("hftpuri=" + hftpuri);