JAVA-8356: split or move spring-boot-properties

This commit is contained in:
chaos2418
2022-01-14 13:33:39 +05:30
parent 5416fc95b2
commit c55e569096
9 changed files with 18 additions and 17 deletions
@@ -0,0 +1,30 @@
package com.baeldung.configuration.processor;
import org.junit.jupiter.api.Assertions;
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)
@TestPropertySource("/configuration-processor.properties")
@SpringBootTest(classes = DemoApplication.class)
class PropertyBeanInjectionUnitTest {
@Autowired
private PropertyBeanInjection propertyBeanInjection;
@Test
void checkThatJdbcPropertiesHaveTheCorrectValueFromPropertiesFile() {
Assertions.assertEquals("jdbc:postgresql:/localhost:5432", propertyBeanInjection.getJdbcUrl());
}
@Test
void checkThatCustomPropertiesHaveTheCorrectValueFromPropertiesFile() {
Assertions.assertEquals("www.abc.test.com", propertyBeanInjection.getUrl());
Assertions.assertEquals(2000, propertyBeanInjection.getTimeoutInMilliseconds());
}
}
@@ -0,0 +1,3 @@
com.baeldung.url=www.abc.test.com
com.baeldung.jdbc.url=
com.baeldung.timeout-in-milli-seconds=2000