Search in sources :

Example 1 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class RepositoryPurgeConsumerTest method cleanupFileTypes.

private void cleanupFileTypes() {
    ArchivaConfiguration archivaConfiguration = applicationContext.getBean("archivaConfiguration#default", ArchivaConfiguration.class);
    FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get(0);
    fileType.removePattern("**/*.xml");
}
Also used : FileType(org.apache.archiva.configuration.model.FileType) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Example 2 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class ArchivaDavResourceFactoryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    request = mock(DavServletRequest.class);
    response = mock(DavServletResponse.class);
    // responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
    archivaConfiguration = mock(ArchivaConfiguration.class);
    config = new Configuration();
    when(archivaConfiguration.getConfiguration()).thenReturn(config);
    when(archivaConfiguration.getDefaultLocale()).thenReturn(Locale.getDefault());
    archivaConfiguration.addListener(any());
    archivaConfiguration.save(eq(config));
    archivaConfiguration.save(eq(config), anyString());
    defaultManagedRepositoryAdmin.setArchivaConfiguration(archivaConfiguration);
    repositoryRegistry.setArchivaConfiguration(archivaConfiguration);
    repositoryRegistry.reload();
    ((DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator()).setArchivaConfiguration(archivaConfiguration);
    if (defaultManagedRepositoryAdmin.getManagedRepository(RELEASES_REPO) == null) {
        defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(RELEASES_REPO, getProjectBase().resolve("target/test-classes/" + RELEASES_REPO).toString(), "default"), false, null);
    }
    if (defaultManagedRepositoryAdmin.getManagedRepository(INTERNAL_REPO) == null) {
        defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(INTERNAL_REPO, getProjectBase().resolve("target/test-classes/" + INTERNAL_REPO).toString(), "default"), false, null);
    }
    RepositoryGroup repoGroupConfig = new RepositoryGroup();
    repoGroupConfig.setId(LOCAL_REPO_GROUP);
    repoGroupConfig.addRepository(RELEASES_REPO);
    repoGroupConfig.addRepository(INTERNAL_REPO);
    defaultRepositoryGroupAdmin.setArchivaConfiguration(archivaConfiguration);
    if (defaultManagedRepositoryAdmin.getManagedRepository(LOCAL_REPO_GROUP) == null) {
        defaultRepositoryGroupAdmin.addRepositoryGroup(repoGroupConfig, null);
    }
    repoFactory = mock(RepositoryContentFactory.class);
    repoRequest = mock(MavenRepositoryRequestInfo.class);
    resourceFactory = new OverridingArchivaDavResourceFactory(applicationContext, archivaConfiguration);
    resourceFactory.setArchivaConfiguration(archivaConfiguration);
    proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).clear();
    proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).add(new OverridingRepositoryProxyHandler(this));
    resourceFactory.setProxyRegistry(proxyRegistry);
    resourceFactory.setRemoteRepositoryAdmin(remoteRepositoryAdmin);
    resourceFactory.setManagedRepositoryAdmin(defaultManagedRepositoryAdmin);
    resourceFactory.setRepositoryRegistry(repositoryRegistry);
    verify(archivaConfiguration, atLeast(2)).getConfiguration();
    verify(archivaConfiguration, atMost(25)).getConfiguration();
    verify(archivaConfiguration, atMost(4)).addListener(any());
    verify(archivaConfiguration, atMost(5)).save(eq(config));
    verify(archivaConfiguration, atMost(5)).save(eq(config), anyString());
}
Also used : DavServletRequest(org.apache.jackrabbit.webdav.DavServletRequest) MavenRepositoryRequestInfo(org.apache.archiva.maven.repository.content.MavenRepositoryRequestInfo) Configuration(org.apache.archiva.configuration.model.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RepositoryGroup(org.apache.archiva.admin.model.beans.RepositoryGroup) DavServletResponse(org.apache.jackrabbit.webdav.DavServletResponse) DefaultRepositoryCommonValidator(org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) RepositoryContentFactory(org.apache.archiva.repository.RepositoryContentFactory) Before(org.junit.Before)

Example 3 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class RepositoryServletTest method testGetRepositoryAfterAdd.

@Test
public void testGetRepositoryAfterAdd() throws Exception {
    RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
    assertNotNull(servlet);
    ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
    Configuration c = archivaConfiguration.getConfiguration();
    ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
    repo.setId(NEW_REPOSITORY_ID);
    repo.setName(NEW_REPOSITORY_NAME);
    Path repoRoot = Paths.get("target/test-repository-root");
    if (!Files.exists(repoRoot)) {
        Files.createDirectories(repoRoot);
    }
    repo.setLocation(repoRoot.toAbsolutePath().toString());
    c.addManagedRepository(repo);
    saveConfiguration(archivaConfiguration);
    ManagedRepository repository = servlet.getRepository(NEW_REPOSITORY_ID);
    assertNotNull(repository);
    assertEquals(NEW_REPOSITORY_NAME, repository.getName());
    // check other is still intact
    assertRepositoryValid(servlet, REPOID_INTERNAL);
}
Also used : Path(java.nio.file.Path) ManagedRepository(org.apache.archiva.repository.ManagedRepository) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) Test(org.junit.Test)

