Package org.apache.commons.configuration2

Examples of org.apache.commons.configuration2.PropertiesConfiguration$DefaultIOFactory


        FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
                new FileBasedConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class)
                        .configure(new FileBasedBuilderParametersImpl()
                                .setFile(file));
        PropertiesConfiguration config = builder.getConfiguration();
        builder.setAutoSave(true);
        config.setProperty(PROP, 1);
        builder.setAutoSave(false);
        config.setProperty(PROP, 2);
        builder.setAutoSave(false); // should have no effect
        checkSavedConfig(file, 1);
    }
View Full Code Here


     * Tests whether a default encoding is find even if a sub class is queried.
     */
    @Test
    public void testGetDefaultEncodingSubClass()
    {
        PropertiesConfiguration conf = new PropertiesConfiguration()
        {
        };
        assertEquals("Wrong default encodng",
                PropertiesConfiguration.DEFAULT_ENCODING,
                FileBasedConfigurationBuilder.getDefaultEncoding(conf
                        .getClass()));
    }
View Full Code Here

            throws ConfigurationException
    {
        final BasicConfigurationBuilder<PropertiesConfiguration> builder =
                new BasicConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class);
        PropertiesConfiguration configuration = builder.getConfiguration();
        BuilderEventListenerImpl listener = new BuilderEventListenerImpl();
        builder.addEventListener(ConfigurationBuilderEvent.RESET, listener);
        builder.addEventListener(
                ConfigurationBuilderEvent.CONFIGURATION_REQUEST,
                new EventListener<ConfigurationBuilderEvent>()
                {
                    @Override
                    public void onEvent(ConfigurationBuilderEvent event)
                    {
                        builder.resetResult();
                    }
                });

        PropertiesConfiguration configuration2 = builder.getConfiguration();
        assertNotSame("Configuration not reset", configuration, configuration2);
        listener.nextEvent(ConfigurationBuilderEvent.RESET);
        listener.assertNoMoreEvents();
    }
View Full Code Here

                new BasicConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class);
        BuilderEventListenerImpl listener = new BuilderEventListenerImpl();
        builder.addEventListener(ConfigurationBuilderEvent.ANY, listener);

        PropertiesConfiguration configuration = builder.getConfiguration();
        listener.nextEvent(ConfigurationBuilderEvent.CONFIGURATION_REQUEST);
        ConfigurationBuilderResultCreatedEvent event =
                listener.nextEvent(ConfigurationBuilderResultCreatedEvent.RESULT_CREATED);
        assertSame("Wrong builder", builder, event.getSource());
        assertSame("Wrong configuration", configuration,
View Full Code Here

        decl.setBeanProperties(props);
        Object bean = factory.createBean(createBcc(PropertiesConfiguration.class, decl));
        assertNotNull("New bean is null", bean);
        assertEquals("Bean is of wrong class", PropertiesConfiguration.class,
                bean.getClass());
        PropertiesConfiguration config = (PropertiesConfiguration) bean;
        assertTrue("Bean was not initialized", config
                .isThrowExceptionOnMissing());
    }
View Full Code Here

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("throwExceptionOnMissing", Boolean.TRUE);
        ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration> builder =
                new ReloadingFileBasedConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class, params);
        PropertiesConfiguration conf = builder.getConfiguration();
        assertTrue("Property not set", conf.isThrowExceptionOnMissing());
        assertTrue("Not empty", conf.isEmpty());
    }
View Full Code Here

        EasyMock.expect(detector.isReloadingRequired()).andReturn(Boolean.TRUE);
        detector.reloadingPerformed();
        EasyMock.replay(detector);
        ReloadingFileBasedConfigurationBuilderTestImpl builder =
                new ReloadingFileBasedConfigurationBuilderTestImpl(detector);
        PropertiesConfiguration config1 = builder.getConfiguration();
        builder.getReloadingController().checkForReloading(null);
        PropertiesConfiguration config2 = builder.getConfiguration();
        assertNotSame("No new configuration instance", config1, config2);
        assertFalse("Still in reloading state", builder
                .getReloadingController().isInReloadingState());
        EasyMock.verify(detector);
    }
View Full Code Here

     */
    @Test
    public void testPropertiesFromFile() throws ConfigurationException
    {
        Configurations configs = new Configurations();
        PropertiesConfiguration config =
                configs.properties(ConfigurationAssert
                        .getTestFile(TEST_PROPERTIES));
        checkProperties(config);
    }
View Full Code Here

     */
    @Test
    public void testPropertiesFromURL() throws ConfigurationException
    {
        Configurations configs = new Configurations();
        PropertiesConfiguration config =
                configs.properties(ConfigurationAssert
                        .getTestURL(TEST_PROPERTIES));
        checkProperties(config);
    }
View Full Code Here

     */
    @Test
    public void testPropertiesFromPath() throws ConfigurationException
    {
        Configurations configs = new Configurations();
        PropertiesConfiguration config =
                configs.properties(filePath(TEST_PROPERTIES));
        checkProperties(config);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.PropertiesConfiguration$DefaultIOFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.