FileUtils { public static boolean containsReservedCharacter( String path, char[] reserved ) { while ( !path.isEmpty() ) { String name = FilenameUtils.getName( path ); if ( StringUtils.containsAny( name, reserved ) ) { return true; } path = FilenameUtils.getPathNoEndSeparator( path ); } return false; }  static String idToPath( String pathId ); static boolean closeQuietly( FileInputStream fileInputStream ); static boolean containsReservedCharacter( String path, char[] reserved ); static boolean containsControlCharacters( String path ); static String[] convertCommaSeparatedStringToArray( String stringToConvert ); static String getParentPath( final String path ); static boolean isRootLevelPath( final String path ); static final String PATH_SEPARATOR; static final String ENCODED_PATH_SEPARATOR; }
@Test public void containsReservedCharacter_Empty() { assertFalse( containsReservedCharacter( "", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_Root() { assertFalse( containsReservedCharacter( "/", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_Folder_NoSlashAtEnd_Ok() { assertFalse( containsReservedCharacter( "/a", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_Folder_NoSlashAtEnd_Bad() { assertTrue( containsReservedCharacter( "/a%", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_Folder_SlashAtEnd_Ok() { assertFalse( containsReservedCharacter( "/a/", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_Folder_SlashAtEnd_Bad() { assertTrue( containsReservedCharacter( "/a%/", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_File_Ok() { assertFalse( containsReservedCharacter( "/a/b/c/qwerty.txt", TEST_RESERVED ) ); }
@Test public void containsReservedCharacter_File_Bad() { assertTrue( containsReservedCharacter( "/a/b/c/qwerty%.txt", TEST_RESERVED ) ); }