use of org.apache.commons.configuration.Configuration in project chassis by Kixeye.
the class ConfigurationBuilderTest method fetchFromArchaius.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void fetchFromArchaius() {
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES, filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"), new SimpleEntry(MODULE_1_KEY_3, MODULE_1_VALUE_3 + "-override"));
TestUtils.writePropertiesToFile(TEST_APP_CONFIG_PROPERTIES.replace(".properties", "." + ENVIRONMENT + ".properties"), filesCreated, new SimpleEntry(MODULE_1_KEY_2, MODULE_1_VALUE_2 + "-override"));
configurationBuilder.withApplicationProperties(TEST_APP_CONFIG_PROPERTIES_SPRING_PATH);
Configuration configuration = configurationBuilder.build();
Assert.assertEquals(MODULE_1_VALUE_1, configuration.getString(MODULE_1_KEY_1));
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", configuration.getString(MODULE_1_KEY_2));
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", configuration.getString(MODULE_1_KEY_3));
Assert.assertEquals(MODULE_1_VALUE_1, DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_1, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_2 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_2, null).getValue());
Assert.assertEquals(MODULE_1_VALUE_3 + "-override", DynamicPropertyFactory.getInstance().getStringProperty(MODULE_1_KEY_3, null).getValue());
}
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