Java Code Examples for org.apache.commons.configuration2.PropertiesConfiguration#IOFactory
The following examples show how to use
org.apache.commons.configuration2.PropertiesConfiguration#IOFactory .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether properties can be set using BeanUtils. */ @Test public void testBeanPropertiesAccess() throws Exception { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); EasyMock.replay(factory); BeanHelper.setProperty(params, "IOFactory", factory); BeanHelper.setProperty(params, "throwExceptionOnMissing", Boolean.TRUE); BeanHelper.setProperty(params, "fileName", "test.properties"); assertEquals("Wrong file name", "test.properties", params .getFileHandler().getFileName()); final Map<String, Object> paramsMap = params.getParameters(); assertEquals("Wrong exception flag", Boolean.TRUE, paramsMap.get("throwExceptionOnMissing")); assertSame("Factory not set", factory, params.getParameters().get("IOFactory")); }
Example 2
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 6 votes |
/** * Tests whether properties can be inherited. */ @Test public void testInheritFrom() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); final ConfigurationConsumer<ConfigurationException> includeListener = EasyMock.createMock(ConfigurationConsumer.class); params.setIOFactory(factory) .setIncludeListener(includeListener) .setIncludesAllowed(false) .setLayout(new PropertiesConfigurationLayout()) .setThrowExceptionOnMissing(true); final PropertiesBuilderParametersImpl params2 = new PropertiesBuilderParametersImpl(); params2.inheritFrom(params.getParameters()); final Map<String, Object> parameters = params2.getParameters(); assertEquals("Exception flag not set", Boolean.TRUE, parameters.get("throwExceptionOnMissing")); assertEquals("IncludeListener not set", includeListener, parameters.get("includeListener")); assertEquals("IOFactory not set", factory, parameters.get("IOFactory")); assertEquals("Include flag not set", Boolean.FALSE, parameters.get("includesAllowed")); assertNull("Layout was copied", parameters.get("layout")); }
Example 3
Source File: TestParameters.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether a parameters object for a properties configuration can be * created. */ @Test public void testProperties() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); final ConfigurationConsumer<ConfigurationException> includeListener = EasyMock.createMock(ConfigurationConsumer.class); // @formatter:off final Map<String, Object> map = new Parameters().properties() .setThrowExceptionOnMissing(true) .setFileName("test.properties") .setIncludeListener(includeListener) .setIOFactory(factory) .setListDelimiterHandler(listHandler) .setIncludesAllowed(false) .getParameters(); // @formatter:on checkBasicProperties(map); final FileBasedBuilderParametersImpl fbp = FileBasedBuilderParametersImpl.fromParameters(map); assertEquals("Wrong file name", "test.properties", fbp.getFileHandler() .getFileName()); assertEquals("Wrong includes flag", Boolean.FALSE, map.get("includesAllowed")); assertSame("Wrong include listener", includeListener, map.get("includeListener")); assertSame("Wrong factory", factory, map.get("IOFactory")); }
Example 4
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether the IO factory can be set. */ @Test public void testSetIOFactory() { final PropertiesConfiguration.IOFactory factory = EasyMock.createMock(PropertiesConfiguration.IOFactory.class); EasyMock.replay(factory); assertSame("Wrong result", params, params.setIOFactory(factory)); assertSame("Factory not set", factory, params.getParameters().get("IOFactory")); }
Example 5
Source File: TestPropertiesBuilderParametersImpl.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether the IOFactory property can be correctly set. This test is * related to CONFIGURATION-648. */ @Test public void testSetIOFactoryProperty() throws ConfigurationException { final PropertiesConfiguration.IOFactory factory = new PropertiesConfiguration.DefaultIOFactory(); final ConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class) .configure(params.setIOFactory(factory)); final PropertiesConfiguration config = builder.getConfiguration(); assertEquals("Wrong IO factory", factory, config.getIOFactory()); }