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.blobstore.BlobStoreChoosingConfigurationTest.java

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

    assertThat(BlobStoreChoosingConfiguration.from(configuration).getImplementation().getName())
            .isEqualTo(OBJECT_STORAGE);/*from  w  w w .  jav a  2s .c  o  m*/
}

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

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

    assertThat(BlobStoreChoosingConfiguration.from(configuration).getImplementation().getName())
            .isEqualTo(OBJECT_STORAGE);// w  w  w. j ava 2s . com
}

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

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

    assertThat(BlobStoreChoosingConfiguration.from(configuration).getImplementation().getName())
            .isEqualTo(CASSANDRA);//from  w  w w . j av  a2  s .  co  m
}

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

@Test
void provideChoosingConfigurationShouldThrowWhenMissingPropertyField() {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", "");
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThatThrownBy(() -> module.provideChoosingConfiguration(propertyProvider))
            .isInstanceOf(IllegalStateException.class);
}

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

@Test
void provideChoosingConfigurationShouldThrowWhenEmptyPropertyField() throws Exception {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", "");
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThatThrownBy(() -> module.provideChoosingConfiguration(propertyProvider))
            .isInstanceOf(IllegalStateException.class);
}

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

@Test
void provideChoosingConfigurationShouldThrowWhenPropertyFieldIsNotInSupportedList() throws Exception {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", "gabouzomeuh");
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThatThrownBy(() -> module.provideChoosingConfiguration(propertyProvider))
            .isInstanceOf(IllegalArgumentException.class);
}

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

@Test
void provideChoosingConfigurationShouldReturnSwiftFactoryWhenConfigurationImplIsSwift() throws Exception {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", BlobStoreImplName.OBJECTSTORAGE.getName());
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThat(module.provideChoosingConfiguration(propertyProvider))
            .isEqualTo(BlobStoreChoosingConfiguration.objectStorage());
}

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

@Test
void provideChoosingConfigurationShouldReturnUnionConfigurationWhenConfigurationImplIsUnion() throws Exception {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", BlobStoreImplName.UNION.getName());
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThat(module.provideChoosingConfiguration(propertyProvider))
            .isEqualTo(BlobStoreChoosingConfiguration.union());
}

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

@Test
void provideChoosingConfigurationShouldReturnCassandraFactoryWhenConfigurationImplIsCassandra()
        throws Exception {
    BlobStoreChoosingModule module = new BlobStoreChoosingModule();
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty("implementation", BlobStoreImplName.CASSANDRA.getName());
    FakePropertiesProvider propertyProvider = FakePropertiesProvider.builder()
            .register(ConfigurationComponent.NAME, configuration).build();

    assertThat(module.provideChoosingConfiguration(propertyProvider))
            .isEqualTo(BlobStoreChoosingConfiguration.cassandra());
}

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

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

    ElasticSearchConfiguration elasticSearchConfiguration = ElasticSearchConfiguration
            .fromProperties(configuration);

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