Package org.apache.commons.configuration2.io

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


        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 testGetProperty() throws Exception
    {
        FileHandler handler = new FileHandler(config);
        handler.setFileName(TEST_FILE);
        handler.load();

        configTest(config);
    }

    @Test
View Full Code Here

    @Test
    public void testLoadURL() throws Exception
    {
        FileHandler handler = new FileHandler(config);
        handler.load(new File(TEST_FILE).getAbsoluteFile().toURI().toURL());
        configTest(config);
    }

    @Test
    public void testLoadBasePath1() throws Exception
View Full Code Here

    public void testLoadBasePath1() throws Exception
    {
        FileHandler handler = new FileHandler(config);
        handler.setBasePath(TEST_DIR);
        handler.setFileName(TEST_FILENAME);
        handler.load();
        configTest(config);
    }

    @Test
    public void testLoadBasePath2() throws Exception
View Full Code Here

    public void testLoadBasePath2() throws Exception
    {
        FileHandler handler = new FileHandler(config);
        handler.setBasePath(new File(TEST_FILE).getAbsoluteFile().toURI().toURL().toString());
        handler.setFileName(TEST_FILENAME);
        handler.load();
        configTest(config);
    }

    /**
     * Ensure various node types are correctly processed in config.
View Full Code Here

        // Number of keys expected from test configuration file
        final int KEY_COUNT = 5;

        // Load the configuration file
        FileHandler handler = new FileHandler(config);
        handler.load(new File(TEST_FILE2).getAbsoluteFile().toURI().toURL());

        // Validate comment in element ignored
        assertEquals("Comment in element must not change element value.", "Case1Text", config
                .getString("case1"));
View Full Code Here

    @Test
    public void testSave() throws Exception
    {
        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);
View Full Code Here

        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"));
        assertEquals("I'm complex!", config.getProperty("element2.subelement.subsubelement"));
        assertEquals(8, config.getInt("test.short"));
        assertEquals("one", config.getString("list(0).item(0)[@name]"));
        assertEquals("two", config.getString("list(0).item(1)"));
View Full Code Here

    private static void load(XMLConfiguration config, String fileName)
            throws ConfigurationException
    {
        FileHandler handler = new FileHandler(config);
        handler.setFileName(fileName);
        handler.load();
    }

    /**
     * Creates a new XMLConfiguration and loads the specified file.
     *
 
View Full Code Here

    public void testLoadFromStream() throws Exception
    {
        String xml = "<?xml version=\"1.0\"?><config><test>1</test></config>";
        conf = new XMLConfiguration();
        FileHandler handler = new FileHandler(conf);
        handler.load(new ByteArrayInputStream(xml.getBytes()));
        assertEquals(1, conf.getInt("test"));

        conf = new XMLConfiguration();
        handler = new FileHandler(conf);
        handler.load(new ByteArrayInputStream(xml.getBytes()), "UTF8");
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.