Example usage for org.apache.commons.configuration PropertiesConfiguration setProperty

List of usage examples for org.apache.commons.configuration PropertiesConfiguration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration setProperty.

Prototype

public void setProperty(String key, Object value) 

Source Link

Document

Sets a new value for the specified property.

Usage

From source file:org.janusgraph.hadoop.HBaseSnapshotInputFormatIT.java

protected Graph getGraph() throws IOException, ConfigurationException {
    final PropertiesConfiguration config = new PropertiesConfiguration(
            "target/test-classes/hbase-read-snapshot.properties");
    Path baseOutDir = Paths.get((String) config.getProperty("gremlin.hadoop.outputLocation"));
    baseOutDir.toFile().mkdirs();/*from  www .j  a v  a2s  .c om*/
    String outDir = Files.createTempDirectory(baseOutDir, null).toAbsolutePath().toString();
    config.setProperty("gremlin.hadoop.outputLocation", outDir);
    // Set the hbase.rootdir property. This is needed by HBaseSnapshotInputFormat.
    config.setProperty("janusgraphmr.ioformat.conf.storage.hbase.ext.hbase.rootdir",
            HBaseStorageSetup.getHBaseRootdir());
    return GraphFactory.open(config);
}

From source file:org.jboss.qa.jcontainer.fuse.test.FuseContainerPortTest.java

@AfterClass
public static void afterClass() throws Exception {
    if (container != null) {
        container.stop();// w  w  w.j a  v  a2s  .c  o m
        final File propsFile = new File(container.getConfiguration().getDirectory(),
                "etc" + File.separator + "org.apache.karaf.shell.cfg");
        final PropertiesConfiguration propConf = new PropertiesConfiguration(propsFile);
        propConf.setProperty("sshPort", FuseConfiguration.DEFAULT_SSH_PORT);
        propConf.save();
    }
}

From source file:org.jboss.qa.jcontainer.karaf.KarafContainer.java

protected void setEtcProperty(String key, Object value, String config) throws Exception {
    final File propsFile = getConfigFile(config);
    final PropertiesConfiguration propConf = new PropertiesConfiguration(propsFile);
    propConf.setProperty(key, value);
    propConf.save();//from  w w  w. j  av a  2 s .  co m
}

From source file:org.jboss.qa.jcontainer.karaf.KarafContainerPortTest.java

@AfterClass
public static void afterClass() throws Exception {
    if (container != null) {
        container.stop();//from ww w .  ja  va 2 s  .co m
        final File propsFile = container.getConfigFile("org.apache.karaf.shell");
        final PropertiesConfiguration propConf = new PropertiesConfiguration(propsFile);
        propConf.setProperty("sshPort", KarafConfiguration.DEFAULT_SSH_PORT);
        propConf.save();
    }
}

From source file:org.jboss.qa.jcontainer.wildfly.WildflyContainer.java

@Override
public void addUser(V user) throws Exception {
    if (user.getRealm() == null) {
        user.setRealm(WildflyUser.Realm.MANAGEMENT_REALM);
    }/*from  w  ww  . j  a  va 2 s. c om*/
    checkMandatoryProperty("username", user.getUsername());
    checkMandatoryProperty("password", user.getUsername());

    File usersFile;
    File rolesFile;
    if (user.getRealm().equals(WildflyUser.Realm.APPLICATION_REALM)) {
        usersFile = new File(configuration.getConfigurationFolder(), "application-users.properties");
        rolesFile = new File(configuration.getConfigurationFolder(), "application-roles.properties");
    } else {
        usersFile = new File(configuration.getConfigurationFolder(), "mgmt-users.properties");
        rolesFile = new File(configuration.getConfigurationFolder(), "mgmt-groups.properties");
    }
    final PropertiesConfiguration propConfUsers = new PropertiesConfiguration(usersFile);
    propConfUsers.setProperty(user.getUsername(), DigestUtils.md5Hex(
            String.format("%s:%s:%s", user.getUsername(), user.getRealm().getValue(), user.getPassword())));
    propConfUsers.save();

    final PropertiesConfiguration propConfRoles = new PropertiesConfiguration(rolesFile);
    propConfRoles.setProperty(user.getUsername(), StringUtils.join(user.getRoles(), ","));
    propConfRoles.save();
}

