File target = prepareTestJar( "javax.persistence_2.0.5.v201212031355.jar" );
assertTrue( JarSignerUtil.isArchiveSigned( target ) );
// check that manifest contains some digest attributes
Manifest originalManifest = readManifest( target );
assertTrue( containsDigest( originalManifest ) );
Manifest originalCleanManifest = JarSignerUtil.buildUnsignedManifest( originalManifest );
assertFalse( containsDigest( originalCleanManifest ) );
assertTrue( originalCleanManifest.equals( JarSignerUtil.buildUnsignedManifest( originalCleanManifest ) ) );
JarSignerUtil.unsignArchive( target );
assertFalse( JarSignerUtil.isArchiveSigned( target ) );
// check that manifest has no digest entry
// see https://jira.codehaus.org/browse/MSHARED-314
Manifest manifest = readManifest( target );
Manifest cleanManifest = JarSignerUtil.buildUnsignedManifest( manifest );
assertFalse( containsDigest( cleanManifest ) );
assertTrue( manifest.equals( cleanManifest ) );
assertTrue( manifest.equals( originalCleanManifest ) );