Package org.apache.commons.configuration2.io

Examples of org.apache.commons.configuration2.io.FileHandler


            throws ConfigurationException
    {
        FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
                new FileBasedConfigurationBuilder<PropertiesConfiguration>(
                        PropertiesConfiguration.class);
        FileHandler handler = new FileHandler();
        String encoding = "testEncoding";
        handler.setEncoding(encoding);
        builder.initFileHandler(handler);
        assertEquals("Encoding was changed", encoding, handler.getEncoding());
    }
View Full Code Here


     */
    @Override
    protected void initResultInstance(T obj) throws ConfigurationException
    {
        super.initResultInstance(obj);
        FileHandler srcHandler =
                (currentFileHandler != null && !resetParameters) ? currentFileHandler
                        : fetchFileHandlerFromParameters();
        currentFileHandler = new FileHandler(obj, srcHandler);

        if (autoSaveListener != null)
        {
            autoSaveListener.updateFileHandler(currentFileHandler);
        }
View Full Code Here

                new BuilderConfigurationWrapperFactory();
        config.addConfiguration(wrapFactory.createBuilderConfigurationWrapper(
                HierarchicalConfiguration.class, multiBuilder), "Multi");
        XMLConfiguration xml = new XMLConfiguration();
        xml.setExpressionEngine(engine);
        FileHandler handler = new FileHandler(xml);
        handler.setFile(new File(DEFAULT_FILE));
        handler.load();
        config.addConfiguration(xml, "Default");

        verify("1001", config, 15);
        verify("1002", config, 25);
        verify("1003", config, 35);
View Full Code Here

    @Before
    public void setUp() throws Exception
    {
        conf = new XMLConfiguration();
        new FileHandler(conf).load(CONFIG_FILE);
    }
View Full Code Here

    public void testReadNotFileBased() throws ConfigurationException
    {
        HierarchicalConfiguration<ImmutableNode> hc = new BaseHierarchicalConfiguration();
        PatternSubtreeConfigurationWrapper config =
                new PatternSubtreeConfigurationWrapper(hc, PATTERN);
        new FileHandler(config).load(CONFIG_FILE);
    }
View Full Code Here

    public void testSaveNotFileBased() throws ConfigurationException
    {
        HierarchicalConfiguration<ImmutableNode> hc = new BaseHierarchicalConfiguration();
        PatternSubtreeConfigurationWrapper config =
                new PatternSubtreeConfigurationWrapper(hc, PATTERN);
        new FileHandler(config).save(new StringWriter());
    }
View Full Code Here

    @Before
    public void setUp() throws Exception
    {
        PropertiesConfiguration c = new PropertiesConfiguration();
        c.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
        FileHandler handler = new FileHandler(c);
        handler.setFileName("threesome.properties");
        handler.load();
        conf = c;
    }
View Full Code Here

     * @throws ConfigurationException if an error occurs
     */
    private static FileHandler load(PropertiesConfiguration pc, String fileName)
            throws ConfigurationException
    {
        FileHandler handler = new FileHandler(pc);
        handler.setFileName(fileName);
        handler.load();
        return handler;
    }
View Full Code Here

     */
    @Test
    public void testAppend() throws Exception
    {
        File file2 = ConfigurationAssert.getTestFile("threesome.properties");
        FileHandler handler = new FileHandler(conf);
        handler.load(file2);
        assertEquals("aaa", conf.getString("test.threesome.one"));
        assertEquals("true", conf.getString("configuration.loaded"));
    }
View Full Code Here

    {
        StringReader in =
                new StringReader(PropertiesConfiguration.getInclude() + " = "
                        + ConfigurationAssert.getTestURL("include.properties"));
        conf = new PropertiesConfiguration();
        FileHandler handler = new FileHandler(conf);
        handler.load(in);
        assertEquals("Include file not loaded", "true",
                conf.getString("include.loaded"));
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.io.FileHandler

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.