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());
}
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());
}
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());
}
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();
}
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();
}
Aggregations