Examples of PropertiesConfiguration


Examples of org.apache.commons.configuration.PropertiesConfiguration

    private File tempCaptchaFile;
   
    @Override
    public void setUp() throws Exception
    {
        PropertiesConfiguration config = new PropertiesConfiguration();
       
        InputStream input = null;
       
        try
        {
            input = Thread.currentThread().getContextClassLoader().getResourceAsStream("mfa.properties");
            config.load(input);
        }
        finally
        {
            IOUtils.closeQuietly(input);
        }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

    }
   
    if (locations != null) {
      for (int i = 0; i < locations.length; i++) {
        URL url = locations[i].getURL();
        Configuration props = new PropertiesConfiguration(url);
        configuration.addConfiguration(props);
      }
    }
  }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

  }

  public void testMergeConfigurations() throws Exception {
    Configuration one = new BaseConfiguration();
    one.setProperty("foo", "bar");
    PropertiesConfiguration two = new PropertiesConfiguration();
    String properties = "## some header \n" + "foo = bar1\n" + "bar = foo\n";
    two.load(new StringReader(properties));

    configurationFactory.setConfigurations(new Configuration[] { one, two });
    configurationFactory.afterPropertiesSet();
    Properties props = (Properties) configurationFactory.getObject();
    assertEquals("foo", props.getProperty("bar"));
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

            throws TorqueException
    {
        log.debug("init(" + configFile + ")");
        try
        {
            Configuration conf = new PropertiesConfiguration(configFile);

            log.debug("Config Object is " + conf);
            init(conf);
        }
        catch (ConfigurationException e)
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

    }
  }

  @Override
  public synchronized String currentConfig() {
    PropertiesConfiguration saver = new PropertiesConfiguration();
    StringWriter writer = new StringWriter();
    saver.copy(config);
    try { saver.save(writer); }
    catch (Exception e) {
      throw new MetricsConfigException("Error stringify config", e);
    }
    return writer.toString();
  }
View Full Code Here

Examples of org.apache.commons.configuration.PropertiesConfiguration

    {
        log.debug("init(" + configFile + ")");
        try
        {
            Configuration configuration
                    = new PropertiesConfiguration(configFile);

            log.debug("Config Object is " + configuration);
            init(configuration);
        }
        catch (ConfigurationException e)
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");
        VFSFileChangedReloadingStrategy strategy = new VFSFileChangedReloadingStrategy();
        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);
        VFSFileChangedReloadingStrategy strategy = new VFSFileChangedReloadingStrategy();
        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

                // 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);

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