Package org.apache.commons.configuration.reloading

Examples of org.apache.commons.configuration.reloading.FileAlwaysReloadingStrategy


            out = new PrintWriter(new FileWriter(testSaveConf));
            out.println("<?xml version=\"1.0\"?><config><test>1</test></config>");
            out.close();
            out = null;
            conf.setFile(testSaveConf);
            FileAlwaysReloadingStrategy strategy = new FileAlwaysReloadingStrategy();
            strategy.setRefreshDelay(100);
            conf.setReloadingStrategy(strategy);
            assertEquals(strategy, conf.getReloadingStrategy());
            assertEquals("Wrong file monitored", testSaveConf.getAbsolutePath(),
                    strategy.getMonitoredFile().getAbsolutePath());
            conf.load();
            assertEquals(1, conf.getInt("test"));

            out = new PrintWriter(new FileWriter(testSaveConf));
            out.println("<?xml version=\"1.0\"?><config><test>2</test></config>");
View Full Code Here


     */
    public void testAutoSaveWithReloadingStrategy() throws ConfigurationException
    {
        conf.setFile(testSaveConf);
        conf.save();
        conf.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        conf.setAutoSave(true);
        assertEquals("Value not found", "value", conf.getProperty("element"));
    }
View Full Code Here

    private XMLConfiguration setUpReloadTest() throws ConfigurationException
    {
        removeTestFile();
        conf.save(testSaveConf);
        XMLConfiguration c = new XMLConfiguration(testSaveConf);
        c.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        conf.setProperty("test(0).entity", "newValue");
        conf.save(testSaveConf);
        return c;
    }
View Full Code Here

        try
        {
            writeTestConfig(testFile, propFirst, "John");
            PropertiesConfiguration c1 = new PropertiesConfiguration(testFile);
            c1.setReloadingStrategy(new FileAlwaysReloadingStrategy());
            PropertiesConfiguration c2 = new PropertiesConfiguration();
            c2.addProperty(propFull, "${" + propFirst + "} Doe");
            CompositeConfiguration cc = new CompositeConfiguration();
            cc.addConfiguration(c1);
            cc.addConfiguration(c2);
View Full Code Here

        File testXmlFile = new File(testDir, "reload.xml");
        File testPropsFile = new File(testDir, "reload.properties");
        writeFile(testXmlFile, "<xml><xmlReload>0</xmlReload></xml>");
        writeFile(testPropsFile, "propsReload = 0");
        XMLConfiguration c1 = new XMLConfiguration(testXmlFile);
        c1.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        PropertiesConfiguration c2 = new PropertiesConfiguration(testPropsFile);
        c2.setThrowExceptionOnMissing(true);
        c2.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        config.addConfiguration(c1);
        config.addConfiguration(c2);
        assertEquals("Wrong xml reload value", 0, config.getInt("xmlReload"));
        assertEquals("Wrong props reload value", 0, config
                .getInt("propsReload"));
View Full Code Here

        File testXmlFile = new File(testDir, "reload.xml");
        File testPropsFile = new File(testDir, "reload.properties");
        writeFile(testXmlFile, "<xml><xmlReload>0</xmlReload></xml>");
        writeFile(testPropsFile, "propsReload = 0");
        XMLConfiguration c1 = new XMLConfiguration(testXmlFile);
        c1.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        PropertiesConfiguration c2 = new PropertiesConfiguration(testPropsFile);
        c2.setThrowExceptionOnMissing(true);
        c2.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        config.addConfiguration(c1);
        config.addConfiguration(c2);
        assertEquals("Wrong xml reload value", 0, config.getInt("xmlReload"));
        assertEquals("Wrong props reload value", 0, config
                .getInt("propsReload"));
View Full Code Here

        try
        {
            writeTestConfig(testFile, propFirst, "John");
            PropertiesConfiguration c1 = new PropertiesConfiguration(testFile);
            c1.setReloadingStrategy(new FileAlwaysReloadingStrategy());
            PropertiesConfiguration c2 = new PropertiesConfiguration();
            c2.addProperty(propFull, "${" + propFirst + "} Doe");
            CompositeConfiguration cc = new CompositeConfiguration();
            cc.addConfiguration(c1);
            cc.addConfiguration(c2);
View Full Code Here

            out = new PrintWriter(new FileWriter(testSaveConf));
            out.println("<?xml version=\"1.0\"?><config><test>1</test></config>");
            out.close();
            out = null;
            conf.setFile(testSaveConf);
            FileAlwaysReloadingStrategy strategy = new FileAlwaysReloadingStrategy();
            strategy.setRefreshDelay(100);
            conf.setReloadingStrategy(strategy);
            assertEquals(strategy, conf.getReloadingStrategy());
            assertEquals("Wrong file monitored", testSaveConf.getAbsolutePath(),
                    strategy.getMonitoredFile().getAbsolutePath());
            conf.load();
            assertEquals(1, conf.getInt("test"));

            out = new PrintWriter(new FileWriter(testSaveConf));
            out.println("<?xml version=\"1.0\"?><config><test>2</test></config>");
View Full Code Here

        TestConfigurationErrorListener l = new TestConfigurationErrorListener();
        PropertiesConfiguration config = new PropertiesConfiguration(
                RESOURCE_NAME);
        config.clearErrorListeners();
        config.addErrorListener(l);
        config.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        config.getString("test");
        config.setFileName("Not existing file");
        config.getString("test");
        assertEquals("Wrong number of error events", 1, l.errorCount);
        assertEquals("Wrong error type",
View Full Code Here

    {
        config.setForceReloadCheck(true);
        File testXmlFile = writeReloadFile(RELOAD_XML_NAME, RELOAD_XML_CONTENT, 0);
        File testPropsFile = writeReloadFile(RELOAD_PROPS_NAME, RELOAD_PROPS_CONTENT, 0);
        XMLConfiguration c1 = new XMLConfiguration(testXmlFile);
        c1.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        PropertiesConfiguration c2 = new PropertiesConfiguration(testPropsFile);
        c2.setThrowExceptionOnMissing(true);
        c2.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        config.addConfiguration(c1);
        config.addConfiguration(c2);
        assertEquals("Wrong xml reload value", 0, config.getInt("xmlReload"));
        assertEquals("Wrong props reload value", 0, config
                .getInt("propsReload"));
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.reloading.FileAlwaysReloadingStrategy

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.