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