|
|
|
|
@ -26,11 +26,13 @@ import org.springframework.context.annotation.Import
@@ -26,11 +26,13 @@ import org.springframework.context.annotation.Import
|
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils |
|
|
|
|
|
|
|
|
|
import org.assertj.core.api.Assertions.assertThat |
|
|
|
|
import org.springframework.boot.context.properties.bind.Name |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Tests for {@link ConfigurationProperties @ConfigurationProperties}-annotated beans. |
|
|
|
|
* |
|
|
|
|
* @author Madhura Bhave |
|
|
|
|
* @author Lasse Wulff |
|
|
|
|
*/ |
|
|
|
|
class KotlinConfigurationPropertiesTests { |
|
|
|
|
|
|
|
|
|
@ -59,6 +61,14 @@ class KotlinConfigurationPropertiesTests {
@@ -59,6 +61,14 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
assertThat(this.context.getBean(LateInitProperties::class.java).inner.value).isEqualTo("alpha") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `renamed property can be bound to late init attribute`() { |
|
|
|
|
this.context.register(EnableRenamedLateInitProperties::class.java) |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "renamed.var=beta") |
|
|
|
|
this.context.refresh() |
|
|
|
|
assertThat(this.context.getBean(RenamedLateInitProperties::class.java).bar).isEqualTo("beta") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `type with constructor bound lateinit property with default can be bound`() { |
|
|
|
|
this.context.register(EnableLateInitPropertiesWithDefault::class.java) |
|
|
|
|
@ -80,6 +90,15 @@ class KotlinConfigurationPropertiesTests {
@@ -80,6 +90,15 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
@ConfigurationProperties(prefix = "foo") |
|
|
|
|
class BingProperties(@Suppress("UNUSED_PARAMETER") bar: String) |
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(prefix = "renamed") |
|
|
|
|
class RenamedLateInitProperties{ |
|
|
|
|
@Name("var") |
|
|
|
|
lateinit var bar: String |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties(RenamedLateInitProperties::class) |
|
|
|
|
class EnableRenamedLateInitProperties |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties |
|
|
|
|
class EnableConfigProperties |
|
|
|
|
|
|
|
|
|
|