use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestPropertyListConfigurationEvents method createConfiguration.
@Override
protected AbstractConfiguration createConfiguration() {
try {
final PropertyListConfiguration c = new PropertyListConfiguration();
new FileHandler(c).load(TEST_FILE);
return c;
} catch (final ConfigurationException cex) {
throw new ConfigurationRuntimeException(cex);
}
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestXMLPropertyListConfigurationEvents method createConfiguration.
@Override
protected AbstractConfiguration createConfiguration() {
try {
final XMLPropertyListConfiguration c = new XMLPropertyListConfiguration();
new FileHandler(c).load(TEST_FILE);
return c;
} catch (final ConfigurationException cex) {
throw new ConfigurationRuntimeException(cex);
}
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestAbstractConfiguration method testSetLogger.
/**
* Tests accessing the configuration's logger.
*/
@Test
public void testSetLogger() {
final AbstractConfiguration config = getEmptyConfiguration();
assertNotNull("Default logger is null", config.getLogger());
final ConfigurationLogger log = new ConfigurationLogger(config.getClass());
config.setLogger(log);
assertSame("Logger was not set", log, config.getLogger());
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestAbstractConfigurationBasicFeatures method testSetPrefixLookupsExistingInterpolator.
/**
* Tests whether prefix lookups can be added to an existing {@code ConfigurationInterpolator}.
*/
@Test
public void testSetPrefixLookupsExistingInterpolator() {
final Lookup look = EasyMock.createMock(Lookup.class);
EasyMock.replay(look);
final AbstractConfiguration config = new TestConfigurationImpl(new PropertiesConfiguration());
final int count = config.getInterpolator().getLookups().size();
final Map<String, Lookup> lookups = new HashMap<>();
lookups.put("test", look);
config.setPrefixLookups(lookups);
final Map<String, Lookup> lookups2 = config.getInterpolator().getLookups();
assertEquals("Not added", count + 1, lookups2.size());
assertSame("Not found", look, lookups2.get("test"));
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestAbstractConfigurationBasicFeatures method testSetPrefixLookupsNoInterpolator.
/**
* Tests whether prefix lookups can be added if no {@code ConfigurationInterpolator} exists yet.
*/
@Test
public void testSetPrefixLookupsNoInterpolator() {
final Lookup look = EasyMock.createMock(Lookup.class);
EasyMock.replay(look);
final AbstractConfiguration config = new TestConfigurationImpl(new PropertiesConfiguration());
config.setInterpolator(null);
config.setPrefixLookups(Collections.singletonMap("test", look));
final Map<String, Lookup> lookups = config.getInterpolator().getLookups();
assertEquals("Wrong number of lookups", 1, lookups.size());
assertSame("Not found", look, lookups.get("test"));
}
Aggregations