Search in sources :

Example 61 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class RepositoryGroupHandlerTest method testPutWithoutRegister.

@Test
void testPutWithoutRegister() throws RepositoryException {
    RepositoryGroupHandler groupHandler = createHandler();
    Configuration aCfg = new Configuration();
    RepositoryGroupConfiguration configuration = new RepositoryGroupConfiguration();
    final String id = "test-group-06";
    configuration.setId(id);
    configuration.setName("n-" + id);
    ArrayList<String> repos = new ArrayList<>();
    repos.add("internal");
    configuration.setRepositories(repos);
    groupHandler.put(configuration, aCfg);
    RepositoryGroup repo = groupHandler.get(id);
    assertNull(repo);
    assertFalse(hasGroupInConfig(id));
    assertTrue(aCfg.getRepositoryGroups().stream().anyMatch(g -> g != null && id.equals(g.getId())));
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArgumentMatchers(org.mockito.ArgumentMatchers) CheckedResult(org.apache.archiva.repository.validation.CheckedResult) Mock(org.mockito.Mock) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) ArchivaRepositoryRegistry(org.apache.archiva.repository.base.ArchivaRepositoryRegistry) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) RemoteRepository(org.apache.archiva.repository.RemoteRepository) RepositoryHandler(org.apache.archiva.repository.RepositoryHandler) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ISEMPTY(org.apache.archiva.repository.validation.ErrorKeys.ISEMPTY) Map(java.util.Map) FileUtils(org.apache.archiva.common.utils.FileUtils) Named(javax.inject.Named) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) ConfigurationHandler(org.apache.archiva.repository.base.ConfigurationHandler) ValidationError(org.apache.archiva.repository.validation.ValidationError) Path(java.nio.file.Path) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Iterator(java.util.Iterator) SpringExtension(org.springframework.test.context.junit.jupiter.SpringExtension) Files(java.nio.file.Files) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) RepositoryException(org.apache.archiva.repository.RepositoryException) MergedRemoteIndexesScheduler(org.apache.archiva.indexer.merger.MergedRemoteIndexesScheduler) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) IOException(java.io.IOException) RepositoryType(org.apache.archiva.repository.RepositoryType) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Mockito.verify(org.mockito.Mockito.verify) BasicRemoteRepository(org.apache.archiva.repository.base.remote.BasicRemoteRepository) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) Paths(java.nio.file.Paths) ContextConfiguration(org.springframework.test.context.ContextConfiguration) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Assertions(org.junit.jupiter.api.Assertions) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) RepositoryState(org.apache.archiva.repository.RepositoryState) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) EditableRepositoryGroup(org.apache.archiva.repository.EditableRepositoryGroup) RepositoryGroup(org.apache.archiva.repository.RepositoryGroup) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 62 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class ManagedRepositoryHandlerTest method testPutWithoutRegister.

