ArtifactRepositoryPolicy.CHECKSUM_POLICY_FAIL );
ArtifactRepository repo =
new DefaultArtifactRepository( "id", "string://url", new ArtifactRepositoryLayoutStub(), policy, policy );
Artifact artifact =
new DefaultArtifact( "sample.group", "sample-art", VersionRange.createFromVersion( "1.0" ), "scope",
"jar", "classifier", null );
artifact.setFile( getTestFile( "target/sample-art" ) );
StringWagon wagon = (StringWagon) wagonManager.getWagon( "string" );
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "lower-case-checksum" );
wagon.addExpectedContent( "path.sha1", "2a25dc564a3b34f68237fc849066cbc7bb7a36a1" );
try
{
wagonManager.getArtifact( artifact, repo );
}
catch ( ChecksumFailedException e )
{
fail( "Checksum verification did not pass: " + e.getMessage() );
}
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "upper-case-checksum" );
wagon.addExpectedContent( "path.sha1", "B7BB97D7D0B9244398D9B47296907F73313663E6" );
try
{
wagonManager.getArtifact( artifact, repo );
}
catch ( ChecksumFailedException e )
{
fail( "Checksum verification did not pass: " + e.getMessage() );
}
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "expected-failure" );
wagon.addExpectedContent( "path.sha1", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
try
{
wagonManager.getArtifact( artifact, repo );
fail( "Checksum verification did not fail" );
}
catch ( ChecksumFailedException e )
{
// expected
}
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "lower-case-checksum" );
wagon.addExpectedContent( "path.md5", "50b2cf50a103a965efac62b983035cac" );
try
{
wagonManager.getArtifact( artifact, repo );
}
catch ( ChecksumFailedException e )
{
fail( "Checksum verification did not pass: " + e.getMessage() );
}
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "upper-case-checksum" );
wagon.addExpectedContent( "path.md5", "842F568FCCFEB7E534DC72133D42FFDC" );
try
{
wagonManager.getArtifact( artifact, repo );
}
catch ( ChecksumFailedException e )
{
fail( "Checksum verification did not pass: " + e.getMessage() );
}
artifact.getFile().delete();
wagon.clearExpectedContent();
wagon.addExpectedContent( "path", "expected-failure" );
wagon.addExpectedContent( "path.md5", "b7bb97d7d0b9244398d9b47296907f73313663e6" );
try