try {
Metadata md1, md2;
// get metadata from a gidr router with merging on (default is on), merge should happen
eventBus().post(new ConfigurationChangeEvent(getApplicationConfiguration(), null, null));
StorageItem item =
getRootRouter().retrieveItem(new ResourceStoreRequest("/groups/test" + spoofedPath, false));
// save it
saveItemToFile((StorageFileItem) item, md1File);
// some content check
md1 = readMetadata(md1File);
assertEquals(3, md1.getVersioning().getVersions().size());
assertEquals("20030303030303", md1.getVersioning().getLastUpdated());
// get metadata directly from repo1, no aggregation, no spoofing
StorageItem item1 =
getRepositoryRegistry().getRepository("repo1").retrieveItem(
new ResourceStoreRequest(spoofedPath, false));
// it should be a file and unmodified
checkForFileAndMatchContents(item1);
// save it
saveItemToFile((StorageFileItem) item1, md1File);
// some content check
md1 = readMetadata(md1File);
assertEquals("1.0", md1.getVersioning().getRelease());
assertEquals(1, md1.getVersioning().getVersions().size());
assertEquals("20010101010101", md1.getVersioning().getLastUpdated());
// get metadata directly from repo2, no aggregation, no spoofing
StorageItem item2 =
getRepositoryRegistry().getRepository("repo2").retrieveItem(
new ResourceStoreRequest(spoofedPath, false));
// it should be a file and unmodified
checkForFileAndMatchContents(item2);
// save it
saveItemToFile((StorageFileItem) item2, md2File);
// some content check
md2 = readMetadata(md2File);
assertEquals("1.1", md2.getVersioning().getRelease());
assertEquals(1, md2.getVersioning().getVersions().size());
assertEquals("20020202020202", md2.getVersioning().getLastUpdated());
// get metadata from a gidr router but switch merging off (default is on), spoofing should happen, and the
// highest ranked repo in group (repo1) should provide the file
MavenGroupRepository mgr =
getRepositoryRegistry().getRepositoryWithFacet("test", MavenGroupRepository.class);
mgr.setMergeMetadata(false);
((AbstractMavenGroupRepository)mgr).commitChanges();
// mgr.getCurrentCoreConfiguration().commitChanges();
eventBus().post(new ConfigurationChangeEvent(getApplicationConfiguration(), null, null));
item = getRootRouter().retrieveItem(new ResourceStoreRequest("/groups/test" + spoofedPath, false));
// it should be a file and unmodified
checkForFileAndMatchContents(item, md1File);
}