Package org.apache.commons.configuration.reloading

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


        xmlConf.setFile(TEST_FILE);
        xmlConf.save();
        config = xmlConf.configurationAt("tables.table(1)", supportReload);
        assertEquals("Wrong table name", TABLE_NAMES[1], config
                .getString("name"));
        xmlConf.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        // Now change the configuration file
        XMLConfiguration confUpdate = new XMLConfiguration(TEST_FILE);
        confUpdate.setProperty("tables.table(1).name", NEW_TABLE_NAME);
        confUpdate.setProperty("tables.table(1).fields.field(0).name",
                "newField");
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

            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);
            conf.load();
            assertEquals(1, conf.getInt("test"));

            for (int i = 1; i < LOOP_COUNT; ++i)
View Full Code Here

    @Test
    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

    @Test
    public void testConcurrentGetAndReload() throws Exception
    {
        //final FileConfiguration config = new PropertiesConfiguration("test.properties");
        final FileConfiguration config = new XMLConfiguration("test.xml");
        config.setReloadingStrategy(new FileAlwaysReloadingStrategy());

        assertTrue("Property not found", config.getProperty("test.short") != null);

        Thread testThreads[] = new Thread[THREAD_COUNT];
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

        ConfigurationErrorListenerImpl l = new ConfigurationErrorListenerImpl();
        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");
        l.verify(AbstractFileConfiguration.EVENT_RELOAD, null, null);
        assertNotNull("Exception is not set", l.getLastEvent().getCause());
View Full Code Here

     *
     * @param config the configuration to test
     */
    private void checkIterationWithReload(FileConfiguration config)
    {
        config.setReloadingStrategy(new FileAlwaysReloadingStrategy());
        for (Iterator it = config.getKeys(); it.hasNext();)
        {
            String key = (String) it.next();
            assertNotNull("No value for key " + key, config.getProperty(key));
        }
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

            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);
            conf.load();
            assertEquals(1, conf.getInt("test"));

            for (int i = 1; i < LOOP_COUNT; ++i)
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.