Java Code Examples for org.apache.commons.configuration2.PropertiesConfiguration#read()

The following examples show how to use org.apache.commons.configuration2.PropertiesConfiguration#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readUnscopedKeystone3ConfigurationWithRegion() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME,
        CONFIG_REGION)));
    assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone3ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .identity(IdentityV3.of(DomainName.of(USER_DOMAIN_NAME), UserName.of(USER_NAME)))
                .region(Optional.of(Region.of(REGION)))
                .build()
        );
}
 
Example 2
Source File: SwiftTmpAuthConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readBasicTempAuthConfiguration() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_TENANT_NAME)));
    assertThat(SwiftTmpAuthConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftTempAuthObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .tenantName(TenantName.of(TENANT_NAME))
                .userName(UserName.of(USER_NAME))
                .build()
        );
}
 
Example 3
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readProjectOfDomainIdScopedKeystone3Configuration() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME,
        CONFIG_SCOPE_PROJECT_NAME,
        CONFIG_SCOPE_PROJECT_DOMAIN_ID,
        CONFIG_REGION)));
    assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone3ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .identity(IdentityV3.of(
                    DomainName.of(USER_DOMAIN_NAME),
                    UserName.of(USER_NAME)))
                .region(Optional.of(Region.of(REGION)))
                .project(Project.of(
                    ProjectName.of(SCOPE_PROJECT_NAME),
                    DomainId.of(SCOPE_PROJECT_DOMAIN_ID)))
                .build()
        );
}
 
Example 4
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readProjectOfDomainNameScopedKeystone3Configuration() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME,
        CONFIG_SCOPE_PROJECT_NAME,
        CONFIG_SCOPE_PROJECT_DOMAIN_NAME,
        CONFIG_REGION)));
    assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone3ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .identity(IdentityV3.of(
                    DomainName.of(USER_DOMAIN_NAME),
                    UserName.of(USER_NAME)))
                .region(Optional.of(Region.of(REGION)))
                .project(Project.of(
                    ProjectName.of(SCOPE_PROJECT_NAME),
                    DomainName.of(SCOPE_PROJECT_DOMAIN_NAME)))
                .build()
        );
}
 
Example 5
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readProjectScopedKeystone3Configuration() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME,
        CONFIG_SCOPE_PROJECT_NAME,
        CONFIG_REGION)));
    assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone3ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .identity(IdentityV3.of(DomainName.of(USER_DOMAIN_NAME), UserName.of(USER_NAME)))
                .region(Optional.of(Region.of(REGION)))
                .project(Project.of(ProjectName.of(SCOPE_PROJECT_NAME)))
                .build()
        );
}
 
Example 6
Source File: SwiftTmpAuthConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readTempAuthConfigurationWithRegion() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_TENANT_NAME,
        CONFIG_REGION)));
    assertThat(SwiftTmpAuthConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftTempAuthObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .tenantName(TenantName.of(TENANT_NAME))
                .userName(UserName.of(USER_NAME))
                .region(Optional.of(Region.of(REGION)))
                .build()
        );
}
 
Example 7
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldReturnDefaultOnMissingHost() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
        "tika.port=889\n" +
        "tika.timeoutInMillis=500\n"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .host("127.0.0.1")
                .port(889)
                .timeoutInMillis(500)
                .build());
}
 
Example 8
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldReturnDefaultOnMissingTimeout() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
        "tika.host=172.0.0.5\n" +
        "tika.port=889\n"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .host("172.0.0.5")
                .port(889)
                .timeoutInMillis(30 * 1000)
                .build());
}
 
Example 9
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readUnscopedKeystone3Configuration() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME)));
    assertThat(SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone3ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .identity(IdentityV3.of(DomainName.of(USER_DOMAIN_NAME), UserName.of(USER_NAME)))
                .build()
        );
}
 
Example 10
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldHaveContentTypeBlacklist() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
            "tika.cache.enabled=true\n" +
            "tika.host=172.0.0.5\n" +
            "tika.port=889\n" +
            "tika.timeoutInMillis=500\n" +
            "tika.cache.weight.max=1520000\n" +
            "tika.contentType.blacklist=application/ics,application/zip"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .cacheEnabled()
                .host("172.0.0.5")
                .port(889)
                .timeoutInMillis(500)
                .cacheWeightInBytes(1520000)
                .contentTypeBlacklist(ImmutableSet.of(MimeType.of("application/ics"), MimeType.of("application/zip")))
                .build());
}
 
