This is an automated email from the ASF dual-hosted git repository. btellier pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit e8497e59642781191e5e25b8b2eeb06a31682d51 Author: Tran Tien Duc <[email protected]> AuthorDate: Thu Aug 22 17:22:08 2019 +0700 JAMES-2871 env variables in list strings cannot be parsed as a list --- server/container/guice/configuration/pom.xml | 6 ++ .../PropertiesProviderFromEnvVariablesTest.java | 68 ++++++++++++++++++++++ .../src/test/resources/env.properties | 1 + 3 files changed, 75 insertions(+) diff --git a/server/container/guice/configuration/pom.xml b/server/container/guice/configuration/pom.xml index 5faf426..b369902 100644 --- a/server/container/guice/configuration/pom.xml +++ b/server/container/guice/configuration/pom.xml @@ -45,6 +45,12 @@ <artifactId>james-server-lifecycle-api</artifactId> </dependency> <dependency> + <groupId>com.github.stefanbirkner</groupId> + <artifactId>system-rules</artifactId> + <scope>test</scope> + <version>1.19.0</version> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> diff --git a/server/container/guice/configuration/src/test/java/org/apache/james/utils/PropertiesProviderFromEnvVariablesTest.java b/server/container/guice/configuration/src/test/java/org/apache/james/utils/PropertiesProviderFromEnvVariablesTest.java new file mode 100644 index 0000000..394af7d --- /dev/null +++ b/server/container/guice/configuration/src/test/java/org/apache/james/utils/PropertiesProviderFromEnvVariablesTest.java @@ -0,0 +1,68 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.utils; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.james.server.core.configuration.Configuration; +import org.apache.james.server.core.filesystem.FileSystemImpl; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.EnvironmentVariables; + +public class PropertiesProviderFromEnvVariablesTest { + + @Rule + public final EnvironmentVariables environmentVariables = new EnvironmentVariables(); + + private PropertiesProvider testee; + + @Before + public void setUp() { + Configuration configuration = Configuration.builder() + .workingDirectory("../") + .configurationFromClasspath() + .build(); + FileSystemImpl fileSystem = new FileSystemImpl(configuration.directories()); + testee = new PropertiesProvider(fileSystem, configuration); + } + + @Ignore("It returns a string 'value1, value2, value3, value4, value5'") + @Test + public void getListShouldLoadEnvVariables() throws Exception { + environmentVariables.set("PROPERTIES_PROVIDER_ENV_VARIABLES", "value1, value2, value3, value4, value5"); + + assertThat(testee.getConfiguration("env") + .getList("keyByEnv")) + .containsExactly("value1", "value2", "value3", "value4", "value5"); + } + + @Ignore("It returns a string 'value1, value2, value3, value4, value5'") + @Test + public void getArrayShouldLoadEnvVariables() throws Exception { + environmentVariables.set("PROPERTIES_PROVIDER_ENV_VARIABLES", "value1, value2, value3, value4, value5"); + + assertThat(testee.getConfiguration("env") + .getStringArray("keyByEnv")) + .containsExactly("value1", "value2", "value3", "value4", "value5"); + } +} diff --git a/server/container/guice/configuration/src/test/resources/env.properties b/server/container/guice/configuration/src/test/resources/env.properties new file mode 100644 index 0000000..683afaa --- /dev/null +++ b/server/container/guice/configuration/src/test/resources/env.properties @@ -0,0 +1 @@ +keyByEnv=${env:PROPERTIES_PROVIDER_ENV_VARIABLES} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
