@Test public void testFixChecksum() throws IOException, ChecksumValidationException { Path jarFile = createTestableJar( "examples/redback-authz-open.jar" ); Path sha1File = jarFile.resolveSibling( jarFile.getFileName()+ ".sha1" ); org.apache.commons.io.FileUtils.writeStringToFile( sha1File.toFile(), "sha1sum: redback-authz-open.jar: No such file or directory", "UTF-8" ); ChecksummedFile checksummedFile = new ChecksummedFile( jarFile ); Assert.assertFalse( "ChecksummedFile.isValid(SHA1) == false", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) ); UpdateStatusList fixed = checksummedFile.fixChecksums( Arrays.asList( ChecksumAlgorithm.SHA1 ) ); Assert.assertEquals(1, fixed.getStatusList().size()); Assert.assertFalse(fixed.getTotalStatus()==UpdateStatus.ERROR); Assert.assertTrue( "ChecksummedFile.fixChecksums() == true", fixed.getStatusList().get(0).getValue()==UpdateStatus.UPDATED ); Assert.assertTrue( "ChecksummedFile.isValid(SHA1) == true", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) ); }
public UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm) { return fixChecksums( Arrays.asList(algorithm) ); }
ChecksummedFile { public UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm) { return fixChecksums( Arrays.asList(algorithm) ); } }
ChecksummedFile { public UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm) { return fixChecksums( Arrays.asList(algorithm) ); } ChecksummedFile( final Path referenceFile ); }
ChecksummedFile { public UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm) { return fixChecksums( Arrays.asList(algorithm) ); } 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 ); }
ChecksummedFile { public UpdateStatusList fixChecksum(ChecksumAlgorithm algorithm) { return fixChecksums( Arrays.asList(algorithm) ); } 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 );  }