@@ -866,17 +866,24 @@ public void testLocalhostReverseLookup() {
866
866
867
867
@ Test (timeout =15000 )
868
868
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" ;
876
881
if (Shell .WINDOWS ) {
877
- assertTrue (DFSUtil .isValidName ("/C:/some/path" ));
882
+ assertTrue ("Should have been accepted '" + windowsPath + "' in windows os." ,
883
+ DFSUtil .isValidName (windowsPath ));
878
884
} else {
879
- assertFalse (DFSUtil .isValidName ("/C:/some/path" ));
885
+ assertFalse ("Should have been rejected '" + windowsPath + "' in unix os." ,
886
+ DFSUtil .isValidName (windowsPath ));
880
887
}
881
888
}
882
889
0 commit comments