### Question:
DiskChecker { public float checkDir(File dir) throws DiskErrorException, DiskOutOfSpaceException, DiskWarnThresholdException { float usage = checkDiskFull(dir); if (!mkdirsWithExistsCheck(dir)) { throw new DiskErrorException("can not create directory: " + dir.toString()); } if (!dir.isDirectory()) { throw new DiskErrorException("not a directory: " + dir.toString()); } if (!dir.canRead()) { throw new DiskErrorException("directory is not readable: " + dir.toString()); } if (!dir.canWrite()) { throw new DiskErrorException("directory is not writable: " + dir.toString()); } return usage; } DiskChecker(float threshold, float warnThreshold); long getTotalFreeSpace(List<File> dirs); long getTotalDiskSpace(List<File> dirs); float getTotalDiskUsage(List<File> dirs); float checkDir(File dir); float getDiskUsageThreshold(); float getDiskUsageWarnThreshold();  }### Answer:
@Test(expected = DiskErrorException.class) public void testCheckDiskErrorForFile() throws Exception { File parent = createTempDir("DiskCheck", "test"); File child = File.createTempFile("DiskCheck", "test", parent); diskChecker.checkDir(child); }
@Test public void testCheckDiskErrorForDir() throws Exception { File parent = createTempDir("DiskCheck", "test"); File child = File.createTempFile("DiskCheck", "test", parent); child.delete(); child.mkdir(); diskChecker.checkDir(child); }