Package org.apache.commons.configuration2.io

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


     * @param file the target file
     * @throws ConfigurationException if an error occurs
     */
    private void save(File file) throws ConfigurationException
    {
        new FileHandler(config).save(file);
    }
View Full Code Here


     */
    @Test
    public void testSaveNoEncoding() throws ConfigurationException
    {
        StringWriter writer = new StringWriter();
        new FileHandler(config).save(writer);
        assertTrue("Wrong document header",
                writer.toString().indexOf("<?xml version=\"1.0\"?>") >= 0);
    }
View Full Code Here

     */
    @Test
    public void testSaveWithEncoding() throws ConfigurationException
    {
        String encoding = "UTF-8";
        FileHandler handler = new FileHandler(config);
        handler.setEncoding(encoding);
        StringWriter writer = new StringWriter();
        handler.save(writer);
        assertTrue(
                "Encoding not found",
                writer.toString()
                        .indexOf(
                                "<?xml version=\"1.0\" encoding=\"" + encoding
View Full Code Here

     * @throws ConfigurationException if an error occurs
     */
    private static void load(PropertyListConfiguration c, File f)
            throws ConfigurationException
    {
        new FileHandler(c).load(f);
    }
View Full Code Here

    @Test
    public void testLoadWithError()
    {
        config = new PropertyListConfiguration();
        try {
            new FileHandler(config).load(new StringReader(""));
            fail("No exception thrown on loading an empty file");
        } catch (ConfigurationException e) {
            // expected
            assertNotNull(e.getMessage());
        }
View Full Code Here

     * @param file the target file
     * @throws ConfigurationException if an error occurs
     */
    private void saveConfig(File file) throws ConfigurationException
    {
        new FileHandler(config).save(file);
    }
View Full Code Here

    protected AbstractConfiguration createConfiguration()
    {
        try
        {
            XMLPropertyListConfiguration c = new XMLPropertyListConfiguration();
            new FileHandler(c).load(TEST_FILE);
            return c;
        }
        catch (ConfigurationException cex)
        {
            throw new ConfigurationRuntimeException(cex);
View Full Code Here

    protected AbstractConfiguration createConfiguration()
    {
        try
        {
            PropertyListConfiguration c = new PropertyListConfiguration();
            new FileHandler(c).load(TEST_FILE);
            return c;
        }
        catch (ConfigurationException cex)
        {
            throw new ConfigurationRuntimeException(cex);
View Full Code Here

    {
        cc = new CompositeConfiguration();
        ListDelimiterHandler listHandler = new LegacyListDelimiterHandler(',');
        conf1 = new PropertiesConfiguration();
        conf1.setListDelimiterHandler(listHandler);
        FileHandler handler1 = new FileHandler(conf1);
        handler1.setFileName(testProperties);
        handler1.load();
        conf2 = new PropertiesConfiguration();
        conf2.setListDelimiterHandler(listHandler);
        FileHandler handler2 = new FileHandler(conf2);
        handler2.setFileName(testProperties2);
        handler2.load();
        xmlConf = new XMLConfiguration();
        FileHandler handler3 = new FileHandler(xmlConf);
        handler3.load(new File(testPropertiesXML));

        cc.setThrowExceptionOnMissing(true);
    }
View Full Code Here

    @Before
    public void setUp() throws Exception
    {
        XMLConfiguration config = new XMLConfiguration();
        FileHandler handler = new FileHandler(config);
        handler.load(TEST_FILE);
        parser = new HierarchicalConfigurationXMLReader<ImmutableNode>(config);
    }
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.