Example 4 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class CleanupReleasedSnapshotsRepositoryPurgeTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    RepositoryContentFactory factory = applicationContext.getBean("repositoryContentFactory#cleanup-released-snapshots", RepositoryContentFactory.class);
    archivaConfiguration = applicationContext.getBean("archivaConfiguration#cleanup-released-snapshots", ArchivaConfiguration.class);
    listener = mock(RepositoryListener.class);
    List<RepositoryListener> listeners = Collections.singletonList(listener);
    Mockito.when(sessionFactory.createSession()).thenReturn(repositorySession);
    Mockito.when(repositorySession.getRepository()).thenReturn(metadataRepository);
    repositorySession.save();
    repoPurge = new CleanupReleasedSnapshotsRepositoryPurge(getRepository(), metadataTools, applicationContext.getBean(ArchivaRepositoryRegistry.class), repositorySession, listeners);
    ((DefaultManagedRepositoryAdmin) applicationContext.getBean(ManagedRepositoryAdmin.class)).setArchivaConfiguration(archivaConfiguration);
}
Also used : RepositoryListener(org.apache.archiva.metadata.audit.RepositoryListener) ManagedRepositoryAdmin(org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin) DefaultManagedRepositoryAdmin(org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin) RepositoryContentFactory(org.apache.archiva.repository.RepositoryContentFactory) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) DefaultManagedRepositoryAdmin(org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin) Before(org.junit.Before)

Example 5 with ArchivaConfiguration

use of org.apache.archiva.configuration.provider.ArchivaConfiguration in project archiva by apache.

the class RepositoryContentConsumersTest method lookupRepositoryConsumers.

private RepositoryContentConsumers lookupRepositoryConsumers() throws Exception {
    ArchivaConfiguration configuration = applicationContext.getBean("archivaConfiguration#test-conf", ArchivaConfiguration.class);
    ArchivaAdministrationStub administrationStub = new ArchivaAdministrationStub(configuration);
    RepositoryContentConsumers consumerUtilStub = new RepositoryContentConsumersStub(administrationStub);
    RepositoryContentConsumers consumerUtil = applicationContext.getBean("repositoryContentConsumers#test", RepositoryContentConsumers.class);
    ApplicationContext context = new // 
    MockApplicationContext(// 
    consumerUtil.getAvailableKnownConsumers(), consumerUtil.getAvailableInvalidConsumers());
    consumerUtilStub.setApplicationContext(context);
    consumerUtilStub.setSelectedInvalidConsumers(consumerUtil.getSelectedInvalidConsumers());
    consumerUtilStub.setSelectedKnownConsumers(consumerUtil.getSelectedKnownConsumers());
    consumerUtilStub.setArchivaAdministration(administrationStub);
    assertNotNull("RepositoryContentConsumers should not be null.", consumerUtilStub);
    return consumerUtilStub;
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration)

Aggregations

ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)14 Configuration (org.apache.archiva.configuration.model.Configuration)6 Path (java.nio.file.Path)5 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)5 Before (org.junit.Before)5 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 FileType (org.apache.archiva.configuration.model.FileType)2 FileTypes (org.apache.archiva.configuration.provider.FileTypes)2 HttpAuthenticator (org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator)2 ManagedRepository (org.apache.archiva.repository.ManagedRepository)2 RepositoryContentFactory (org.apache.archiva.repository.RepositoryContentFactory)2 ServletAuthenticator (org.apache.archiva.security.ServletAuthenticator)2 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 RepositoryGroup (org.apache.archiva.admin.model.beans.RepositoryGroup)1 ManagedRepositoryAdmin (org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin)1 DefaultRepositoryCommonValidator (org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator)1