Search in sources :

Example 31 with Configuration

use of org.apache.commons.configuration.Configuration in project java-chassis by ServiceComb.

the class CseEndpoint method invoke.

@Override
public Map<String, Object> invoke() {
    Map<String, Object> map = new LinkedHashMap<String, Object>();
    AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    if (config instanceof ConcurrentCompositeConfiguration) {
        ConcurrentCompositeConfiguration composite = (ConcurrentCompositeConfiguration) config;
        for (Configuration item : composite.getConfigurations()) {
            append(map, item);
        }
    } else {
        append(map, config);
    }
    return map;
}
Also used : AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) Configuration(org.apache.commons.configuration.Configuration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) AbstractConfiguration(org.apache.commons.configuration.AbstractConfiguration) SystemConfiguration(org.apache.commons.configuration.SystemConfiguration) EnvironmentConfiguration(org.apache.commons.configuration.EnvironmentConfiguration) ConcurrentCompositeConfiguration(com.netflix.config.ConcurrentCompositeConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 32 with Configuration

use of org.apache.commons.configuration.Configuration in project zaproxy by zaproxy.

the class PluginPassiveScannerUnitTest method shouldReadConfigurationSetEvenIfThereAreMultipleUnrelatedEntries.

@Test
public void shouldReadConfigurationSetEvenIfThereAreMultipleUnrelatedEntries() {
    // given
    Configuration configuration = createEmptyConfiguration();
    addConfiguration(configuration, 0, 10, null, null);
    addConfiguration(configuration, 1, "TestClassName", Boolean.TRUE, AlertThreshold.HIGH);
    addConfiguration(configuration, 2, TestPluginPassiveScanner.PLUGIN_ID, Boolean.FALSE, AlertThreshold.MEDIUM);
    addConfiguration(configuration, 3, 1011, null, AlertThreshold.LOW);
    addConfiguration(configuration, 4, "OtherTestClassName", Boolean.FALSE, AlertThreshold.OFF);
    scanner.setEnabled(true);
    scanner.setLevel(AlertThreshold.LOW);
    // when
    scanner.setConfig(configuration);
    // then
    assertThat(scanner.isEnabled(), is(false));
    assertThat(scanner.getLevel(), is(equalTo(AlertThreshold.MEDIUM)));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.Test)

Example 33 with Configuration

use of org.apache.commons.configuration.Configuration in project zaproxy by zaproxy.

the class PluginPassiveScannerUnitTest method shouldUseClassnameToReadConfigurationSet.

@Test
public void shouldUseClassnameToReadConfigurationSet() {
    // given
    Configuration configuration = createConfiguration(TestPluginPassiveScanner.class.getCanonicalName(), Boolean.FALSE, AlertThreshold.HIGH);
    scanner.setEnabled(true);
    scanner.setLevel(AlertThreshold.LOW);
    // when
    scanner.setConfig(configuration);
    // then
    assertThat(scanner.isEnabled(), is(false));
    assertThat(scanner.getLevel(), is(equalTo(AlertThreshold.HIGH)));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.Test)

Example 34 with Configuration

use of org.apache.commons.configuration.Configuration in project zaproxy by zaproxy.

the class PluginPassiveScannerUnitTest method shouldNotPersistLevelOnSaveIfDefaultValue.

@Test
public void shouldNotPersistLevelOnSaveIfDefaultValue() {
    // Given
    Configuration configuration = createEmptyConfiguration();
    scanner.setConfig(configuration);
    scanner.setLevel(AlertThreshold.MEDIUM);
    scanner.setEnabled(true);
    // When
    scanner.save();
    // Then
    assertThat(configuration.containsKey("pscans.pscanner(0).level"), is(false));
    assertThat(configuration.containsKey("pscans.pscanner(0).id"), is(false));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.Test)

Example 35 with Configuration

use of org.apache.commons.configuration.Configuration in project zaproxy by zaproxy.

the class PluginPassiveScannerUnitTest method shouldPersistEnabledStateOnSaveIfDisabled.

@Test
public void shouldPersistEnabledStateOnSaveIfDisabled() {
    // Given
    Configuration configuration = createEmptyConfiguration();
    scanner.setConfig(configuration);
    scanner.setEnabled(false);
    // When
    scanner.save();
    // Then
    assertThat(configuration.containsKey("pscans.pscanner(0).enabled"), is(true));
    assertThat(configuration.getBoolean("pscans.pscanner(0).enabled"), is(false));
    assertThat(configuration.containsKey("pscans.pscanner(0).id"), is(true));
    assertThat(configuration.getInt("pscans.pscanner(0).id"), is(equalTo(TestPluginPassiveScanner.PLUGIN_ID)));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.Test)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)169 Test (org.junit.Test)42 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)39 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)13 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 AtlasException (org.apache.atlas.AtlasException)9 ZkUtils (kafka.utils.ZkUtils)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 HashMap (java.util.HashMap)7 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)7 ArrayList (java.util.ArrayList)6 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 IOException (java.io.IOException)5 SimpleEntry (java.util.AbstractMap.SimpleEntry)5 ConfigurationException (org.apache.commons.configuration.ConfigurationException)5