FileUtil { public static boolean removeSessionDirectory(String sessionId) { return rmdirs(getSessionDirectory(sessionId)); }  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 testRemoveSessionDirectory01() throws Exception { String input = "01234567abcdefgh"; Method method = FileUtil.class.getDeclaredMethod("makeSessionDirectory", String.class); method.setAccessible(true); method.invoke(FileUtil.class, input); assertTrue(FileUtil.removeSessionDirectory(input)); }
@Test public void testRemoveSessionDirectory02() throws Exception { String input = "01234567abcdefgh"; Method method = FileUtil.class.getDeclaredMethod("getSessionDirectory", String.class); method.setAccessible(true); File dir = (File) method.invoke(FileUtil.class, input); dir.delete(); assertFalse(FileUtil.removeSessionDirectory(input)); }
@Test public void testRemoveSessionDirectory03() throws Exception { try { FileUtil.removeSessionDirectory(null); fail(); } catch (NullPointerException e) { return; } fail(); }