BAEL-3756-YAML-for-Spring-DevOps (#9368)
* Add modifications to include the configuration for YAML and DevOps * Clean the Dockerfile * Modify the name of testing environment and include YAML tests
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
spring:
|
||||
profiles:
|
||||
active:
|
||||
- test
|
||||
|
||||
---
|
||||
|
||||
spring:
|
||||
profiles: test
|
||||
name: test-YAML
|
||||
environment: test
|
||||
environment: testing
|
||||
servers:
|
||||
- www.abc.test.com
|
||||
- www.xyz.test.com
|
||||
@@ -15,3 +22,13 @@ environment: production
|
||||
servers:
|
||||
- www.abc.com
|
||||
- www.xyz.com
|
||||
|
||||
---
|
||||
|
||||
spring:
|
||||
profiles: dev
|
||||
name: ${DEV_NAME:dev-YAML}
|
||||
environment: development
|
||||
servers:
|
||||
- www.abc.dev.com
|
||||
- www.xyz.dev.com
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.yaml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = MyApplication.class)
|
||||
@TestPropertySource(properties = {"spring.profiles.active = dev"})
|
||||
class YAMLDevIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private YAMLConfig config;
|
||||
|
||||
@Test
|
||||
void whenProfileTest_thenNameTesting() {
|
||||
assertTrue("development".equalsIgnoreCase(config.getEnvironment()));
|
||||
assertTrue("dev-YAML".equalsIgnoreCase(config.getName()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.baeldung.yaml;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = MyApplication.class)
|
||||
class YAMLIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private YAMLConfig config;
|
||||
|
||||
@Test
|
||||
void whenProfileTest_thenNameTesting() {
|
||||
assertTrue("testing".equalsIgnoreCase(config.getEnvironment()));
|
||||
assertTrue("test-YAML".equalsIgnoreCase(config.getName()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user