final Repository repo = inhouseRelease;
// == 1st pass: we recreate all the maven metadata for given repo to have them all in place
{
final DefaultWalkerContext ctx =
new DefaultWalkerContext(repo, new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT, true));
ctx.getProcessors().add(new RecreateMavenMetadataWalkerProcessor(getLogger()));
walker.walk(ctx);
}
// === 2nd pass: all MD is recreated, and they are valid, NO overwrite should happen at all!
{
final DefaultWalkerContext ctx =
new DefaultWalkerContext(repo, new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT, true));
ctx.getProcessors().add(new RecreateMavenMetadataWalkerProcessor(getLogger()));
final ValidationEventListener validationEventListener = new ValidationEventListener();
eventBus().register(validationEventListener);
walker.walk(ctx);
eventBus().unregister(validationEventListener);
assertFalse("We should not record any STORE!", validationEventListener.hasStoresRecorded());
}
// === 3rd pass: e manually "break" one checksum, and expect that one only to be overwritten
{
final String checksumPath = "/com/mycom/group1/maven-metadata.xml.sha1";
final String checksumPathMd5 = "/com/mycom/group1/maven-metadata.xml.md5";
// coming from http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.pom.sha1
final String wrongChecksum = "93c66c9afd6cf7b91bd4ecf38a60ca48fc5f2078";
repo.storeItem(new ResourceStoreRequest(checksumPath),
new ByteArrayInputStream(wrongChecksum.getBytes("UTF-8")), null);
final DefaultWalkerContext ctx =
new DefaultWalkerContext(repo, new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT, true));
ctx.getProcessors().add(new RecreateMavenMetadataWalkerProcessor(getLogger()));
final ValidationEventListener validationEventListener = new ValidationEventListener();
eventBus().register(validationEventListener);
walker.walk(ctx);
eventBus().unregister(validationEventListener);