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

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

Introduction

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

Prototype

public void addProperty(String key, Object value) 

Source Link

Document

Adds a new property to this configuration.

Usage

From source file:org.apache.james.backends.es.ElasticSearchConfigurationTest.java

@Test
public void getHostsShouldReturnConfiguredMasterHost() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String hostname = "myHost";
    configuration.addProperty("elasticsearch.masterHost", hostname);
    int port = 9300;
    configuration.addProperty("elasticsearch.port", port);

    ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getHosts()).containsOnly(Host.from(hostname, port));
}

From source file:org.apache.james.backends.es.ElasticSearchConfigurationTest.java

@Test
public void clusterNameShouldBeEmptyWhenNotGiven() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String hostname = "myHost";
    configuration.addProperty("elasticsearch.masterHost", hostname);
    int port = 9300;
    configuration.addProperty("elasticsearch.port", port);

    ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getClusterName()).isEmpty();
}

From source file:org.apache.james.backends.es.ElasticSearchConfigurationTest.java

@Test
public void clusterNameShouldBeEmptyWhenNull() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String hostname = "myHost";
    configuration.addProperty("elasticsearch.masterHost", hostname);
    int port = 9300;
    configuration.addProperty("elasticsearch.port", port);
    configuration.addProperty("elasticsearch.clusterName", null);

    ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getClusterName()).isEmpty();
}

From source file:org.apache.james.backends.es.ElasticSearchConfigurationTest.java

@Test
public void clusterNameShouldKeepTheValueWhenGiven() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String hostname = "myHost";
    configuration.addProperty("elasticsearch.masterHost", hostname);
    int port = 9300;
    configuration.addProperty("elasticsearch.port", port);
    String clusterName = "myClusterName";
    configuration.addProperty("elasticsearch.clusterName", clusterName);

    ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getClusterName()).contains(clusterName);
}

From source file:org.apache.james.CassandraConfTest.java

private PropertiesConfiguration getCassandraConfigurationForDocker(String confIps) {
    PropertiesConfiguration configuration = new PropertiesConfiguration();

    configuration.addProperty("cassandra.nodes", confIps);
    configuration.addProperty("cassandra.keyspace", "apache_james");
    configuration.addProperty("cassandra.replication.factor", 1);
    configuration.addProperty("cassandra.retryConnection.maxRetries", 10);
    configuration.addProperty("cassandra.retryConnection", 5000);

    return configuration;
}

From source file:org.apache.james.CassandraLogConfigurationTest.java

@Test
public void serverShouldStartWithMinimalConfigAboutAConstantThresholdSlowQueryLogger() throws Exception {
    jamesServer = cassandraJmapTestRule/*from w  w w.  j  av  a  2s  . c  om*/
            .jmapServer((binder) -> binder.bind(CassandraSessionConfiguration.class).toInstance(() -> {
                PropertiesConfiguration configuration = dockerCassandraRule
                        .getCassandraConfigurationForDocker();

                configuration.addProperty("cassandra.query.logger.constant.threshold", 100);

                return configuration;
            }));

    assertThatServerStartCorrectly();
}

From source file:org.apache.james.CassandraLogConfigurationTest.java

@Test
public void serverShouldStartWithPersonalizedConfigAboutPercentileSlowQuerryLogger() throws Exception {
    jamesServer = cassandraJmapTestRule// w w w. jav  a2  s  .  co  m
            .jmapServer((binder) -> binder.bind(CassandraSessionConfiguration.class).toInstance(() -> {
                PropertiesConfiguration configuration = dockerCassandraRule
                        .getCassandraConfigurationForDocker();

                configuration.addProperty("cassandra.query.slow.query.latency.threshold.percentile", 90);
                configuration.addProperty("cassandra.query.logger.max.logged.parameters", 9);
                configuration.addProperty("cassandra.query.logger.max.query.string.length", 9000);
                configuration.addProperty("cassandra.query.logger.max.parameter.value.length", 90);

                return configuration;
            }));

    assertThatServerStartCorrectly();
}

From source file:org.apache.james.CassandraLogConfigurationTest.java

@Test
public void serverStartShouldFailIfConfigAboutLoggerIsInvalid() throws Exception {
    thrown.expect(ProvisionException.class);

    jamesServer = cassandraJmapTestRule//from w w  w . j  ava 2 s.  com
            .jmapServer((binder) -> binder.bind(CassandraSessionConfiguration.class).toInstance(() -> {
                PropertiesConfiguration configuration = dockerCassandraRule
                        .getCassandraConfigurationForDocker();

                configuration.addProperty("cassandra.query.slow.query.latency.threshold.percentile", 90);
                configuration.addProperty("cassandra.query.logger.constant.threshold", 100);

                return configuration;
            }));

    assertThatServerStartCorrectly();
}

From source file:org.apache.james.DockerCassandraRule.java

public PropertiesConfiguration getCassandraConfigurationForDocker() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();

    configuration.addProperty("cassandra.nodes", getIp() + ":" + CASSANDRA_PORT);
    configuration.addProperty("cassandra.keyspace", "apache_james");
    configuration.addProperty("cassandra.replication.factor", 1);
    configuration.addProperty("cassandra.retryConnection.maxRetries", 10);
    configuration.addProperty("cassandra.retryConnection", 5000);

    return configuration;
}

From source file:org.apache.james.DockerElasticSearchRule.java

public PropertiesConfiguration getElasticSearchConfigurationForDocker() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();

    configuration.addProperty("elasticsearch.masterHost", getIp());
    configuration.addProperty("elasticsearch.port", ELASTIC_SEARCH_PORT);

    configuration.addProperty("elasticsearch.nb.shards", 1);
    configuration.addProperty("elasticsearch.nb.replica", 0);
    configuration.addProperty("elasticsearch.retryConnection.maxRetries", 7);
    configuration.addProperty("elasticsearch.retryConnection.minDelay", 30);
    configuration.addProperty("elasticsearch.indexAttachments", false);
    configuration.addProperty("elasticsearch.http.host", getIp());
    configuration.addProperty("elasticsearch.http.port", ELASTIC_SEARCH_HTTP_PORT);
    configuration.addProperty("elasticsearch.metrics.reports.enabled", true);
    configuration.addProperty("elasticsearch.metrics.reports.period", 30);
    configuration.addProperty("elasticsearch.metrics.reports.index", "james-metrics");

    return configuration;
}