Search in sources :

Example 31 with Configuration

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

the class RepositoryRegistryTest method removeRemoteRepositoryWithoutSave.

@Test
public void removeRemoteRepositoryWithoutSave() throws Exception {
    Configuration configuration = archivaConfiguration.getConfiguration();
    assertEquals(1, repositoryRegistry.getRemoteRepositories().size());
    RemoteRepository repo = repositoryRegistry.getRemoteRepository("central");
    repositoryRegistry.removeRepository(repo, configuration);
    assertEquals(0, repositoryRegistry.getRemoteRepositories().size());
    assertTrue(repositoryRegistry.getRemoteRepositories().stream().noneMatch(rep -> rep.getId().equals("central")));
    archivaConfiguration.reload();
    repositoryRegistry.reload();
    assertEquals(1, repositoryRegistry.getRemoteRepositories().size());
}
Also used : AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Files(java.nio.file.Files) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaSpringJUnit4ClassRunner(org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner) Test(org.junit.Test) IOException(java.io.IOException) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) StandardCopyOption(java.nio.file.StandardCopyOption) Inject(javax.inject.Inject) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Paths(java.nio.file.Paths) After(org.junit.After) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) Assert(org.junit.Assert) Path(java.nio.file.Path) Before(org.junit.Before) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) Test(org.junit.Test)

Example 32 with Configuration

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

the class RepositoryRegistryTest method putManagedRepositoryFromConfigWithoutSave.

@Test
public void putManagedRepositoryFromConfigWithoutSave() throws Exception {
    Configuration configuration = archivaConfiguration.getConfiguration();
    ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
    cfg.setId("test002");
    cfg.setName("This is test 002");
    ManagedRepository repo = repositoryRegistry.putRepository(cfg, configuration);
    assertNotNull(repo);
    assertEquals("test002", repo.getId());
    assertEquals("This is test 002", repo.getName());
    assertNotNull(repo.getContent());
    archivaConfiguration.reload();
    assertEquals(3, archivaConfiguration.getConfiguration().getManagedRepositories().size());
    Collection<ManagedRepository> repos = repositoryRegistry.getManagedRepositories();
    assertEquals(5, repos.size());
    ManagedRepository internalRepo = repositoryRegistry.getManagedRepository("internal");
    cfg = new ManagedRepositoryConfiguration();
    cfg.setId("internal");
    cfg.setName("This is internal test 002");
    repo = repositoryRegistry.putRepository(cfg, configuration);
    assertTrue(internalRepo == repo);
    assertEquals("This is internal test 002", repo.getName());
    assertEquals(5, repositoryRegistry.getManagedRepositories().size());
    repositoryRegistry.reload();
    assertEquals(4, repositoryRegistry.getManagedRepositories().size());
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Test(org.junit.Test)

Example 33 with Configuration

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

the class RepositoryRegistryTest method removeManagedRepositoryWithoutSave.

@Test
public void removeManagedRepositoryWithoutSave() throws Exception {
    Configuration configuration = archivaConfiguration.getConfiguration();
    assertEquals(4, repositoryRegistry.getManagedRepositories().size());
    ManagedRepository repo = repositoryRegistry.getManagedRepository("snapshots");
    repositoryRegistry.removeRepository(repo, configuration);
    assertEquals(3, repositoryRegistry.getManagedRepositories().size());
    assertTrue(repositoryRegistry.getManagedRepositories().stream().noneMatch(rep -> rep.getId().equals("snapshots")));
    archivaConfiguration.reload();
    repositoryRegistry.reload();
    assertEquals(4, repositoryRegistry.getManagedRepositories().size());
}
Also used : AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Files(java.nio.file.Files) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) Collection(java.util.Collection) RunWith(org.junit.runner.RunWith) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaSpringJUnit4ClassRunner(org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner) Test(org.junit.Test) IOException(java.io.IOException) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) StandardCopyOption(java.nio.file.StandardCopyOption) Inject(javax.inject.Inject) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) Paths(java.nio.file.Paths) After(org.junit.After) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) Assert(org.junit.Assert) Path(java.nio.file.Path) Before(org.junit.Before) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) Test(org.junit.Test)

Example 34 with Configuration

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

