MD5FileUtils { public static void verifySavedMD5(File dataFile, MD5Hash expectedMD5) throws IOException { MD5Hash storedHash = readStoredMd5ForFile(dataFile); if (!expectedMD5.equals(storedHash)) { throw new IOException( "File " + dataFile + " did not match stored MD5 checksum " + " (stored: " + storedHash + ", computed: " + expectedMD5); } }  static void verifySavedMD5(File dataFile, MD5Hash expectedMD5); static MD5Hash readStoredMd5ForFile(File dataFile); static MD5Hash computeMd5ForFile(File dataFile); static void saveMD5File(File dataFile, MD5Hash digest); static void renameMD5File(File oldDataFile, File newDataFile); static File getDigestFileForFile(File file); static final String MD5_SUFFIX; }
@Test(expected = IOException.class) public void testVerifyMD5FileMissing() throws Exception { MD5FileUtils.verifySavedMD5(TEST_FILE, TEST_MD5); }