private void verifyChecksums( String repoLocation )
throws IOException
{
// verify checksums of jar file
ChecksummedFile checksum =
new ChecksummedFile( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ) );
String sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
String md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
String contents =
FileUtils.readFileToString( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
contents =
FileUtils.readFileToString( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar.md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
// verify checksums of pom file
checksum =
new ChecksummedFile( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom" ) );
sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
contents =
FileUtils.readFileToString( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );
contents =
FileUtils.readFileToString( new File( repoLocation,
"/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.pom.md5" ) );
assertTrue( StringUtils.contains( contents, md5 ) );
// verify checksums of metadata file
checksum =
new ChecksummedFile( new File( repoLocation, "/org/apache/archiva/artifact-upload/" +
MetadataTools.MAVEN_METADATA ) );
sha1 = checksum.calculateChecksum( ChecksumAlgorithm.SHA1 );
md5 = checksum.calculateChecksum( ChecksumAlgorithm.MD5 );
contents =
FileUtils.readFileToString( new File( repoLocation, "/org/apache/archiva/artifact-upload/" +
MetadataTools.MAVEN_METADATA + ".sha1" ) );
assertTrue( StringUtils.contains( contents, sha1 ) );