public void testNexus4985GroupsShouldNotSwallowMemberExceptions()
throws Exception
{
// add another group to make things a bit hairier
{
M2GroupRepository group = (M2GroupRepository) lookup(GroupRepository.class, "maven2");
CRepository repoGroupConf = new DefaultCRepository();
repoGroupConf.setProviderRole(GroupRepository.class.getName());
repoGroupConf.setProviderHint("maven2");
repoGroupConf.setId("another-test");
repoGroupConf.setLocalStorage(new CLocalStorage());
repoGroupConf.getLocalStorage().setProvider("file");
repoGroupConf.getLocalStorage().setUrl(
getApplicationConfiguration().getWorkingDirectory("proxy/store/another-test").toURI().toURL().toString());
Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
repoGroupConf.setExternalConfiguration(exGroupRepo);
M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
// members are "test" (an existing group, to have group of group) and repo1 that is already member via
// "test"
exGroupRepoConf.setMemberRepositoryIds(Arrays.asList("test", "repo1"));
exGroupRepoConf.setMergeMetadata(true);
group.configure(repoGroupConf);
getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
getRepositoryRegistry().addRepository(group);
}
// now put a hosted repository "inhouse-snapshot" out of service to make output nicer
final Repository inhouseSnapshot = getRepositoryRegistry().getRepository("inhouse-snapshot");
inhouseSnapshot.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
((AbstractMavenRepository) inhouseSnapshot).commitChanges();
// so far, what we did: we had few reposes and a group called "test" (that had all the reposes as members).
// now, we added test and repo1 reposes ta a newly created group, to have groups of groups.
// we also put a member repo "inhouse-snapshot" out of service.
// now we ask for something that IS KNOWN TO NOT EXISTS, hence, request will arrive to all members
// and members of members (recursively), and the response will form a nice tree
final GroupRepository group =
getRepositoryRegistry().getRepositoryWithFacet("another-test", GroupRepository.class);
try {
group.retrieveItem(new ResourceStoreRequest("/some/path/that/we/know/is/not/existing/123456/12.foo"));
// anything else should fail
fail("We expected an exception here!");
}
catch (GroupItemNotFoundException e) {
final String dumpStr = dumpNotFoundReasoning(e, 0);