소스 검색

HADOOP-13051. Test for special characters in path being respected during globPaths. Contributed by Harsh J.

Ravi Prakash 9 년 전
부모
커밋
d8faf47f32
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java

+ 19 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/TestGlobPaths.java

@@ -88,6 +88,25 @@ public class TestGlobPaths {
     }
   }
 
+  /**
+   * Test case to ensure that globs work on files with special characters.
+   * Tests with a file pair where one has a \r at end and other does not.
+   */
+  @Test
+  public void testCRInPathGlob() throws IOException {
+    FileStatus[] statuses;
+    Path d1 = new Path(USER_DIR, "dir1");
+    Path fNormal = new Path(d1, "f1");
+    Path fWithCR = new Path(d1, "f1\r");
+    fs.mkdirs(d1);
+    fs.createNewFile(fNormal);
+    fs.createNewFile(fWithCR);
+    statuses = fs.globStatus(new Path(d1, "f1*"));
+    assertEquals("Expected both normal and CR-carrying files in result: ",
+        2, statuses.length);
+    cleanupDFS();
+  }
+
   @Test
   public void testMultiGlob() throws IOException {
     FileStatus[] status;