Package org.apache.commons.configuration2

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


        BeanHelper helper = new BeanHelper(factory);
        BasicConfigurationBuilder<PropertiesConfiguration> builder =
                new BasicConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class);
        builder.configure(new BasicBuilderParameters().setBeanHelper(helper));
        PropertiesConfiguration config = builder.getConfiguration();
        assertTrue("BeanFactory was not used correctly",
                classesPassedToFactory.contains(config.getClass()));
    }
View Full Code Here


     * Tests whether a wrapper DynaBean for a Java bean can be created.
     */
    @Test
    public void testCreateWrapDynaBean()
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        DynaBean bean = BeanHelper.createWrapDynaBean(config);
        String value = "TestFooter";
        bean.set("footer", value);
        assertEquals("Property not set", value, config.getFooter());
    }
View Full Code Here

     * Tests whether properties from one bean to another can be copied.
     */
    @Test
    public void testCopyProperties() throws Exception
    {
        PropertiesConfiguration src = new PropertiesConfiguration();
        src.setHeader("TestHeader");
        src.setFooter("TestFooter");
        LazyDynaBean dest = new LazyDynaBean();
        BeanHelper.copyProperties(dest, src);
        assertEquals("Wrong footer property", "TestFooter", dest.get("footer"));
        assertEquals("Wrong header property", "TestHeader", dest.get("header"));
    }
View Full Code Here

     * Tests whether a load() operation is correctly synchronized.
     */
    @Test
    public void testLoadSynchronized() throws ConfigurationException
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        SynchronizerTestImpl sync = new SynchronizerTestImpl();
        config.setSynchronizer(sync);
        FileHandler handler = new FileHandler(config);
        handler.load(ConfigurationAssert.getTestFile("test.properties"));
        sync.verifyStart(Methods.BEGIN_WRITE);
        sync.verifyEnd(Methods.END_WRITE);
    }
View Full Code Here

     * Tests whether a save() operation is correctly synchronized.
     */
    @Test
    public void testSaveSynchronized() throws ConfigurationException, IOException
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.addProperty("test.synchronized", Boolean.TRUE);
        SynchronizerTestImpl sync = new SynchronizerTestImpl();
        config.setSynchronizer(sync);
        FileHandler handler = new FileHandler(config);
        File f = folder.newFile();
        handler.save(f);
        sync.verify(Methods.BEGIN_WRITE, Methods.END_WRITE);
    }
View Full Code Here

        assertNotNull("URL not filled", locator.getSourceURL());
        assertNotNull("Base path not filled", locator.getBasePath());
        assertEquals("Wrong file name", TEST_FILENAME, locator.getFileName());

        // check whether the correct URL was obtained
        PropertiesConfiguration config = new PropertiesConfiguration();
        FileHandler h2 = new FileHandler(config);
        h2.setURL(locator.getSourceURL());
        h2.load();
        assertTrue("Configuration not loaded",
                config.getBoolean("configuration.loaded"));
    }
View Full Code Here

        ConfigurationBuilder<? extends Configuration> builder =
                createProvider().getConfigurationBuilder(decl);
        Configuration config = builder.getConfiguration();
        assertEquals("Wrong configuration class",
                PropertiesConfiguration.class, config.getClass());
        PropertiesConfiguration pconfig = (PropertiesConfiguration) config;
        assertTrue("Wrong exception flag",
                pconfig.isThrowExceptionOnMissing());
        DefaultListDelimiterHandler listHandler =
                (DefaultListDelimiterHandler) pconfig.getListDelimiterHandler();
        assertEquals("Wrong list delimiter", ';', listHandler.getDelimiter());
        assertTrue("Configuration not loaded",
                pconfig.getBoolean("configuration.loaded"));
        return builder;
    }
View Full Code Here

        AbstractTestConfigurationEvents
{
    @Override
    protected AbstractConfiguration createConfiguration()
    {
        return new PropertiesConfiguration();
    }
View Full Code Here

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

        FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
                new FileBasedConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class)
                        .configure(new FileBasedBuilderParametersImpl()
                                .setFile(file));
        PropertiesConfiguration config = builder.getConfiguration();
        assertEquals("Not read from file", 1, config.getInt(PROP));
        assertSame("FileHandler not initialized", config, builder
                .getFileHandler().getContent());
    }
View Full Code Here

TOP

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

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.