Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
lgh committed Nov 3, 2023
1 parent 9f7aac6 commit 5a5ede8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ public static boolean isValidName(String src) {
for (int i = 0; i < components.length; i++) {
String element = components[i];
// For Windows, we must allow the : in the drive letter.
if (Shell.WINDOWS && i == 1 && element.contains(":")) {
if (Shell.WINDOWS && i == 1 && element.endsWith(":")) {
continue;
}
if (element.equals(".") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.apache.hadoop.security.alias.JavaKeyStoreProvider;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.Shell;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -872,6 +873,11 @@ public void testIsValidName() {
assertTrue(DFSUtil.isValidName("/bar/"));
assertFalse(DFSUtil.isValidName("/foo/:/bar"));
assertFalse(DFSUtil.isValidName("/foo:bar"));
if (Shell.WINDOWS) {
assertTrue(DFSUtil.isValidName("/C:/some/path"));
} else {
assertFalse(DFSUtil.isValidName("/C:/some/path"));
}
}

@Test(timeout=5000)
Expand Down

0 comments on commit 5a5ede8

Please sign in to comment.