Added sample code for BAEL-1122 (#6468)

This commit is contained in:
Juan Moreno
2019-03-09 00:50:03 -03:00
committed by KevinGilmore
parent 2c4d334dc3
commit 8f54420e95
5 changed files with 59 additions and 8 deletions
@@ -7,6 +7,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@PropertySource("classpath:foo.properties")
@PropertySource("classpath:bar.properties")
public class PropertiesWithJavaConfig {
public PropertiesWithJavaConfig() {
@@ -7,7 +7,7 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:foo.properties"/>
<context:property-placeholder location="classpath:foo.properties,classpath:bar.properties"/>
<bean id="componentInXmlUsingProperties" class="org.baeldung.properties.core.ComponentInXmlUsingProperties">
<constructor-arg value="${key.something}"/>
@@ -0,0 +1,25 @@
package org.baeldung.properties.multiple;
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@SpringJUnitConfig(PropertiesWithJavaConfig.class)
public class MultiplePropertiesJavaConfigIntegrationTest {
@Value("${key.something}")
private String something;
@Value("${key.something2}")
private String something2;
@Test
public void whenReadInjectedValues_thenGetCorrectValues() {
assertThat(something).isEqualTo("val");
assertThat(something2).isEqualTo("val2");
}
}
@@ -0,0 +1,21 @@
package org.baeldung.properties.multiple;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@SpringJUnitConfig(locations = "classpath:configForProperties.xml")
public class MultiplePropertiesXmlConfigIntegrationTest {
@Value("${key.something}") private String something;
@Value("${key.something2}") private String something2;
@Test
public void whenReadInjectedValues_thenGetCorrectValues() {
assertThat(something).isEqualTo("val");
assertThat(something2).isEqualTo("val2");
}
}