use of org.apache.archiva.configuration.model.RepositoryGroupConfiguration in project archiva by apache.
the class MavenRepositoryProviderTest method getRepositoryGroupConfiguration.
@Test
public void getRepositoryGroupConfiguration() throws RepositoryException, URISyntaxException, IOException {
MavenRepositoryGroup repositoryGroup = MavenRepositoryGroup.newLocalInstance("group1", "group1", Paths.get("target/groups"));
MavenManagedRepository repo1 = MavenManagedRepository.newLocalInstance("test01", "My Test repo", Paths.get("target/repositories"));
MavenManagedRepository repo2 = MavenManagedRepository.newLocalInstance("test02", "My Test repo", Paths.get("target/repositories"));
repositoryGroup.setDescription(repositoryGroup.getPrimaryLocale(), "Repository group");
repositoryGroup.setLayout("non-default");
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature(IndexCreationFeature.class);
indexCreationFeature.setIndexPath(new URI(".index2"));
repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), "Repo Group 1");
repositoryGroup.setMergedIndexTTL(1005);
repositoryGroup.setSchedulingDefinition("0 0 04 ? * THU");
repositoryGroup.addRepository(repo1);
repositoryGroup.addRepository(repo2);
RepositoryGroupConfiguration cfg = provider.getRepositoryGroupConfiguration(repositoryGroup);
assertEquals("group1", cfg.getId());
assertEquals(".index2", cfg.getMergedIndexPath());
assertEquals("0 0 04 ? * THU", cfg.getCronExpression());
assertEquals("Repo Group 1", cfg.getName());
assertEquals(1005, cfg.getMergedIndexTtl());
assertTrue(cfg.getRepositories().contains("test01"));
assertTrue(cfg.getRepositories().contains("test02"));
assertEquals(2, cfg.getRepositories().size());
}
use of org.apache.archiva.configuration.model.RepositoryGroupConfiguration in project archiva by apache.
the class RepositoryServletRepositoryGroupTest method createRepositoryGroup.
protected RepositoryGroupConfiguration createRepositoryGroup(String id, List<String> repositories) {
RepositoryGroupConfiguration repoGroupConfiguration = new RepositoryGroupConfiguration();
repoGroupConfiguration.setId(id);
repoGroupConfiguration.setRepositories(repositories);
return repoGroupConfiguration;
}
use of org.apache.archiva.configuration.model.RepositoryGroupConfiguration in project archiva by apache.
the class ArchivaDavResourceFactoryTest method testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled.
@Test
public void testRepositoryGroupArtifactDoesNotExistInAnyOfTheReposAuthenticationDisabled() throws Exception {
DavResourceLocator locator = new ArchivaDavResourceLocator("", "/repository/" + LOCAL_REPO_GROUP + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP, new ArchivaDavLocatorFactory());
defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(LOCAL_MIRROR_REPO, Paths.get("target/test-classes/local-mirror").toString(), "default"), false, null);
List<RepositoryGroupConfiguration> repoGroups = new ArrayList<>();
RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
repoGroup.setId(LOCAL_REPO_GROUP);
repoGroup.addRepository(INTERNAL_REPO);
repoGroup.addRepository(LOCAL_MIRROR_REPO);
repoGroups.add(repoGroup);
config.setRepositoryGroups(repoGroups);
ManagedRepositoryContent internalRepo = createManagedRepositoryContent(INTERNAL_REPO);
ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent(LOCAL_MIRROR_REPO);
repositoryRegistry.putRepositoryGroup(repoGroup);
try {
reset(archivaConfiguration);
reset(request);
reset(repoFactory);
when(archivaConfiguration.getConfiguration()).thenReturn(config);
when(request.getMethod()).thenReturn("GET");
when(request.getPathInfo()).thenReturn("org/apache/archiva");
when(repoFactory.getManagedRepositoryContent(INTERNAL_REPO)).thenReturn(internalRepo);
when(repoFactory.getManagedRepositoryContent(LOCAL_MIRROR_REPO)).thenReturn(localMirrorRepo);
when(request.getRemoteAddr()).thenReturn("http://localhost:8080");
when(request.getDavSession()).thenReturn(new ArchivaDavSession());
when(request.getContextPath()).thenReturn("");
when(repoRequest.isSupportFile("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn(false);
when(repoRequest.getLayout("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn("legacy");
when(repoRequest.toItemSelector("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn(null);
when(repoRequest.toNativePath("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn(Paths.get(config.findManagedRepositoryById(INTERNAL_REPO).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar").toString());
when(repoRequest.toNativePath("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn(Paths.get(config.findManagedRepositoryById(LOCAL_MIRROR_REPO).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar").toString());
when(repoRequest.isArchetypeCatalog("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar")).thenReturn(false);
resourceFactory.createResource(locator, request, response);
verify(archivaConfiguration, times(3)).getConfiguration();
verify(request, times(5)).getMethod();
verify(request, atMost(2)).getPathInfo();
verify(request, times(4)).getRemoteAddr();
verify(request, times(4)).getDavSession();
verify(request, times(2)).getContextPath();
verify(repoRequest, times(2)).isSupportFile("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar");
verify(repoRequest, times(2)).getLayout("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar");
verify(repoRequest, times(2)).toItemSelector("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar");
verify(repoRequest, times(2)).isArchetypeCatalog("org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar");
fail("A DavException with 404 error code should have been thrown.");
} catch (DavException e) {
assertEquals(404, e.getErrorCode());
}
}
Aggregations