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.mailbox.elasticsearch.ElasticSearchMailboxConfigurationTest.java

@Test
public void getWriteAliasMailboxNameShouldReturnNewConfiguredValueWhenBoth() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    String name = "name";
    configuration.addProperty("elasticsearch.alias.write.mailbox.name", name);
    configuration.addProperty("elasticsearch.alias.write.name", "other");
    configuration.addProperty("elasticsearch.hosts", "127.0.0.1");

    ElasticSearchMailboxConfiguration elasticSearchConfiguration = ElasticSearchMailboxConfiguration
            .fromProperties(configuration);

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

From source file:org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfigurationTest.java

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

    ElasticSearchMailboxConfiguration elasticSearchConfiguration = ElasticSearchMailboxConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getWriteAliasMailboxName())
            .isEqualTo(MailboxElasticSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS);
}

From source file:org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfigurationTest.java

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

    ElasticSearchMailboxConfiguration elasticSearchConfiguration = ElasticSearchMailboxConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getIndexAttachment()).isEqualTo(IndexAttachments.YES);
}

From source file:org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfigurationTest.java

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

    ElasticSearchMailboxConfiguration elasticSearchConfiguration = ElasticSearchMailboxConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getIndexAttachment()).isEqualTo(IndexAttachments.NO);
}

From source file:org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfigurationTest.java

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

    ElasticSearchMailboxConfiguration elasticSearchConfiguration = ElasticSearchMailboxConfiguration
            .fromProperties(configuration);

    assertThat(elasticSearchConfiguration.getIndexAttachment()).isEqualTo(IndexAttachments.YES);
}

From source file:org.apache.james.modules.blobstore.BlobStoreChoosingConfigurationTest.java

@Test
void fromShouldThrowWhenBlobStoreImplIsNull() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", null);

    assertThatThrownBy(() -> BlobStoreChoosingConfiguration.from(configuration))
            .isInstanceOf(IllegalStateException.class).hasMessage(
                    "implementation property is missing please use one of supported values in: cassandra, objectstorage, union");
}

From source file:org.apache.james.modules.blobstore.BlobStoreChoosingConfigurationTest.java

@Test
void fromShouldThrowWhenBlobStoreImplIsEmpty() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", "");

    assertThatThrownBy(() -> BlobStoreChoosingConfiguration.from(configuration))
            .isInstanceOf(IllegalStateException.class).hasMessage(
                    "implementation property is missing please use one of supported values in: cassandra, objectstorage, union");
}

From source file:org.apache.james.modules.blobstore.BlobStoreChoosingConfigurationTest.java

@Test
void fromShouldThrowWhenBlobStoreImplIsNotInSupportedList() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", "un_supported");

    assertThatThrownBy(() -> BlobStoreChoosingConfiguration.from(configuration))
            .isInstanceOf(IllegalArgumentException.class).hasMessage(
                    "un_supported is not a valid name of BlobStores, please use one of supported values in: cassandra, objectstorage, union");
}

From source file:org.apache.james.modules.blobstore.BlobStoreChoosingConfigurationTest.java

@Test
void fromShouldReturnConfigurationWhenBlobStoreImplIsCassandra() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", CASSANDRA);

    assertThat(BlobStoreChoosingConfiguration.from(configuration).getImplementation().getName())
            .isEqualTo(CASSANDRA);/*from   w w  w  .  jav  a2  s.  c  om*/
}

From source file:org.apache.james.modules.blobstore.BlobStoreChoosingConfigurationTest.java

@Test
void fromShouldReturnConfigurationWhenBlobStoreImplIsUnion() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", UNION);

    assertThat(BlobStoreChoosingConfiguration.from(configuration).getImplementation().getName())
            .isEqualTo(UNION);/*from   w ww.j a v  a 2  s .co m*/
}