added example for multidocument properties files
This commit is contained in:
parent
5e26ff97d9
commit
7347c8fe16
|
@ -8,4 +8,8 @@ spring.datasource.url=jdbc:h2:dev
|
||||||
spring.datasource.username=SA
|
spring.datasource.username=SA
|
||||||
spring.datasource.password=password
|
spring.datasource.password=password
|
||||||
app.name=MyApp
|
app.name=MyApp
|
||||||
app.description=${app.name} is a Spring Boot application
|
app.description=${app.name} is a Spring Boot application
|
||||||
|
bael.property=defaultValue
|
||||||
|
#---
|
||||||
|
spring.config.activate.on-profile=prod
|
||||||
|
bael.property=prodValue
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.baeldung.boot.properties.multidocument;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
|
||||||
|
import com.baeldung.boot.properties.DemoApplication;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK)
|
||||||
|
public class DefaultMultidocumentPropertiesFileIntegrationTest {
|
||||||
|
|
||||||
|
@Value("${bael.property}")
|
||||||
|
private String baelCustomProperty;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||||
|
assertThat(baelCustomProperty).isEqualTo("defaultValue");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.baeldung.boot.properties.multidocument;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
|
import com.baeldung.boot.properties.DemoApplication;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK)
|
||||||
|
@ActiveProfiles("prod")
|
||||||
|
public class ProdMultidocumentPropertiesFileIntegrationTest {
|
||||||
|
|
||||||
|
@Value("${bael.property}")
|
||||||
|
private String baelCustomProperty;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||||
|
assertThat(baelCustomProperty).isEqualTo("prodValue");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue