Added sample code for BAEL-1122 (#6468)
This commit is contained in:
committed by
KevinGilmore
parent
2c4d334dc3
commit
8f54420e95
@@ -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}"/>
|
||||
|
||||
+25
@@ -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");
|
||||
}
|
||||
}
|
||||
+21
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user