Package org.apache.commons.configuration2.io

Examples of org.apache.commons.configuration2.io.FileHandler.save()


    {
        FileHandler handler = new FileHandler(config);
        handler.setFileName(TEST_FILE3);
        handler.load();
        File saveFile = folder.newFile(TEST_SAVENAME);
        handler.save(saveFile);

        config = new XMLConfiguration();
        FileHandler handler2 = new FileHandler(config);
        handler2.load(saveFile.toURI().toURL());
        assertEquals("value", config.getProperty("element"));
View Full Code Here


        config.setRootElementName("myconfig");
        File saveFile = folder.newFile(TEST_SAVENAME);
        FileHandler handler = new FileHandler(config);
        handler.setFile(saveFile);
        handler.save();

        config = new XMLConfiguration();
        handler = new FileHandler(config);
        handler.load(saveFile);
        assertEquals(1, config.getMaxIndex("tables.table.name"));
View Full Code Here

     */
    @Test
    public void testSaveToURL() throws Exception
    {
        FileHandler handler = new FileHandler(conf);
        handler.save(testSaveConf.toURI().toURL());
        checkSavedConfig(testSaveConf);
    }

    /**
     * Tests saving to a stream.
View Full Code Here

        FileOutputStream out = null;
        FileHandler handler = new FileHandler(conf);
        try
        {
            out = new FileOutputStream(testSaveConf);
            handler.save(out, "UTF8");
        }
        finally
        {
            if(out != null)
            {
View Full Code Here

        handler.setEncoding("UTF8");
        FileOutputStream out = null;
        try
        {
            out = new FileOutputStream(testSaveConf);
            handler.save(out);
        }
        finally
        {
            if(out != null)
            {
View Full Code Here

        conf.setProperty("test", "a value");
        FileHandler handler = new FileHandler(conf);
        handler.setEncoding(ENCODING);

        StringWriter out = new StringWriter();
        handler.save(out);
        assertThat("Encoding was not written to file", out.toString(),
                containsString("encoding=\"" + ENCODING + "\""));
    }

    /**
 
View Full Code Here

        conf = new XMLConfiguration();
        conf.setProperty("testNoEncoding", "yes");
        FileHandler handler = new FileHandler(conf);

        StringWriter out = new StringWriter();
        handler.save(out);
        assertThat("Encoding was written to file", out.toString(),
                containsString("encoding=\"UTF-"));
    }

    /**
 
View Full Code Here

     * @throws ConfigurationException if an error occurs
     */
    private void saveTestConfig() throws ConfigurationException
    {
        FileHandler handler = new FileHandler(conf);
        handler.save(testSaveConf);
    }

    /**
     * Tests whether the saved configuration file matches the original data.
     *
 
View Full Code Here

        XMLConfiguration reloadConfig = new XMLConfiguration();
        FileHandler handler = new FileHandler(reloadConfig);
        handler.setFile(outFile);
        final String key = "test.reload";
        reloadConfig.setProperty(key, "no");
        handler.save();
        try
        {
            assertEquals("Wrong property", "no", config.getString(key));
            ConfigurationBuilder<? extends Configuration> childBuilder =
                    builder.getNamedBuilder("clientConfig");
View Full Code Here

                            .getReloadingController();
            ctrl.checkForReloading(null); // initialize reloading
            BuilderEventListenerImpl l = new BuilderEventListenerImpl();
            childBuilder.addEventListener(ConfigurationBuilderEvent.RESET, l);
            reloadConfig.setProperty(key, "yes");
            handler.save();

            int attempts = 10;
            boolean changeDetected;
            do
            {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.