Example 11
Source File: SwiftKeystone2ConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
void readKeystone2ConfigurationWithRegion() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_TENANT_NAME,
        CONFIG_REGION)));
    assertThat(SwiftKeystone2ConfigurationReader.readSwiftConfiguration(configuration))
        .isEqualTo(
            SwiftKeystone2ObjectStorage.configBuilder()
                .endpoint(URI.create(ENDPOINT))
                .credentials(Credentials.of(CREDENTIALS))
                .tenantName(TenantName.of(TENANT_NAME))
                .userName(UserName.of(USER_NAME))
                .region(Optional.of(Region.of(REGION)))
                .build()
        );
}
 
Example 12
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldDefaultToSecondWhenMissingUnitForCacheEvitionPeriod() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
        "tika.host=172.0.0.5\n" +
        "tika.port=889\n" +
        "tika.timeoutInMillis=500\n" +
        "tika.cache.eviction.period=3600"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .host("172.0.0.5")
                .port(889)
                .timeoutInMillis(500)
                .cacheEvictionPeriod(Duration.ofHours(1))
                .build());
}
 
Example 13
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldReturnDefaultOnMissingPort() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
        "tika.host=172.0.0.5\n" +
        "tika.timeoutInMillis=500\n"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .host("172.0.0.5")
                .port(9998)
                .timeoutInMillis(500)
                .build());
}
 
Example 14
Source File: TikaConfigurationReaderTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
public void readTikaConfigurationShouldParseUnitForCacheEvictionPeriod() throws Exception {
    PropertiesConfiguration configuration = newConfiguration();
    configuration.read(new StringReader(
        "tika.enabled=true\n" +
        "tika.host=172.0.0.5\n" +
        "tika.port=889\n" +
        "tika.timeoutInMillis=500\n" +
        "tika.cache.eviction.period=2H"));

    assertThat(TikaConfigurationReader.readTikaConfiguration(configuration))
        .isEqualTo(
            TikaConfiguration.builder()
                .enabled()
                .host("172.0.0.5")
                .port(889)
                .timeoutInMillis(500)
                .cacheEvictionPeriod(Duration.ofHours(2))
                .build());
}
 
Example 15
Source File: JmxConfigurationTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void fromPropertiesShouldReturnConfiguredValues() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(
            "jmx.address=172.0.0.5\n" +
            "jmx.port=889\n"));

    assertThat(JmxConfiguration.fromProperties(configuration))
        .isEqualTo(new JmxConfiguration(JmxConfiguration.ENABLED, Optional.of(Host.from("172.0.0.5", 889))));
}
 
Example 16
Source File: SwiftKeystone2ConfigurationReaderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void failToReadSwiftKeystone2ConfigurationWhenMissingUserName() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_TENANT_NAME,
        CONFIG_REGION)));
    assertThatThrownBy(() ->
        SwiftKeystone2ConfigurationReader.readSwiftConfiguration(configuration))
        .isInstanceOf(IllegalArgumentException.class);
}
 
Example 17
Source File: SwiftKeystone3ConfigurationReaderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void failsToReadKeystone3ConfigurationWithoutCredentials() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_USER_NAME,
        CONFIG_USER_DOMAIN_NAME)));
    assertThatThrownBy(() -> SwiftKeystone3ConfigurationReader.readSwiftConfiguration(configuration))
        .isInstanceOf(IllegalArgumentException.class);
}
 
Example 18
Source File: SwiftTmpAuthConfigurationReaderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void failToReadSwiftTempAuthConfigurationWhenMissingUserName() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_TENANT_NAME,
        CONFIG_REGION)));
    assertThatThrownBy(() ->
        SwiftTmpAuthConfigurationReader.readSwiftConfiguration(configuration))
        .isInstanceOf(IllegalArgumentException.class);
}
 
Example 19
Source File: SwiftTmpAuthConfigurationReaderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void failToReadSwiftTempAuthConfigurationWhenMissingTenantName() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_ENDPOINT,
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_REGION)));
    assertThatThrownBy(() ->
        SwiftTmpAuthConfigurationReader.readSwiftConfiguration(configuration))
        .isInstanceOf(IllegalArgumentException.class);
}
 
Example 20
Source File: SwiftKeystone2ConfigurationReaderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void failToReadSwiftKeystone2ConfigurationWhenMissingEndpoint() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.read(new StringReader(StringUtils.joinWith("\n",
        CONFIG_CREDENTIALS,
        CONFIG_USER_NAME,
        CONFIG_TENANT_NAME,
        CONFIG_REGION)));
    assertThatThrownBy(() ->
        SwiftKeystone2ConfigurationReader.readSwiftConfiguration(configuration))
        .isInstanceOf(IllegalArgumentException.class);
}