Examples of PropertiesConfiguration


Examples of org.apache.commons.configuration.PropertiesConfiguration

        if (file.exists())
        {
            file.delete();
        }

        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFile(file);
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(500);
        config.setReloadingStrategy(strategy);

        assertNull("Initial value", config.getString("string"));

        // change the file
        FileWriter out = new FileWriter(file);
        out.write("string=value1");
        out.flush();
        out.close();

        Thread.sleep(2000);

        // test the automatic reloading
        assertEquals("Modified value with enabled reloading", "value1", config.getString("string"));
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

    /**
     * Tests if a file from the classpath can be monitored.
     */
    public void testFromClassPath() throws Exception
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFileName(TEST_FILE);
        config.load();
        assertTrue(config.getBoolean("configuration.loaded"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        assertEquals(config.getURL().toExternalForm(), strategy.getFile().toURI().toURL().toExternalForm());
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

                // signal always a change
                return true;
            }
        };
        strategy.setRefreshDelay(100000);
        PropertiesConfiguration config = new PropertiesConfiguration(TEST_FILE);
        config.setReloadingStrategy(strategy);
        assertTrue("Reloading not required", strategy.reloadingRequired());
        assertTrue("Reloading no more required", strategy.reloadingRequired());
        strategy.reloadingPerformed();
        assertFalse("Reloading still required", strategy.reloadingRequired());
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

        out.write("string=value1");
        out.flush();
        out.close();

        // load the configuration
        PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties");
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(500);
        config.setReloadingStrategy(strategy);
        assertEquals("Initial value", "value1", config.getString("string"));

        Thread.sleep(2000);

        // Delete the file.
        file.delete();
        //Old value should still be returned.
        assertEquals("Initial value", "value1", config.getString("string"));
        logger.removeAppender(appender);
        String str = os.toString();
        //System.out.println(str);
        assertTrue("No error was logged", str != null && str.length() > 0);
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

        out.write("string=value1");
        out.flush();
        out.close();

        // load the configuration
        PropertiesConfiguration config = new PropertiesConfiguration("target/testReload.properties");
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(500);
        config.setReloadingStrategy(strategy);
        assertEquals("Initial value", "value1", config.getString("string"));

        Thread.sleep(2000);

        // change the file
        out = new FileWriter(file);
        out.write("string=value2");
        out.flush();
        out.close();

        // test the automatic reloading
        assertEquals("Modified value with enabled reloading", "value2", config.getString("string"));
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

        if (file.exists())
        {
            file.delete();
        }

        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFile(file);
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        strategy.setRefreshDelay(500);
        config.setReloadingStrategy(strategy);

        assertNull("Initial value", config.getString("string"));

        // change the file
        FileWriter out = new FileWriter(file);
        out.write("string=value1");
        out.flush();
        out.close();

        Thread.sleep(2000);

        // test the automatic reloading
        assertEquals("Modified value with enabled reloading", "value1", config.getString("string"));
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

    /**
     * Tests if a file from the classpath can be monitored.
     */
    public void testFromClassPath() throws Exception
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
        config.setFileName("test.properties");
        config.load();
        assertTrue(config.getBoolean("configuration.loaded"));
        FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy();
        config.setReloadingStrategy(strategy);
        assertEquals(config.getURL(), strategy.getFile().toURL());
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

 
  private void load()
  {
    try
    {
      PropertiesConfiguration pc = new PropertiesConfiguration();
      pc.load("bgslibrary_gui.properties");
     
      basePath = pc.getString("base.path");
      configPath = basePath + pc.getString("config.path");
     
      String paths[] = pc.getStringArray("run.path");
      loadConfigComboBox.setModel(new DefaultComboBoxModel(paths));
     
      String methods[] = pc.getStringArray("bgs.methods");
      tictocComboBox.setModel(new DefaultComboBoxModel(methods));
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

     *
     * @param confURL
     *          Configuration URL
     */
    public void loadConf(URL confURL) throws ConfigurationException {
        Configuration loadedConf = new PropertiesConfiguration(confURL);
        addConfiguration(loadedConf);
    }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

     * precedence over any loaded later.
     *
     * @param confURL
     */
    public void loadConf(URL confURL) throws ConfigurationException {
        Configuration loadedConf = new PropertiesConfiguration(confURL);
        conf.addConfiguration(loadedConf);

    }
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.