improved and updated spring-boot-yaml-vs-properties article code
This commit is contained in:
+5
-1
@@ -10,13 +10,17 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import com.baeldung.boot.properties.DemoApplication;
|
||||
|
||||
@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK)
|
||||
public class DefaultMultidocumentPropertiesFileIntegrationTest {
|
||||
public class DefaultMultidocumentFilesIntegrationTest {
|
||||
|
||||
@Value("${bael.property}")
|
||||
private String baelCustomProperty;
|
||||
|
||||
@Value("${bael.root-level-property}")
|
||||
private String baelRootProperty;
|
||||
|
||||
@Test
|
||||
public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||
assertThat(baelCustomProperty).isEqualTo("defaultValue");
|
||||
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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("multidocument-dev")
|
||||
public class DevMultidocumentFilesIntegrationTest {
|
||||
|
||||
@Value("${bael.property}")
|
||||
private String baelCustomProperty;
|
||||
|
||||
@Value("${bael.root-level-property}")
|
||||
private String baelRootProperty;
|
||||
|
||||
@Test
|
||||
public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||
assertThat(baelCustomProperty).isEqualTo("devValue");
|
||||
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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("multidocument-integration")
|
||||
public class IntegrationMultidocumentFilesIntegrationTest {
|
||||
|
||||
@Value("${bael.property}")
|
||||
private String baelCustomProperty;
|
||||
|
||||
@Value("${bael.root-level-property}")
|
||||
private String baelRootProperty;
|
||||
|
||||
@Test
|
||||
public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||
assertThat(baelCustomProperty).isEqualTo("integrationValue");
|
||||
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -11,14 +11,18 @@ import org.springframework.test.context.ActiveProfiles;
|
||||
import com.baeldung.boot.properties.DemoApplication;
|
||||
|
||||
@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK)
|
||||
@ActiveProfiles("prod")
|
||||
public class ProdMultidocumentPropertiesFileIntegrationTest {
|
||||
@ActiveProfiles("multidocument-prod")
|
||||
public class ProdMultidocumentFilesIntegrationTest {
|
||||
|
||||
@Value("${bael.property}")
|
||||
private String baelCustomProperty;
|
||||
|
||||
@Value("${bael.root-level-property}")
|
||||
private String baelRootProperty;
|
||||
|
||||
@Test
|
||||
public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||
assertThat(baelCustomProperty).isEqualTo("prodValue");
|
||||
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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("multidocument-staging")
|
||||
public class StagingMultidocumentFilesIntegrationTest {
|
||||
|
||||
@Value("${bael.property}")
|
||||
private String baelCustomProperty;
|
||||
|
||||
@Value("${bael.root-level-property}")
|
||||
private String baelRootProperty;
|
||||
|
||||
@Test
|
||||
public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
|
||||
assertThat(baelCustomProperty).isEqualTo("stagingValue");
|
||||
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user