diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties index eace1f0e46..bf89182d8a 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties @@ -8,4 +8,8 @@ spring.datasource.url=jdbc:h2:dev spring.datasource.username=SA spring.datasource.password=password app.name=MyApp -app.description=${app.name} is a Spring Boot application \ No newline at end of file +app.description=${app.name} is a Spring Boot application +bael.property=defaultValue +#--- +spring.config.activate.on-profile=prod +bael.property=prodValue \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java new file mode 100644 index 0000000000..61c76aef84 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java @@ -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"); + } +} diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java new file mode 100644 index 0000000000..39bc2da3ba --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java @@ -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"); + } +}