FileUtil { public static boolean makeSessionDirectory(String sessionId) { if (sessionId == null || "".equals(sessionId)) { return false; } return getSessionDirectory(sessionId).mkdirs(); }  static String getSessionDirectoryName(String sessionId); static File getSessionDirectory(String sessionId); static boolean makeSessionDirectory(String sessionId); static boolean removeSessionDirectory(String sessionId); static boolean rmdirs(File dir);  }
@Test public void testMakeSessionDirectory01() throws Exception { String input = "01234567abcdefgh"; String dirName = StringUtil.toHexString(HashUtil.hashSHA1(input), ""); File dir = new File(TMP_SESSIONS_DIR + dirName); if (dir.exists()) { dir.delete(); } boolean result = FileUtil.makeSessionDirectory(input); assertTrue(result); if (!dir.exists()) { fail(); } }
@Test public void testMakeSessionDirectory02() throws Exception { String input = "01234567abcdefgh"; String dirName = StringUtil.toHexString(HashUtil.hashSHA1(input), ""); File dir = new File(TMP_SESSIONS_DIR + dirName); if (dir.exists()) { dir.delete(); } FileUtil.makeSessionDirectory(input); boolean result = FileUtil.makeSessionDirectory(input); assertFalse(result); if (!dir.exists()) { fail(); } }
@Test public void testMakeSessionDirectory03() throws Exception { String input = null; boolean result = FileUtil.makeSessionDirectory(input); assertFalse(result); }
@Test public void testMakeSessionDirectory04() throws Exception { String input = ""; boolean result = FileUtil.makeSessionDirectory(input); assertFalse(result); }