the class AbstractRepositoryServletTestCase method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    String appserverBase = Paths.get("target/appserver-base").toAbsolutePath().toString();
    System.setProperty("appserver.base", appserverBase);
    Path testConf = Paths.get("src/test/resources/repository-archiva.xml");
    Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml");
    if (Files.exists(testConfDest)) {
        org.apache.archiva.common.utils.FileUtils.deleteQuietly(testConfDest);
    }
    FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
    repoRootInternal = Paths.get(appserverBase, "data/repositories/internal");
    repoRootLegacy = Paths.get(appserverBase, "data/repositories/legacy");
    Configuration config = archivaConfiguration.getConfiguration();
    config.getManagedRepositories().clear();
    config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal, true));
    repositoryRegistry.reload();
    config.getProxyConnectors().clear();
    config.getRemoteRepositories().clear();
    saveConfiguration(archivaConfiguration);
    CacheManager.getInstance().clearAll();
}
Also used : Path(java.nio.file.Path) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) Configuration(org.apache.archiva.configuration.Configuration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Before(org.junit.Before)

Example 35 with Configuration

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

the class AbstractMavenRepositorySearch method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer"));
    assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_1 + "/.indexer")));
    FileUtils.deleteDirectory(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer"));
    assertFalse(Files.exists(Paths.get(org.apache.archiva.common.utils.FileUtils.getBasedir(), "/target/repos/" + TEST_REPO_2 + "/.indexer")));
    archivaConfigControl = EasyMock.createControl();
    archivaConfig = archivaConfigControl.createMock(ArchivaConfiguration.class);
    DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
    defaultManagedRepositoryAdmin.setArchivaConfiguration(archivaConfig);
    DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin();
    defaultProxyConnectorAdmin.setArchivaConfiguration(archivaConfig);
    repositoryRegistry.setArchivaConfiguration(archivaConfig);
    search = new MavenRepositorySearch(indexer, repositoryRegistry, defaultProxyConnectorAdmin, queryCreator);
    assertNotNull(repositoryRegistry);
    defaultManagedRepositoryAdmin.setRepositoryRegistry(repositoryRegistry);
    config = new Configuration();
    config.addManagedRepository(createRepositoryConfig(TEST_REPO_1));
    config.addManagedRepository(createRepositoryConfig(TEST_REPO_2));
    config.addManagedRepository(createRepositoryConfig(REPO_RELEASE));
    archivaConfig.addListener(EasyMock.anyObject(ConfigurationListener.class));
    EasyMock.expect(archivaConfig.getDefaultLocale()).andReturn(Locale.getDefault()).anyTimes();
    EasyMock.expect(archivaConfig.getConfiguration()).andReturn(config).anyTimes();
    archivaConfig.save(EasyMock.anyObject(Configuration.class));
    EasyMock.expectLastCall().anyTimes();
    archivaConfigControl.replay();
    repositoryRegistry.reload();
    archivaConfigControl.reset();
}
Also used : ConfigurationListener(org.apache.archiva.configuration.ConfigurationListener) DefaultProxyConnectorAdmin(org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.ManagedRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Configuration(org.apache.archiva.configuration.Configuration) ArchivaConfiguration(org.apache.archiva.configuration.ArchivaConfiguration) DefaultManagedRepositoryAdmin(org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin) Before(org.junit.Before)

Aggregations

Configuration (org.apache.archiva.configuration.Configuration)63 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)30 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)29 ProxyConnectorConfiguration (org.apache.archiva.configuration.ProxyConnectorConfiguration)21 RemoteRepositoryConfiguration (org.apache.archiva.configuration.RemoteRepositoryConfiguration)19 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)18 ContextConfiguration (org.springframework.test.context.ContextConfiguration)16 NetworkConfiguration (org.apache.archiva.admin.model.beans.NetworkConfiguration)13 UiConfiguration (org.apache.archiva.admin.model.beans.UiConfiguration)13 WebappConfiguration (org.apache.archiva.configuration.WebappConfiguration)13 IndeterminateConfigurationException (org.apache.archiva.configuration.IndeterminateConfigurationException)11 RepositoryGroupConfiguration (org.apache.archiva.configuration.RepositoryGroupConfiguration)11 RegistryException (org.apache.archiva.redback.components.registry.RegistryException)11 Before (org.junit.Before)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 Path (java.nio.file.Path)8 RepositoryException (org.apache.archiva.repository.RepositoryException)7 IOException (java.io.IOException)4 NetworkProxyConfiguration (org.apache.archiva.configuration.NetworkProxyConfiguration)4