Package org.apache.commons.configuration2.io

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


        assertSame("Wrong event listener for original", conf.getLayout(), conf
                .getEventListeners(ConfigurationEvent.ANY).iterator().next());
        assertSame("Wrong event listener for clone", copy.getLayout(), copy
                .getEventListeners(ConfigurationEvent.ANY).iterator().next());
        StringWriter outConf = new StringWriter();
        new FileHandler(conf).save(outConf);
        StringWriter outCopy = new StringWriter();
        new FileHandler(copy).save(outCopy);
        assertEquals("Output from copy is different", outConf.toString(), outCopy.toString());
    }
View Full Code Here


    public void testSaveToHTTPServerSuccess() throws Exception
    {
        MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
                HttpURLConnection.HTTP_OK, testSavePropertiesFile);
        URL url = new URL(null, "http://jakarta.apache.org", handler);
        new FileHandler(conf).save(url);
        MockHttpURLConnection con = handler.getMockConnection();
        assertTrue("Wrong output flag", con.getDoOutput());
        assertEquals("Wrong method", "PUT", con.getRequestMethod());
        checkSavedConfig();
    }
View Full Code Here

        MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
                HttpURLConnection.HTTP_BAD_REQUEST, testSavePropertiesFile);
        URL url = new URL(null, "http://jakarta.apache.org", handler);
        try
        {
            new FileHandler(conf).save(url);
            fail("Response code was not checked!");
        }
        catch (ConfigurationException cex)
        {
            assertTrue("Wrong root cause: " + cex,
View Full Code Here

    {
        File file = new File("target/sharp#1.properties");
        file.createNewFile();

        PropertiesConfiguration conf = new PropertiesConfiguration();
        FileHandler handler = new FileHandler(conf);
        handler.setFile(file);
        handler.load();
        handler.save();

        assertTrue("Missing file " + file, file.exists());
    }
View Full Code Here

    @Test
    public void testInitFromNonExistingFile() throws ConfigurationException
    {
        final String testProperty = "test.successfull";
        conf = new PropertiesConfiguration();
        FileHandler handler = new FileHandler(conf);
        handler.setFile(testSavePropertiesFile);
        conf.addProperty(testProperty, "true");
        handler.save();
        checkSavedConfig();
    }
View Full Code Here

     */
    @Test
    public void testSaveWithDataConfig() throws ConfigurationException
    {
        conf = new PropertiesConfiguration();
        FileHandler handler = new FileHandler(conf);
        handler.setFile(testSavePropertiesFile);
        DataConfiguration dataConfig = new DataConfiguration(conf);
        dataConfig.setProperty("foo", "bar");
        assertEquals("Property not set", "bar", conf.getString("foo"));

        handler.save();
        PropertiesConfiguration config2 = new PropertiesConfiguration();
        load(config2, testSavePropertiesFile.getAbsolutePath());
        assertEquals("Property not saved", "bar", config2.getString("foo"));
    }
View Full Code Here

                {
                    return null;
                }
            }
        });
        new FileHandler(conf).save(new StringWriter());
        propertiesWriter.getValue().close();
        checkSavedConfig();
    }
View Full Code Here

    @Test
    public void testSlashEscaping() throws ConfigurationException
    {
        conf.setProperty(PROP_NAME, "http://www.apache.org");
        StringWriter writer = new StringWriter();
        new FileHandler(conf).save(writer);
        String s = writer.toString();
        assertTrue("Value not found: " + s, s.contains(PROP_NAME
                + " = http://www.apache.org"));
    }
View Full Code Here

    {
        conf.clear();
        String text = "\"Hello World!\"";
        conf.setProperty(PROP_NAME, text);
        StringWriter out = new StringWriter();
        new FileHandler(conf).save(out);
        assertTrue("Value was escaped: " + out,
                out.toString().contains(text));
        saveTestConfig();
        PropertiesConfiguration c2 = new PropertiesConfiguration();
        load(c2, testSavePropertiesFile.getAbsolutePath());
View Full Code Here

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

TOP

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

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.