Search in sources :

Example 26 with RepositoryGroupConfiguration

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());
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) URI(java.net.URI) Test(org.junit.Test)

Example 27 with RepositoryGroupConfiguration

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;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration)

Example 28 with RepositoryGroupConfiguration

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());
    }
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) DavException(org.apache.jackrabbit.webdav.DavException) ArrayList(java.util.ArrayList) ManagedRepositoryContent(org.apache.archiva.repository.ManagedRepositoryContent) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator) Test(org.junit.Test)

Aggregations

RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)28 EditableRepositoryGroup (org.apache.archiva.repository.EditableRepositoryGroup)11 RepositoryException (org.apache.archiva.repository.RepositoryException)10 Configuration (org.apache.archiva.configuration.model.Configuration)9 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)9 RepositoryGroup (org.apache.archiva.repository.RepositoryGroup)9 ArrayList (java.util.ArrayList)8 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)7 Map (java.util.Map)5 ValidationError (org.apache.archiva.repository.validation.ValidationError)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 ContextConfiguration (org.springframework.test.context.ContextConfiguration)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4 List (java.util.List)4 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)4 RepositoryProvider (org.apache.archiva.repository.RepositoryProvider)4 RepositoryType (org.apache.archiva.repository.RepositoryType)4 Path (java.nio.file.Path)3