Search in sources :

Example 41 with Configuration

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"));
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) Test(org.junit.Test)

Example 42 with Configuration

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());
    }
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) Test(org.junit.Test)

Example 43 with Configuration

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());
}
Also used : Path(java.nio.file.Path) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) Test(org.junit.Test)

Example 44 with Configuration

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" );
}
Also used : RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) Properties(java.util.Properties) Test(org.junit.Test)

Example 45 with Configuration

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"));
}
Also used : Path(java.nio.file.Path) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) Test(org.junit.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