### Question:
StorageManagerUtil { public static boolean isValidDirName(String basename) { if (StringUtils.isBlank(basename)) { return true; } if (!isValidPath(basename)) { return false; } Pattern pattern = Pattern.compile(REGEXP_DIR); Matcher matcher = pattern.matcher(basename); boolean check = matcher.matches(); if (!check) { return false; } return endWithParentDir(basename); } private  StorageManagerUtil(); static boolean isValidFilename(String fullname); static boolean isValidFilename(String basename, String extension); static boolean isValidFilenameNoExtension(String basename); static boolean isValidDirName(String basename); static boolean isValidExtension(String extension);  }### Answer:
@Test public void isValidDirName() { Assert.assertTrue(StorageManagerUtil.isValidDirName(null)); Assert.assertTrue(StorageManagerUtil.isValidDirName("dirname")); Assert.assertTrue(StorageManagerUtil.isValidDirName("dirname.txt")); Assert.assertTrue(StorageManagerUtil.isValidDirName("dirn ame.xht")); Assert.assertTrue(StorageManagerUtil.isValidDirName("dir_name.ney")); Assert.assertTrue(StorageManagerUtil.isValidDirName("dir name")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir_name (1)")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir_?name")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir_../name")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir../name.subname")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir_nam%2e%2e/e")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir..%2f_name")); Assert.assertFalse(StorageManagerUtil.isValidDirName("dir_na%2e%2e%2fme")); }