ChecksumUtils { public static String calculateHash(File resourceFile, HashAlgorithm algorithm) throws IOException { return new HashCalculator().calculateHash(resourceFile, algorithm); } private  ChecksumUtils(); static String calculateSHA1(File resourceFile); static String calculateHash(File resourceFile, HashAlgorithm algorithm); static void calculateHeaderAndFooterSha1(File file, DependencyInfo dependencyInfo); static void calculateSuperHash(DependencyInfo dependencyInfo, File dependencyFile); static String calculateOtherPlatformSha1(File file); static void calculateOtherPlatformSha1(DependencyInfo dependency, File file);  }
@Test public void testEmptyFileMD5() throws IOException { String filePath = getClass().getResource(EMPTY_FILE_TXT).getFile(); File file = new File(URLDecoder.decode(filePath, UTF_8)); String md5 = ChecksumUtils.calculateHash(file, HashAlgorithm.MD5); Assert.assertEquals(EMPTY_FILE_MD5, md5); }
@Test public void testMD5() throws IOException { String filePath = getClass().getResource(NON_EMPTY_FILE_TXT).getFile(); File file = new File(URLDecoder.decode(filePath, UTF_8)); String md5 = ChecksumUtils.calculateHash(file, HashAlgorithm.MD5); if (Platform.isWindows()) { Assert.assertEquals(NON_EMPTY_FILE_WINDOWS_MD5, md5); } else { Assert.assertEquals(NON_EMPTY_FILE_UNIX_MD5, md5); } }