Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change test case to output more info
Browse files Browse the repository at this point in the history
lgh committed Nov 10, 2023
1 parent 5a5ede8 commit 8eec4d1
Showing 1 changed file with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -866,17 +866,24 @@ public void testLocalhostReverseLookup() {

@Test (timeout=15000)
public void testIsValidName() {
assertFalse(DFSUtil.isValidName("/foo/../bar"));
assertFalse(DFSUtil.isValidName("/foo/./bar"));
assertFalse(DFSUtil.isValidName("/foo//bar"));
assertTrue(DFSUtil.isValidName("/"));
assertTrue(DFSUtil.isValidName("/bar/"));
assertFalse(DFSUtil.isValidName("/foo/:/bar"));
assertFalse(DFSUtil.isValidName("/foo:bar"));
String validPaths[] = new String[]{"/", "/bar/"};
for (String path : validPaths) {
assertTrue("Should have been accepted '" + path + "'", DFSUtil.isValidName(path));
}

String invalidPaths[] =
new String[]{"/foo/../bar", "/foo/./bar", "/foo//bar", "/foo/:/bar", "/foo:bar"};
for (String path : invalidPaths) {
assertFalse("Should have been rejected '" + path + "'", DFSUtil.isValidName(path));
}

String windowsPath = "/C:/foo/bar";
if (Shell.WINDOWS) {
assertTrue(DFSUtil.isValidName("/C:/some/path"));
assertTrue("Should have been accepted '" + windowsPath + "' in windows os.",
DFSUtil.isValidName(windowsPath));
} else {
assertFalse(DFSUtil.isValidName("/C:/some/path"));
assertFalse("Should have been rejected '" + windowsPath + "' in unix os.",
DFSUtil.isValidName(windowsPath));
}
}

0 comments on commit 8eec4d1

Please sign in to comment.