From source file:org.jenkinsci.test.acceptance.utils.pluginreporter.TextFileExercisedPluginReporter.java

@Override
public void log(String testName, String pluginName, String pluginVersion) {

    PropertiesConfiguration config = null;
    try {//from  w ww.j  av  a  2s . c o m
        config = new PropertiesConfiguration(file);
    } catch (ConfigurationException e) {
        LOGGER.error(e.getMessage());
        return;
    }

    config.setProperty(testName + "$" + pluginName, pluginVersion);
    try {
        config.save();
    } catch (ConfigurationException e) {
        LOGGER.error(e.getMessage());
        return;
    }
}

From source file:org.jspare.core.config.CommonsConfigImpl.java

@Override
public void store() {

    try {/*w ww  . j av a  2 s .  c  o m*/

        PropertiesConfiguration targetConfiguration = new PropertiesConfiguration(this.fileToLoad);
        configuration.getKeys()
                .forEachRemaining(k -> targetConfiguration.setProperty(k, configuration.getProperties(k)));
        targetConfiguration.save();

    } catch (ConfigurationException e) {

        log.error("Error when trying to save a configuration [{}] - Message [{}]", this.fileToLoad,
                e.getMessage());
    }
}

From source file:org.lockss.crawljax.DefLockssConfigurationBuilder.java

static PropertiesConfiguration defaultConfig() {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty(MAX_STATES_PARAM, MAX_STATES_DEFAULT);
    config.setProperty(DEPTH_PARAM, DEPTH_DEFAULT);
    config.setProperty(BROWSER_PARAM, BROWSER_DEFAULT.name());
    config.setProperty(PARALLEL_PARAM, PARALLEL_DEFAULT);
    config.setProperty(CRAWL_HIDDEN_PARAM, CRAWL_HIDDEN_DEFAULT);
    config.setProperty(CLICK_ONCE_PARAM, CLICK_ONCE_DEFAULT);
    config.setProperty(TIMEOUT_PARAM, TIMEOUT_DEFAULT);
    config.setProperty(WAIT_AFTER_RELOAD_PARAM, WAIT_AFTER_RELOAD_DEFAULT);
    config.setProperty(WAIT_AFTER_EVENT_PARAM, WAIT_AFTER_EVENT_DEFAULT);
    config.setProperty(CRAWL_FRAMES_PARAM, CRAWL_FRAMES_DEFAULT);
    config.setProperty(INSERT_RANDOM_DATA_PARAM, INSERT_RANDOM_DATA_DEFAULT);
    config.setProperty(CLICK_PARAM, CLICK_DEFAULT);
    config.setProperty(PROXY_PARAM, PROXY_PARAM_DEFAULT);
    config.setProperty(SCARAB_PROXY_ADDR_PARAM, SCARAB_PROXY_ADDR_DEFAULT);
    config.setProperty(SCARAB_PROXY_PORT_PARAM, SCARAB_PROXY_PORT_DEFAULT);
    config.setProperty(WARC_PROXY_HOST_PARAM, WARC_PROXY_HOST_DEFAULT);
    config.setProperty(WARC_PROXY_WEB_PORT_PARAM, WARC_PROXY_WEB_PORT_DEFAULT);
    return config;
}

From source file:org.lockss.crawljax.TestDefLockssConfigurationBuilder.java

