List of usage examples for org.apache.commons.configuration PropertiesConfiguration load
public synchronized void load(Reader in) throws ConfigurationException
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldDefaultToSecondWhenMissingUnitForCacheEvitionPeriod() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(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()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldParseUnitForCacheWeightMax() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n" + "tika.cache.weight.max=200M")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo(TikaConfiguration.builder().enabled().host("172.0.0.5").port(889).timeoutInMillis(500) .cacheWeightInBytes(200L * 1024L * 1024L).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldDefaultToByteAsSizeUnit() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader("tika.enabled=true\n" + "tika.host=172.0.0.5\n" + "tika.port=889\n" + "tika.timeoutInMillis=500\n" + "tika.cache.weight.max=1520000")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo(TikaConfiguration.builder().enabled().host("172.0.0.5").port(889).timeoutInMillis(500) .cacheWeightInBytes(1520000).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldEnableCacheWhenConfigured() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration .load(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")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)) .isEqualTo(TikaConfiguration.builder().enabled().cacheEnabled().host("172.0.0.5").port(889) .timeoutInMillis(500).cacheWeightInBytes(1520000).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldNotHaveContentTypeBlacklist() throws ConfigurationException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration .load(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")); assertThat(TikaConfigurationReader.readTikaConfiguration(configuration)).isEqualTo(TikaConfiguration .builder().enabled().cacheEnabled().host("172.0.0.5").port(889).timeoutInMillis(500) .cacheWeightInBytes(1520000).contentTypeBlacklist(ImmutableSet.of()).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldHaveContentTypeBlacklist() throws ConfigurationException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration .load(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("application/ics", "application/zip")).build()); }
From source file:org.apache.james.modules.mailbox.TikaConfigurationReaderTest.java
@Test public void readTikaConfigurationShouldHaveContentTypeBlacklistWithWhiteSpace() throws ConfigurationException { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration .load(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("application/ics", "application/zip")).build()); }
From source file:org.apache.james.modules.objectstorage.SwiftKeystone2ConfigurationReaderTest.java
@Test void readBasicKeystone2Configuration() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader(StringUtils.joinWith("\n", CONFIG_ENDPOINT, CONFIG_CREDENTIALS, CONFIG_USER_NAME, CONFIG_TENANT_NAME))); 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)).build()); }
From source file:org.apache.james.modules.objectstorage.SwiftKeystone2ConfigurationReaderTest.java
@Test void readKeystone2ConfigurationWithRegion() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(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()); }
From source file:org.apache.james.modules.objectstorage.SwiftKeystone2ConfigurationReaderTest.java
@Test void failToReadSwiftKeystone2ConfigurationWhenMissingEndpoint() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.load(new StringReader(StringUtils.joinWith("\n", CONFIG_CREDENTIALS, CONFIG_USER_NAME, CONFIG_TENANT_NAME, CONFIG_REGION))); assertThatThrownBy(() -> SwiftKeystone2ConfigurationReader.readSwiftConfiguration(configuration)) .isInstanceOf(IllegalArgumentException.class); }