use of org.apache.commons.configuration2.AbstractConfiguration in project hugegraph-common by hugegraph.
the class HugeConfigTest method testHugeConfigWithOverride.
@Test
public void testHugeConfigWithOverride() throws Exception {
Configuration conf = new PropertiesConfiguration();
Assert.assertEquals(DisabledListDelimiterHandler.INSTANCE, ((AbstractConfiguration) conf).getListDelimiterHandler());
HugeConfig config = new HugeConfig(conf);
Assert.assertEquals("text1-value", config.get(TestSubOptions.text1));
Assert.assertEquals("text2-value-override", config.get(TestSubOptions.text2));
Assert.assertEquals("textsub-value", config.get(TestSubOptions.textsub));
}
use of org.apache.commons.configuration2.AbstractConfiguration in project invesdwin-context by invesdwin.
the class FileProperties method createDelegate.
@Override
protected AbstractConfiguration createDelegate() {
final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class);
builder.setAutoSave(true);
try {
if (!file.exists()) {
Files.touch(file);
}
final PropertiesConfiguration conf = builder.configure(new Parameters().fileBased().setFile(file)).getConfiguration();
return conf;
} catch (final ConfigurationException | IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.commons.configuration2.AbstractConfiguration in project invesdwin-context by invesdwin.
the class SystemProperties method createDelegate.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected AbstractConfiguration createDelegate() {
// CHECKSTYLE:OFF Properties
final MapConfiguration delegate = new MapConfiguration((Map) System.getProperties());
// CHECKSTYLE:ON
delegate.setThrowExceptionOnMissing(true);
return delegate;
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestConfigurationLogger method testAbstractConfigurationSetLoggerNull.
/**
* Tests that the logger can be disabled by setting it to null.
*/
@Test
public void testAbstractConfigurationSetLoggerNull() {
final AbstractConfiguration config = new BaseConfiguration();
config.setLogger(new ConfigurationLogger(getClass()));
config.setLogger(null);
assertThat("Logger not disabled", config.getLogger().getLog(), instanceOf(NoOpLog.class));
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestAppletConfiguration method getConfiguration.
@Override
protected AbstractConfiguration getConfiguration() {
final AbstractConfiguration config;
final Properties parameters = new Properties();
parameters.setProperty("key1", "value1");
parameters.setProperty("key2", "value2");
parameters.setProperty("list", "value1, value2");
parameters.setProperty("listesc", "value1\\,value2");
if (supportsApplet) {
final Applet applet = new Applet() {
/**
* Serial version UID.
*/
private static final long serialVersionUID = 1L;
@Override
public String getParameter(final String key) {
return parameters.getProperty(key);
}
@Override
public String[][] getParameterInfo() {
return new String[][] { { "key1", "String", "" }, { "key2", "String", "" }, { "list", "String[]", "" }, { "listesc", "String", "" } };
}
};
config = new AppletConfiguration(applet);
} else {
config = new MapConfiguration(parameters);
}
config.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
return config;
}
Aggregations