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.modules.mailbox.ElasticSearchMailboxModuleTest.java

@Test
public void provideIndexAttachmentsShouldReturnTrueWhenIndexAttachmentsIsTrueInConfiguration() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("elasticsearch.indexAttachments", true);

    ElasticSearchMailboxModule testee = new ElasticSearchMailboxModule();

    IndexAttachments indexAttachments = testee.provideIndexAttachments(configuration);

    assertThat(indexAttachments).isEqualTo(IndexAttachments.YES);
}

From source file:org.apache.james.modules.mailbox.ElasticSearchMailboxModuleTest.java

@Test
public void provideIndexAttachmentsShouldReturnFalseWhenIndexAttachmentsIsFalseInConfiguration() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("elasticsearch.indexAttachments", false);

    ElasticSearchMailboxModule testee = new ElasticSearchMailboxModule();

    IndexAttachments indexAttachments = testee.provideIndexAttachments(configuration);

    assertThat(indexAttachments).isEqualTo(IndexAttachments.NO);
}

From source file:org.apache.james.modules.spamassassin.SpamAssassinConfigurationLoaderTest.java

@Test
public void hostShouldReturnCustomWhenConfigurationIsProvided() {
    PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
    String host = "10.69.1.123";
    propertiesConfiguration.addProperty("spamassassin.host", host);
    int port = 1783;
    propertiesConfiguration.addProperty("spamassassin.port", port);

    SpamAssassinConfiguration configuration = SpamAssassinConfigurationLoader
            .fromProperties(propertiesConfiguration);
    assertThat(configuration.getHost().get()).isEqualTo(Host.from(host, port));
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getReadAliasQuotaRatioNameShouldReturnConfiguredValue() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String name = "name";
    configuration.addProperty("elasticsearch.alias.read.quota.ratio.name", name);
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getReadAliasQuotaRatioName()).isEqualTo(new ReadAliasName(name));
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getReadAliasQuotaRatioNameShouldReturnDefaultValueWhenMissing() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getReadAliasQuotaRatioName())
            .isEqualTo(QuotaRatioElasticSearchConstants.DEFAULT_QUOTA_RATIO_READ_ALIAS);
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getWriteAliasQuotaRatioNameShouldReturnConfiguredValue() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String name = "name";
    configuration.addProperty("elasticsearch.alias.write.quota.ratio.name", name);
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getWriteAliasQuotaRatioName()).isEqualTo(new WriteAliasName(name));
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getWriteAliasQuotaRatioNameShouldReturnDefaultValueWhenMissing() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getWriteAliasQuotaRatioName())
            .isEqualTo(QuotaRatioElasticSearchConstants.DEFAULT_QUOTA_RATIO_WRITE_ALIAS);
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getIndexQuotaRatioNameShouldReturnConfiguredValue() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String name = "name";
    configuration.addProperty("elasticsearch.index.quota.ratio.name", name);
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getIndexQuotaRatioName()).isEqualTo(new IndexName(name));
}

From source file:org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfigurationTest.java

@Test
public void getIndexQuotaRatioNameShouldReturnDefaultValueWhenMissing() throws ConfigurationException {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchQuotaConfiguration elasticSearchConfiguration = ElasticSearchQuotaConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getIndexQuotaRatioName())
            .isEqualTo(QuotaRatioElasticSearchConstants.DEFAULT_QUOTA_RATIO_INDEX);
}

From source file:org.apache.kylin.rest.service.AdminService.java

/**
 * Get Java Env info as string/*from  w  ww.j a  va2 s  .c o m*/
 */
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public String getEnv() throws ConfigurationException {
    PropertiesConfiguration tempConfig = new PropertiesConfiguration();
    OrderedProperties orderedProperties = new OrderedProperties(new TreeMap<String, String>());
    // Add Java Env

    String content = "";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // env
    Map<String, String> env = System.getenv();

    for (Map.Entry<String, String> entry : env.entrySet()) {
        orderedProperties.setProperty(entry.getKey(), entry.getValue());
    }

    // properties
    Properties properties = System.getProperties();

    for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        orderedProperties.setProperty((String) entry.getKey(), (String) entry.getValue());
    }

    for (Map.Entry<String, String> entry : orderedProperties.entrySet()) {
        tempConfig.addProperty(entry.getKey(), entry.getValue());
    }

    // do save
    tempConfig.save(baos);
    content = baos.toString();
    return content;
}