public void testConfigureCrawlRules() throws Exception {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(m_testUrl);
    m_configBuilder.setConfig(m_defaultConfig);
    m_configBuilder.configureCrawlRules(builder);
    CrawljaxConfiguration cconfig = builder.build();
    CrawlRules rules = cconfig.getCrawlRules();
    assertEquals(DefLockssConfigurationBuilder.CRAWL_HIDDEN_DEFAULT, rules.isCrawlHiddenAnchors());
    assertEquals(DefLockssConfigurationBuilder.CLICK_ONCE_DEFAULT, rules.isClickOnce());
    assertEquals(DefLockssConfigurationBuilder.CRAWL_FRAMES_DEFAULT, rules.shouldCrawlFrames());
    assertEquals(DefLockssConfigurationBuilder.INSERT_RANDOM_DATA_DEFAULT, rules.isRandomInputInForms());
    assertEquals(DefLockssConfigurationBuilder.TIMEOUT_DEFAULT * 60000, cconfig.getMaximumRuntime());
    assertEquals(DefLockssConfigurationBuilder.WAIT_AFTER_EVENT_DEFAULT, rules.getWaitAfterEvent());
    assertEquals(DefLockssConfigurationBuilder.WAIT_AFTER_RELOAD_DEFAULT, rules.getWaitAfterReloadUrl());
    // reassign the defaults
    PropertiesConfiguration config = new PropertiesConfiguration();

    config.setProperty(DefLockssConfigurationBuilder.CRAWL_HIDDEN_PARAM,
            !DefLockssConfigurationBuilder.CRAWL_HIDDEN_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.CLICK_ONCE_PARAM,
            !DefLockssConfigurationBuilder.CLICK_ONCE_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.TIMEOUT_PARAM,
            2 * DefLockssConfigurationBuilder.TIMEOUT_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.WAIT_AFTER_RELOAD_PARAM,
            2 * DefLockssConfigurationBuilder.WAIT_AFTER_RELOAD_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.WAIT_AFTER_EVENT_PARAM,
            2 * DefLockssConfigurationBuilder.WAIT_AFTER_EVENT_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.CRAWL_FRAMES_PARAM,
            !DefLockssConfigurationBuilder.CRAWL_FRAMES_DEFAULT);
    config.setProperty(DefLockssConfigurationBuilder.INSERT_RANDOM_DATA_PARAM,
            !DefLockssConfigurationBuilder.INSERT_RANDOM_DATA_DEFAULT);
    m_configBuilder.setConfig(config);//from w w  w.  j av  a2s. com
    m_configBuilder.configureCrawlRules(builder);
    cconfig = builder.build();
    rules = cconfig.getCrawlRules();
    assertEquals(!DefLockssConfigurationBuilder.CRAWL_HIDDEN_DEFAULT, rules.isCrawlHiddenAnchors());
    assertEquals(!DefLockssConfigurationBuilder.CLICK_ONCE_DEFAULT, rules.isClickOnce());
    assertEquals(!DefLockssConfigurationBuilder.CRAWL_FRAMES_DEFAULT, rules.shouldCrawlFrames());
    assertEquals(!DefLockssConfigurationBuilder.INSERT_RANDOM_DATA_DEFAULT, rules.isRandomInputInForms());
    assertEquals(DefLockssConfigurationBuilder.TIMEOUT_DEFAULT * 60000 * 2, cconfig.getMaximumRuntime());
    assertEquals(DefLockssConfigurationBuilder.WAIT_AFTER_EVENT_DEFAULT * 2, rules.getWaitAfterEvent());
    assertEquals(DefLockssConfigurationBuilder.WAIT_AFTER_RELOAD_DEFAULT * 2, rules.getWaitAfterReloadUrl());
}

From source file:org.lockss.crawljax.TestDefLockssConfigurationBuilder.java

public void testConfigureCrawlClicks() throws Exception {
    CrawljaxConfigurationBuilder builder = CrawljaxConfiguration.builderFor(m_testUrl);
    m_configBuilder.setConfig(m_defaultConfig);
    m_configBuilder.configureCrawlClicks(builder);
    CrawljaxConfiguration cconfig = builder.build();
    CrawlRules rules = cconfig.getCrawlRules();
    ImmutableList<CrawlElement> included = rules.getPreCrawlConfig().getIncludedElements();
    assertEquals(1, included.size());/*from ww w .j  a  v  a2 s  .c om*/
    ImmutableList<CrawlElement> excluded = rules.getPreCrawlConfig().getExcludedElements();
    assertEquals(0, excluded.size());

    // modify the rules by changing the basic config
    builder = CrawljaxConfiguration.builderFor(m_testUrl);
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty(DefLockssConfigurationBuilder.CLICK_PARAM, "A");
    config.setProperty(DefLockssConfigurationBuilder.DONT_CLICK_PARAM, "OPTION");
    config.setProperty(DefLockssConfigurationBuilder.DONT_CLICK_CHILDREN_PARAM, "FORM");
    m_configBuilder.setConfig(config);
    m_configBuilder.configureCrawlClicks(builder);
    cconfig = builder.build();
    rules = cconfig.getCrawlRules();
    included = rules.getPreCrawlConfig().getIncludedElements();
    assertEquals(1, included.size());
    excluded = rules.getPreCrawlConfig().getExcludedElements();
    assertEquals(2, excluded.size());

}