Search in sources :

Example 1 with ArchivaConfiguration

use of org.apache.archiva.configuration.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.admin.model.beans.ManagedRepository) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) Test(org.junit.Test)

Example 2 with ArchivaConfiguration

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

the class FileMetadataRepositoryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    Path directory = Paths.get("target/test-repositories");
    if (Files.exists(directory)) {
        org.apache.archiva.common.utils.FileUtils.deleteDirectory(directory);
    }
    ArchivaConfiguration config = createTestConfiguration(directory);
    Map<String, MetadataFacetFactory> factories = createTestMetadataFacetFactories();
    this.repository = new FileMetadataRepository(factories, config);
}
Also used : Path(java.nio.file.Path) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) MetadataFacetFactory(org.apache.archiva.metadata.model.MetadataFacetFactory) Before(org.junit.Before)

Example 3 with ArchivaConfiguration

use of org.apache.archiva.configuration.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);
    listenerControl = EasyMock.createControl();
    listener = listenerControl.createMock(RepositoryListener.class);
    List<RepositoryListener> listeners = Collections.singletonList(listener);
    repoPurge = new CleanupReleasedSnapshotsRepositoryPurge(getRepository(), metadataTools, applicationContext.getBean(RepositoryRegistry.class), repositorySession, listeners);
    ((DefaultManagedRepositoryAdmin) applicationContext.getBean(ManagedRepositoryAdmin.class)).setArchivaConfiguration(archivaConfiguration);
}
Also used : RepositoryListener(org.apache.archiva.repository.events.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.ArchivaConfiguration) DefaultManagedRepositoryAdmin(org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin) Before(org.junit.Before)

Example 4 with ArchivaConfiguration

use of org.apache.archiva.configuration.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.FileType) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration)

Example 5 with ArchivaConfiguration

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

the class ArchivaDavResourceFactoryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    requestControl = createControl();
    request = requestControl.createMock(DavServletRequest.class);
    responseControl = createControl();
    response = responseControl.createMock(DavServletResponse.class);
    // responseControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
    archivaConfigurationControl = createControl();
    archivaConfiguration = archivaConfigurationControl.createMock(ArchivaConfiguration.class);
    config = new Configuration();
    expect(archivaConfiguration.getConfiguration()).andReturn(config).times(2, 20);
    expect(archivaConfiguration.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
    archivaConfiguration.addListener(EasyMock.anyObject());
    expectLastCall().times(0, 4);
    archivaConfiguration.save(config);
    expectLastCall().times(0, 4);
    archivaConfigurationControl.replay();
    defaultManagedRepositoryAdmin.setArchivaConfiguration(archivaConfiguration);
    repositoryRegistry.setArchivaConfiguration(archivaConfiguration);
    repositoryRegistry.reload();
    ((DefaultRepositoryCommonValidator) defaultManagedRepositoryAdmin.getRepositoryCommonValidator()).setArchivaConfiguration(archivaConfiguration);
    if (defaultManagedRepositoryAdmin.getManagedRepository(RELEASES_REPO) == null) {
        defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(RELEASES_REPO, Paths.get("target/test-classes/" + RELEASES_REPO).toString(), "default"), false, null);
    }
    if (defaultManagedRepositoryAdmin.getManagedRepository(INTERNAL_REPO) == null) {
        defaultManagedRepositoryAdmin.addManagedRepository(createManagedRepository(INTERNAL_REPO, Paths.get("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);
    }
    repoContentFactoryControl = createControl();
    repoFactory = repoContentFactoryControl.createMock(RepositoryContentFactory.class);
    repoRequestControl = createControl();
    repoRequest = repoRequestControl.createMock(RepositoryRequest.class);
    resourceFactory = new OverridingArchivaDavResourceFactory(applicationContext, plexusSisuBridge, archivaConfiguration);
    resourceFactory.setArchivaConfiguration(archivaConfiguration);
    resourceFactory.setRepositoryFactory(repoFactory);
    resourceFactory.setRepositoryRequest(repoRequest);
    resourceFactory.setConnectors(new OverridingRepositoryProxyConnectors());
    resourceFactory.setRemoteRepositoryAdmin(remoteRepositoryAdmin);
    resourceFactory.setManagedRepositoryAdmin(defaultManagedRepositoryAdmin);
    resourceFactory.setRepositoryRegistry(repositoryRegistry);
}
Also used : DavServletRequest(org.apache.jackrabbit.webdav.DavServletRequest) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RepositoryGroup(org.apache.archiva.admin.model.beans.RepositoryGroup) RepositoryRequest(org.apache.archiva.repository.content.maven2.RepositoryRequest) DavServletResponse(org.apache.jackrabbit.webdav.DavServletResponse) DefaultRepositoryCommonValidator(org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RepositoryContentFactory(org.apache.archiva.repository.RepositoryContentFactory) Before(org.junit.Before)

Aggregations

ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)15 Path (java.nio.file.Path)7 Before (org.junit.Before)7 Configuration (org.apache.archiva.configuration.Configuration)6 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)5 ManagedRepository (org.apache.archiva.admin.model.beans.ManagedRepository)3 ManagedRepositoryAdmin (org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 URI (java.net.URI)2 DefaultManagedRepositoryAdmin (org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin)2 FileType (org.apache.archiva.configuration.FileType)2 FileTypes (org.apache.archiva.configuration.FileTypes)2 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)2 HttpAuthenticator (org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator)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 IOException (java.io.IOException)1