use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestServletConfiguration method getConfiguration.
@Override
protected AbstractConfiguration getConfiguration() {
final MockServletConfig config = new MockServletConfig();
config.setInitParameter("key1", "value1");
config.setInitParameter("key2", "value2");
config.setInitParameter("list", "value1, value2");
config.setInitParameter("listesc", "value1\\,value2");
final Servlet servlet = new HttpServlet() {
/**
* Serial version UID.
*/
private static final long serialVersionUID = 1L;
@Override
public ServletConfig getServletConfig() {
return config;
}
};
final ServletConfiguration servletConfiguration = new ServletConfiguration(servlet);
servletConfiguration.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
return servletConfiguration;
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestServletFilterConfiguration method getConfiguration.
@Override
protected AbstractConfiguration getConfiguration() {
final MockFilterConfig config = new MockFilterConfig();
config.setInitParameter("key1", "value1");
config.setInitParameter("key2", "value2");
config.setInitParameter("list", "value1, value2");
config.setInitParameter("listesc", "value1\\,value2");
final ServletFilterConfiguration resultConfig = new ServletFilterConfiguration(config);
resultConfig.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
return resultConfig;
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestSubsetConfiguration method testLocalLookupsInInterpolatorAreInherited.
@Test
public void testLocalLookupsInInterpolatorAreInherited() {
final BaseConfiguration config = new BaseConfiguration();
final ConfigurationInterpolator interpolator = config.getInterpolator();
interpolator.registerLookup("brackets", key -> "(" + key + ")");
config.setProperty("prefix.var", "${brackets:x}");
final AbstractConfiguration subset = (AbstractConfiguration) config.subset("prefix");
assertEquals("Local lookup was not inherited", "(x)", subset.getString("var", ""));
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestSubsetConfiguration method testSetListDelimiterHandlerInParent.
/**
* Tests whether the list delimiter handler is also set for the parent configuration.
*/
@Test
public void testSetListDelimiterHandlerInParent() {
final BaseConfiguration config = new BaseConfiguration();
final AbstractConfiguration subset = (AbstractConfiguration) config.subset("prefix");
final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
subset.setListDelimiterHandler(listHandler);
assertSame("Handler not passed to parent", listHandler, config.getListDelimiterHandler());
}
use of org.apache.commons.configuration2.AbstractConfiguration in project commons-configuration by apache.
the class TestSubsetConfiguration method testSetListDelimiterHandlerParentNotSupported.
/**
* Tests the case that the parent configuration is not derived from AbstractConfiguration and thus does not support a
* list delimiter handler.
*/
@Test
public void testSetListDelimiterHandlerParentNotSupported() {
final Configuration config = EasyMock.createNiceMock(Configuration.class);
EasyMock.replay(config);
final SubsetConfiguration subset = new SubsetConfiguration(config, "prefix");
final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
subset.setListDelimiterHandler(listHandler);
assertSame("List delimiter handler not set", listHandler, subset.getListDelimiterHandler());
}
Aggregations