Example usage for org.apache.commons.configuration BaseConfiguration getProperty

List of usage examples for org.apache.commons.configuration BaseConfiguration getProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration BaseConfiguration getProperty.

Prototype

public Object getProperty(String key) 

Source Link

Document

Read property from underlying map.

Usage

From source file:com.netflix.config.PollingSourceTest.java

@Test
public void testIncrementalPollingSource() throws Exception {
    BaseConfiguration config = new BaseConfiguration();
    DynamicPropertyFactory.initWithConfigurationSource(config);
    DynamicStringProperty prop1 = new DynamicStringProperty("prop1", null);
    DynamicStringProperty prop2 = new DynamicStringProperty("prop2", null);
    config.addProperty("prop1", "original");
    DummyPollingSource source = new DummyPollingSource(true);
    FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, true);
    scheduler.setIgnoreDeletesFromSource(false);
    // ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source,scheduler);
    scheduler.startPolling(source, config);
    assertEquals("original", config.getProperty("prop1"));
    assertEquals("original", prop1.get());
    source.setAdded("prop2=new");
    Thread.sleep(200);//from www. ja  v  a 2 s  . co m
    assertEquals("original", config.getProperty("prop1"));
    assertEquals("new", config.getProperty("prop2"));
    assertEquals("new", prop2.get());
    source.setDeleted("prop1=DoesNotMatter");
    source.setChanged("prop2=changed");
    source.setAdded("");
    Thread.sleep(200);
    assertFalse(config.containsKey("prop1"));
    assertNull(prop1.get());
    assertEquals("changed", config.getProperty("prop2"));
    assertEquals("changed", prop2.get());
}

From source file:net.riccardocossu.i18split.maven.I18splitMojo.java

public void execute() throws MojoExecutionException {
    File f = new File(outputBasePath);

    if (!f.exists()) {
        f.mkdirs();//from  w w w .  j a  v a2  s.c  o m
    }

    BaseConfiguration conf = new BaseConfiguration();
    conf.addProperty(ConfigKeys.INPUT_DRIVER, inputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_DRIVER, outputPlugin);
    conf.addProperty(ConfigKeys.OUTPUT_BASE_PATH, outputBasePath);
    conf.addProperty(ConfigKeys.INPUT_BASE_PATH, inputBasePath);
    conf.addProperty(ConfigKeys.INPUT_ENCODING, inputEncoding);
    conf.addProperty(ConfigKeys.OUTPUT_ENCODING, outputEncoding);
    if (pluginsConfig != null) {
        @SuppressWarnings("unchecked")
        MapConfiguration mc = new MapConfiguration(pluginsConfig);
        conf.append(mc);
    }
    org.apache.maven.plugin.logging.Log log = getLog();
    Iterator<String> keys = conf.getKeys();
    while (keys.hasNext()) {
        String k = keys.next();
        log.info(String.format("%s = %s", k, conf.getProperty(k)));
    }
    Engine eng = new Engine(conf);
    eng.process();

}

From source file:org.neo4j.server.configuration.validation.WebadminConfigurationRuleTest.java

@Test
public void shouldNormaliseUris() throws RuleFailedException {
    WebadminConfigurationRule rule = new WebadminConfigurationRule();
    BaseConfiguration config = new BaseConfiguration();
    config.addProperty(Configurator.REST_API_PATH_PROPERTY_KEY, "http://localhost:7474///db///data///");
    config.addProperty(Configurator.MANAGEMENT_PATH_PROPERTY_KEY, "http://localhost:7474////db///manage");
    rule.validate(config);/*from ww  w .  ja va  2  s.  c  o m*/

    assertThat((String) config.getProperty(Configurator.MANAGEMENT_PATH_PROPERTY_KEY),
            not(containsString("///")));
    assertFalse(((String) config.getProperty(Configurator.MANAGEMENT_PATH_PROPERTY_KEY)).endsWith("//"));
    assertFalse(((String) config.getProperty(Configurator.MANAGEMENT_PATH_PROPERTY_KEY)).endsWith("/"));

    assertThat((String) config.getProperty(Configurator.REST_API_PATH_PROPERTY_KEY),
            not(containsString("///")));
    assertFalse(((String) config.getProperty(Configurator.REST_API_PATH_PROPERTY_KEY)).endsWith("//"));
    assertFalse(((String) config.getProperty(Configurator.REST_API_PATH_PROPERTY_KEY)).endsWith("/"));
}