use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestSubsetConfiguration method testListDelimiterHandling.
/**
* Tests whether a list delimiter handler is used correctly.
*/
@Test
public void testListDelimiterHandling() {
final BaseConfiguration config = new BaseConfiguration();
final Configuration subset = config.subset("prefix");
config.setListDelimiterHandler(new DefaultListDelimiterHandler('/'));
subset.addProperty("list", "a/b/c");
assertEquals("Wrong size of list", 3, config.getList("prefix.list").size());
((AbstractConfiguration) subset).setListDelimiterHandler(new DefaultListDelimiterHandler(';'));
subset.addProperty("list2", "a;b;c");
assertEquals("Wrong size of list2", 3, config.getList("prefix.list2").size());
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestSubsetConfiguration method testGetListDelimiterHandlerFromParent.
/**
* Tests whether the list delimiter handler from the parent configuration is used.
*/
@Test
public void testGetListDelimiterHandlerFromParent() {
final BaseConfiguration config = new BaseConfiguration();
final AbstractConfiguration subset = (AbstractConfiguration) config.subset("prefix");
final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
config.setListDelimiterHandler(listHandler);
assertSame("Not list handler from parent", listHandler, subset.getListDelimiterHandler());
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestMapConfiguration method getConfiguration.
@Override
protected AbstractConfiguration getConfiguration() {
final Map<String, Object> map = new HashMap<>();
map.put(KEY, "value1");
map.put("key2", "value2");
map.put("list", "value1, value2");
map.put("listesc", "value1\\,value2");
final MapConfiguration config = new MapConfiguration(map);
config.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
return config;
}
Aggregations