Skip to content

Commit 8eec4d1

Browse files
author
lgh
committed
change test case to output more info
1 parent 5a5ede8 commit 8eec4d1

File tree

1 file changed

+16
-9
lines changed
  • hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs

1 file changed

+16
-9
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java

+16-9
Original file line numberDiff line numberDiff line change
@@ -866,17 +866,24 @@ public void testLocalhostReverseLookup() {
866866

867867
@Test (timeout=15000)
868868
public void testIsValidName() {
869-
assertFalse(DFSUtil.isValidName("/foo/../bar"));
870-
assertFalse(DFSUtil.isValidName("/foo/./bar"));
871-
assertFalse(DFSUtil.isValidName("/foo//bar"));
872-
assertTrue(DFSUtil.isValidName("/"));
873-
assertTrue(DFSUtil.isValidName("/bar/"));
874-
assertFalse(DFSUtil.isValidName("/foo/:/bar"));
875-
assertFalse(DFSUtil.isValidName("/foo:bar"));
869+
String validPaths[] = new String[]{"/", "/bar/"};
870+
for (String path : validPaths) {
871+
assertTrue("Should have been accepted '" + path + "'", DFSUtil.isValidName(path));
872+
}
873+
874+
String invalidPaths[] =
875+
new String[]{"/foo/../bar", "/foo/./bar", "/foo//bar", "/foo/:/bar", "/foo:bar"};
876+
for (String path : invalidPaths) {
877+
assertFalse("Should have been rejected '" + path + "'", DFSUtil.isValidName(path));
878+
}
879+
880+
String windowsPath = "/C:/foo/bar";
876881
if (Shell.WINDOWS) {
877-
assertTrue(DFSUtil.isValidName("/C:/some/path"));
882+
assertTrue("Should have been accepted '" + windowsPath + "' in windows os.",
883+
DFSUtil.isValidName(windowsPath));
878884
} else {
879-
assertFalse(DFSUtil.isValidName("/C:/some/path"));
885+
assertFalse("Should have been rejected '" + windowsPath + "' in unix os.",
886+
DFSUtil.isValidName(windowsPath));
880887
}
881888
}
882889

0 commit comments

Comments
 (0)