use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class ArchivaConfigurationTest method testConfigurationUpgradeFrom13.
@Test
public void testConfigurationUpgradeFrom13() throws Exception {
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-upgrade-1.3");
// we just use the defaults when upgrading from 1.3 at this point.
Configuration configuration = archivaConfiguration.getConfiguration();
assertConfiguration(configuration, 2, 2, 2);
assertEquals("check network proxies", 0, configuration.getNetworkProxies().size());
ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get(0);
assertEquals("check managed repositories", "${appserver.base}/data/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());
log.info("knowContentConsumers {}", configuration.getRepositoryScanning().getKnownContentConsumers());
assertFalse(configuration.getRepositoryScanning().getKnownContentConsumers().contains("update-db-artifact"));
assertFalse(configuration.getRepositoryScanning().getKnownContentConsumers().contains("update-db-repository-metadata"));
assertTrue(configuration.getRepositoryScanning().getKnownContentConsumers().contains("create-archiva-metadata"));
assertTrue(configuration.getRepositoryScanning().getKnownContentConsumers().contains("duplicate-artifacts"));
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class ArchivaConfigurationTest method testGetConfigurationSystemOverride.
@Test
public void testGetConfigurationSystemOverride() throws Exception {
System.setProperty("org.apache.archiva.webapp.ui.appletFindEnabled", "false");
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-configuration");
archivaConfiguration.reload();
try {
Configuration configuration = archivaConfiguration.getConfiguration();
assertFalse("check boolean", configuration.getWebapp().getUi().isAppletFindEnabled());
} finally {
System.getProperties().remove("org.apache.archiva.webapp.ui.appletFindEnabled");
archivaConfiguration.reload();
Configuration configuration = archivaConfiguration.getConfiguration();
assertTrue("check boolean", configuration.getWebapp().getUi().isAppletFindEnabled());
}
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class ArchivaConfigurationTest method testStoreConfigurationLoadedFromDefaults.
@Test
public void testStoreConfigurationLoadedFromDefaults() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.delete(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-save-user-defaults");
archivaConfiguration.reload();
Configuration configuration = new Configuration();
configuration.setWebapp(new WebappConfiguration());
configuration.getWebapp().setUi(new UserInterfaceOptions());
configuration.getWebapp().getUi().setAppletFindEnabled(false);
// add a change listener
ConfigurationListener listener = createConfigurationListenerMockControl();
archivaConfiguration.addListener(listener);
listener.configurationEvent(new ConfigurationEvent(ConfigurationEvent.SAVED));
archivaConfiguration.save(configuration);
assertTrue("Check file exists", Files.exists(userFile));
assertFalse("Check file not created", Files.exists(baseFile));
// check it
configuration = archivaConfiguration.getConfiguration();
assertFalse("check value", configuration.getWebapp().getUi().isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class MavenProxyPropertyLoaderTest method testInvalidConfiguration.
@Test(expected = InvalidConfigurationException.class)
public void testInvalidConfiguration() throws InvalidConfigurationException {
Configuration configuration = new Configuration();
loader.load(new Properties(), configuration);
// fail( "Incomplete config should have failed" );
}
use of org.apache.archiva.configuration.model.Configuration in project archiva by apache.
the class MavenProxyPropertyLoaderTest method testLoadValidMavenProxyConfiguration.
@Test
public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException {
Path confFile = ArchivaConfigurationTest.getTestFile("src/test/conf/maven-proxy-complete.conf");
Configuration configuration = new Configuration();
NetworkProxyConfiguration proxy = new NetworkProxyConfiguration();
proxy.setHost("original-host");
// overwritten
configuration.addNetworkProxy(proxy);
loader.load(Files.newInputStream(confFile), configuration);
Map<String, ManagedRepositoryConfiguration> repositoryIdMap = configuration.getManagedRepositoriesAsMap();
assertEquals("Count repositories", 1, repositoryIdMap.size());
assertRepositoryExists("maven-proxy", "target", repositoryIdMap.get("maven-proxy"));
Map<String, RemoteRepositoryConfiguration> remoteRepositoryMap = configuration.getRemoteRepositoriesAsMap();
assertEquals("Count repositories", 4, remoteRepositoryMap.size());
assertRepositoryExists("local-repo", "file://target", remoteRepositoryMap.get("local-repo"));
assertRepositoryExists("www-ibiblio-org", "http://www.ibiblio.org/maven2", remoteRepositoryMap.get("www-ibiblio-org"));
assertRepositoryExists("dist-codehaus-org", "http://dist.codehaus.org", remoteRepositoryMap.get("dist-codehaus-org"));
assertRepositoryExists("private-example-com", "http://private.example.com/internal", remoteRepositoryMap.get("private-example-com"));
}
Aggregations