@Test
void testPutWithoutRegister() throws RepositoryException {
    final String id = "test-repo-06";
    ManagedRepositoryHandler repoHandler = createHandler();
    Configuration aCfg = new Configuration();
    ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
    configuration.setId(id);
    configuration.setName("n-" + id);
    repoHandler.put(configuration, aCfg);
    ManagedRepository repo = repoHandler.get(id);
    assertNull(repo);
    assertFalse(hasRepositoryInConfig(id));
    assertTrue(aCfg.getManagedRepositories().stream().anyMatch(g -> g != null && id.equals(g.getId())));
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) CheckedResult(org.apache.archiva.repository.validation.CheckedResult) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) ArchivaRepositoryRegistry(org.apache.archiva.repository.base.ArchivaRepositoryRegistry) Inject(javax.inject.Inject) Repository(org.apache.archiva.repository.Repository) RepositoryContentFactory(org.apache.archiva.repository.RepositoryContentFactory) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ISEMPTY(org.apache.archiva.repository.validation.ErrorKeys.ISEMPTY) IndexManagerFactory(org.apache.archiva.indexer.IndexManagerFactory) Map(java.util.Map) FileUtils(org.apache.archiva.common.utils.FileUtils) Named(javax.inject.Named) ConfigurationHandler(org.apache.archiva.repository.base.ConfigurationHandler) ValidationError(org.apache.archiva.repository.validation.ValidationError) Path(java.nio.file.Path) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryValidator(org.apache.archiva.repository.validation.RepositoryValidator) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) Iterator(java.util.Iterator) SpringExtension(org.springframework.test.context.junit.jupiter.SpringExtension) Files(java.nio.file.Files) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) RepositoryException(org.apache.archiva.repository.RepositoryException) IOException(java.io.IOException) RepositoryType(org.apache.archiva.repository.RepositoryType) ManagedRepository(org.apache.archiva.repository.ManagedRepository) Test(org.junit.jupiter.api.Test) List(java.util.List) Paths(java.nio.file.Paths) ContextConfiguration(org.springframework.test.context.ContextConfiguration) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Assertions(org.junit.jupiter.api.Assertions) RepositoryState(org.apache.archiva.repository.RepositoryState) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ManagedRepository(org.apache.archiva.repository.ManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Test(org.junit.jupiter.api.Test)

Example 63 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class ManagedRepositoryHandlerTest method newInstancesFromConfig.

@Test
void newInstancesFromConfig() throws RepositoryException {
    final String id = "test-repo-01";
    ManagedRepositoryHandler repoHandler = createHandler();
    Configuration configuration = new Configuration();
    repoHandler.remove("test-repo-01", configuration);
    Map<String, ManagedRepository> instances = repoHandler.newInstancesFromConfig();
    assertFalse(repoHandler.hasRepository(id));
    assertTrue(instances.containsKey(id));
    assertEquals(RepositoryState.REFERENCES_SET, instances.get(id).getLastState());
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Test(org.junit.jupiter.api.Test)

Example 64 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class ManagedRepositoryHandlerTest method removeRepositoryFromConfig.

// Helper method that removes a repo from the configuration
private void removeRepositoryFromConfig(String id) {
    Configuration configuration = configurationHandler.getBaseConfiguration();
    Iterator<ManagedRepositoryConfiguration> iter = configuration.getManagedRepositories().iterator();
    while (iter.hasNext()) {
        ManagedRepositoryConfiguration repo = iter.next();
        if (id.equals(repo.getId())) {
            iter.remove();
            break;
        }
    }
    try {
        configurationHandler.save(configuration);
    } catch (Throwable e) {
        System.err.println("Could not remove repo from config " + id);
    }
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)

Example 65 with Configuration

use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.

the class RemoteRepositoryHandlerTest method testPutWithoutRegister.

@Test
void testPutWithoutRegister() throws RepositoryException {
    final String id = "test-repo-06";
    RemoteRepositoryHandler repoHandler = createHandler();
    Configuration aCfg = new Configuration();
    RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration();
    configuration.setId(id);
    configuration.setName("n-" + id);
    repoHandler.put(configuration, aCfg);
    RemoteRepository repo = repoHandler.get(id);
    assertNull(repo);
    assertFalse(hasRepositoryInConfig(id));
    assertTrue(aCfg.getRemoteRepositories().stream().anyMatch(g -> g != null && id.equals(g.getId())));
}
Also used : ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) CheckedResult(org.apache.archiva.repository.validation.CheckedResult) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) ArchivaRepositoryRegistry(org.apache.archiva.repository.base.ArchivaRepositoryRegistry) Inject(javax.inject.Inject) Repository(org.apache.archiva.repository.Repository) RepositoryContentFactory(org.apache.archiva.repository.RepositoryContentFactory) RemoteRepository(org.apache.archiva.repository.RemoteRepository) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ISEMPTY(org.apache.archiva.repository.validation.ErrorKeys.ISEMPTY) IndexManagerFactory(org.apache.archiva.indexer.IndexManagerFactory) Map(java.util.Map) FileUtils(org.apache.archiva.common.utils.FileUtils) Named(javax.inject.Named) ConfigurationHandler(org.apache.archiva.repository.base.ConfigurationHandler) ValidationError(org.apache.archiva.repository.validation.ValidationError) Path(java.nio.file.Path) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryValidator(org.apache.archiva.repository.validation.RepositoryValidator) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) EditableRemoteRepository(org.apache.archiva.repository.EditableRemoteRepository) Iterator(java.util.Iterator) SpringExtension(org.springframework.test.context.junit.jupiter.SpringExtension) Files(java.nio.file.Files) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) RepositoryException(org.apache.archiva.repository.RepositoryException) IOException(java.io.IOException) RepositoryType(org.apache.archiva.repository.RepositoryType) Test(org.junit.jupiter.api.Test) List(java.util.List) Paths(java.nio.file.Paths) ContextConfiguration(org.springframework.test.context.ContextConfiguration) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Assertions(org.junit.jupiter.api.Assertions) RepositoryState(org.apache.archiva.repository.RepositoryState) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RemoteRepository(org.apache.archiva.repository.RemoteRepository) EditableRemoteRepository(org.apache.archiva.repository.EditableRemoteRepository) Test(org.junit.jupiter.api.Test)

Aggregations

Configuration (org.apache.archiva.configuration.model.Configuration)94 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)56 ContextConfiguration (org.springframework.test.context.ContextConfiguration)45 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)42 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)34 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)34 WebappConfiguration (org.apache.archiva.configuration.model.WebappConfiguration)32 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)29 Path (java.nio.file.Path)27 Test (org.junit.Test)26 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)23 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)23 RepositoryException (org.apache.archiva.repository.RepositoryException)22 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)14 ManagedRepository (org.apache.archiva.repository.ManagedRepository)13 IOException (java.io.IOException)12 ArrayList (java.util.ArrayList)12 RemoteRepository (org.apache.archiva.repository.RemoteRepository)12 Test (org.junit.jupiter.api.Test)12 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)11