### Question:
ChecksummedFile { public String calculateChecksum( ChecksumAlgorithm checksumAlgorithm ) throws IOException { Checksum checksum = new Checksum( checksumAlgorithm ); ChecksumUtil.update(checksum, referenceFile ); return checksum.getChecksum( ); } ChecksummedFile( final Path referenceFile ); static ChecksumReference getFromChecksumFile( Path checksumFile ); String calculateChecksum( ChecksumAlgorithm checksumAlgorithm ); Path writeFile(ChecksumAlgorithm checksumAlgorithm ); Path getChecksumFile( ChecksumAlgorithm checksumAlgorithm ); boolean isValidChecksum( ChecksumAlgorithm algorithm); boolean isValidChecksum( ChecksumAlgorithm algorithm, boolean throwExceptions ); boolean isValidChecksums( List<ChecksumAlgorithm> algorithms); boolean isValidChecksums( List<ChecksumAlgorithm> algorithms, boolean throwExceptions); Path getReferenceFile( ); UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm); UpdateStatusList fixChecksums( List<ChecksumAlgorithm> algorithms ); String parseChecksum( Path checksumFile, ChecksumAlgorithm checksumAlgorithm, String fileName, Charset encoding ); ChecksumFileContent parseChecksumFile( Path checksumFile, ChecksumAlgorithm checksumAlgorithm, Charset encoding );  }### Answer:
@Test public void testCalculateChecksumMd5() throws IOException { Path testfile = getTestResource( "examples/redback-authz-open.jar" ); ChecksummedFile checksummedFile = new ChecksummedFile( testfile ); String expectedChecksum = "f42047fe2e177ac04d0df7aa44d408be"; String actualChecksum = checksummedFile.calculateChecksum( ChecksumAlgorithm.MD5 ); Assert.assertEquals( expectedChecksum, actualChecksum ); }
@Test public void testCalculateChecksumSha1() throws IOException { Path testfile = getTestResource( "examples/redback-authz-open.jar" ); ChecksummedFile checksummedFile = new ChecksummedFile( testfile ); String expectedChecksum = "2bb14b388973351b0a4dfe11d171965f59cc61a1"; String actualChecksum = checksummedFile.calculateChecksum( ChecksumAlgorithm.SHA1 ); Assert.assertEquals( expectedChecksum, actualChecksum ); }