use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method testCronExpressionsWithComma.
@Test
public void testCronExpressionsWithComma() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
Files.createDirectories(baseFile.getParent());
FileUtils.copyFile(getTestFile("src/test/conf/escape-cron-expressions.xml").toFile(), baseFile.toFile());
Files.createDirectories(userFile.getParent());
FileUtils.writeStringToFile(userFile.toFile(), "<configuration/>", Charset.defaultCharset());
final ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-cron-expressions");
archivaConfiguration.reload();
Configuration configuration = archivaConfiguration.getConfiguration();
ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get(0);
assertEquals("check cron expression", "0 0,30 * * * ?", repository.getRefreshCronExpression().trim());
// add a test listener to confirm it doesn't see the escaped format. We don't need to test the number of calls,
// etc. as it's done in other tests
archivaConfiguration.addListener(new ConfigurationListener() {
@Override
public void configurationEvent(ConfigurationEvent event) {
assertEquals(ConfigurationEvent.SAVED, event.getType());
}
});
archivaConfiguration.save(configuration);
configuration = archivaConfiguration.getConfiguration();
// test for the escape character '\' showing up on repositories.jsp
repository.setRefreshCronExpression("0 0,20 0 * * ?");
archivaConfiguration.save(configuration);
repository = archivaConfiguration.getConfiguration().findManagedRepositoryById("snapshots");
assertEquals("check cron expression", "0 0,20 0 * * ?", repository.getRefreshCronExpression());
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method testGetConfigurationFromRegistryWithASingleNamedConfigurationResource.
@Test
public void testGetConfigurationFromRegistryWithASingleNamedConfigurationResource() throws Exception {
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-configuration");
Configuration configuration = archivaConfiguration.getConfiguration();
assertConfiguration(configuration, 2, 2, 2);
assertEquals("check network proxies", 1, configuration.getNetworkProxies().size());
ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get(0);
assertEquals("check managed repositories", "${appserver.base}/repositories/internal", repository.getLocation());
assertEquals("check managed repositories", "Archiva Managed Internal Repository", repository.getName());
assertEquals("check managed repositories", "internal", repository.getId());
assertEquals("check managed repositories", "default", repository.getLayout());
assertTrue("check managed repositories", repository.isScanned());
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method testRemoveLastElements.
@Test
public void testRemoveLastElements() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
Files.createDirectories(baseFile.getParent());
FileUtils.copyFile(getTestFile("src/test/conf/conf-single-list-elements.xml").toFile(), baseFile.toFile());
Files.createDirectories(userFile.getParent());
FileUtils.writeStringToFile(userFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-remove-central");
archivaConfiguration.reload();
Configuration configuration = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration repositoryGroup = configuration.getRepositoryGroups().get(0);
assertNotNull(repositoryGroup);
configuration.removeRepositoryGroup(repositoryGroup);
assertTrue(configuration.getRepositoryGroups().isEmpty());
RemoteRepositoryConfiguration repository = configuration.getRemoteRepositoriesAsMap().get("central");
assertNotNull(repository);
configuration.removeRemoteRepository(repository);
assertTrue(configuration.getRemoteRepositories().isEmpty());
ManagedRepositoryConfiguration managedRepository = configuration.getManagedRepositoriesAsMap().get("snapshots");
assertNotNull(managedRepository);
configuration.removeManagedRepository(managedRepository);
assertTrue(configuration.getManagedRepositories().isEmpty());
ProxyConnectorConfiguration proxyConnector = configuration.getProxyConnectors().get(0);
assertNotNull(proxyConnector);
configuration.removeProxyConnector(proxyConnector);
assertTrue(configuration.getProxyConnectors().isEmpty());
NetworkProxyConfiguration networkProxy = configuration.getNetworkProxiesAsMap().get("proxy");
assertNotNull(networkProxy);
configuration.removeNetworkProxy(networkProxy);
assertTrue(configuration.getNetworkProxies().isEmpty());
LegacyArtifactPath path = configuration.getLegacyArtifactPaths().get(0);
assertNotNull(path);
configuration.removeLegacyArtifactPath(path);
assertTrue(configuration.getLegacyArtifactPaths().isEmpty());
RepositoryScanningConfiguration scanning = configuration.getRepositoryScanning();
String consumer = scanning.getKnownContentConsumers().get(0);
assertNotNull(consumer);
scanning.removeKnownContentConsumer(consumer);
// default values
assertFalse(scanning.getKnownContentConsumers().isEmpty());
consumer = scanning.getInvalidContentConsumers().get(0);
assertNotNull(consumer);
scanning.removeInvalidContentConsumer(consumer);
assertTrue(scanning.getInvalidContentConsumers().isEmpty());
archivaConfiguration.save(configuration);
archivaConfiguration = lookup(ArchivaConfiguration.class, "test-read-saved");
configuration = archivaConfiguration.getConfiguration();
assertNull(configuration.getRemoteRepositoriesAsMap().get("central"));
assertTrue(configuration.getRepositoryGroups().isEmpty());
assertNull(configuration.getManagedRepositoriesAsMap().get("snapshots"));
assertTrue(configuration.getProxyConnectors().isEmpty());
assertNull(configuration.getNetworkProxiesAsMap().get("proxy"));
assertTrue(configuration.getLegacyArtifactPaths().isEmpty());
scanning = configuration.getRepositoryScanning();
assertFalse(scanning.getKnownContentConsumers().isEmpty());
assertTrue(scanning.getInvalidContentConsumers().isEmpty());
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class DefaultManagedRepositoryAdmin method getRepositoryConfiguration.
private ManagedRepositoryConfiguration getRepositoryConfiguration(ManagedRepository repo) {
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
setBaseRepoAttributes(repoConfig, repo);
repoConfig.setBlockRedeployments(repo.isBlockRedeployments());
repoConfig.setReleases(repo.isReleases());
repoConfig.setSnapshots(repo.isSnapshots());
repoConfig.setScanned(repo.isScanned());
repoConfig.setLocation(getRepositoryCommonValidator().removeExpressions(repo.getLocation()));
repoConfig.setRefreshCronExpression(repo.getCronExpression());
repoConfig.setRetentionPeriod(repo.getRetentionPeriod());
repoConfig.setRetentionCount(repo.getRetentionCount());
repoConfig.setDeleteReleasedSnapshots(repo.isDeleteReleasedSnapshots());
repoConfig.setSkipPackedIndexCreation(repo.isSkipPackedIndexCreation());
repoConfig.setStageRepoNeeded(repo.isStageRepoNeeded());
return repoConfig;
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ArchivaRepositoryRegistryTest method putManagedRepositoryFromConfigWithoutSave.
@Test
public void putManagedRepositoryFromConfigWithoutSave() throws Exception {
Configuration configuration = archivaConfiguration.getConfiguration();
int actualSize = configuration.getManagedRepositories().size();
Configuration newConfiguration = new Configuration();
ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
cfg.setId("test002");
cfg.setName("This is test 002");
ManagedRepository repo = repositoryRegistry.putRepository(cfg, newConfiguration);
assertNotNull(repo);
assertEquals("test002", repo.getId());
assertEquals("This is test 002", repo.getName());
assertNotNull(repo.getContent());
archivaConfiguration.reload();
assertEquals(actualSize, configuration.getManagedRepositories().size());
List<ManagedRepositoryConfiguration> repos = newConfiguration.getManagedRepositories();
assertEquals(1, repos.size());
ManagedRepository internalRepo = repositoryRegistry.getManagedRepository("internal");
cfg = new ManagedRepositoryConfiguration();
cfg.setId("internal");
cfg.setName("This is internal test 002");
repo = repositoryRegistry.putRepository(cfg, newConfiguration);
assertEquals("This is internal test 002", repo.getName());
assertEquals(2, newConfiguration.getManagedRepositories().size());
repositoryRegistry.reload();
assertEquals(actualSize, configuration.getManagedRepositories().size());
}
Aggregations