|
|
|
|
@ -38,7 +38,7 @@ class KotlinConfigurationPropertiesTests {
@@ -38,7 +38,7 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
@AfterEach |
|
|
|
|
fun cleanUp() { |
|
|
|
|
this.context.close(); |
|
|
|
|
this.context.close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test //gh-18652 |
|
|
|
|
@ -48,22 +48,22 @@ class KotlinConfigurationPropertiesTests {
@@ -48,22 +48,22 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
RootBeanDefinition(BingProperties::class.java)) |
|
|
|
|
beanFactory.registerSingleton("foo", BingProperties("")) |
|
|
|
|
this.context.register(EnableConfigProperties::class.java) |
|
|
|
|
this.context.refresh(); |
|
|
|
|
this.context.refresh() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `type with constructor bound lateinit property can be bound`() { |
|
|
|
|
this.context.register(EnableLateInitProperties::class.java) |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "lateinit.inner.value=alpha"); |
|
|
|
|
this.context.refresh(); |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "lateinit.inner.value=alpha") |
|
|
|
|
this.context.refresh() |
|
|
|
|
assertThat(this.context.getBean(LateInitProperties::class.java).inner.value).isEqualTo("alpha") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
fun `type with constructor bound lateinit property with default can be bound`() { |
|
|
|
|
this.context.register(EnableLateInitPropertiesWithDefault::class.java) |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "lateinit-with-default.inner.bravo=two"); |
|
|
|
|
this.context.refresh(); |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "lateinit-with-default.inner.bravo=two") |
|
|
|
|
this.context.refresh() |
|
|
|
|
val properties = this.context.getBean(LateInitPropertiesWithDefault::class.java) |
|
|
|
|
assertThat(properties.inner.alpha).isEqualTo("apple") |
|
|
|
|
assertThat(properties.inner.bravo).isEqualTo("two") |
|
|
|
|
@ -72,20 +72,16 @@ class KotlinConfigurationPropertiesTests {
@@ -72,20 +72,16 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
@Test |
|
|
|
|
fun `mutable data class properties can be imported`() { |
|
|
|
|
this.context.register(MutableDataClassPropertiesImporter::class.java) |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "mutable.prop=alpha"); |
|
|
|
|
this.context.refresh(); |
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "mutable.prop=alpha") |
|
|
|
|
this.context.refresh() |
|
|
|
|
assertThat(this.context.getBean(MutableDataClassProperties::class.java).prop).isEqualTo("alpha") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(prefix = "foo") |
|
|
|
|
class BingProperties(@Suppress("UNUSED_PARAMETER") bar: String) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
class BingProperties(@Suppress("UNUSED_PARAMETER") bar: String) |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties |
|
|
|
|
class EnableConfigProperties { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
class EnableConfigProperties |
|
|
|
|
|
|
|
|
|
@ConfigurationProperties("lateinit") |
|
|
|
|
class LateInitProperties { |
|
|
|
|
@ -97,9 +93,7 @@ class KotlinConfigurationPropertiesTests {
@@ -97,9 +93,7 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
data class Inner(val value: String) |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties(LateInitPropertiesWithDefault::class) |
|
|
|
|
class EnableLateInitPropertiesWithDefault { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
class EnableLateInitPropertiesWithDefault |
|
|
|
|
|
|
|
|
|
@ConfigurationProperties("lateinit-with-default") |
|
|
|
|
class LateInitPropertiesWithDefault { |
|
|
|
|
@ -111,15 +105,12 @@ class KotlinConfigurationPropertiesTests {
@@ -111,15 +105,12 @@ class KotlinConfigurationPropertiesTests {
|
|
|
|
|
data class InnerWithDefault(val alpha: String = "apple", val bravo: String = "banana") |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties(LateInitProperties::class) |
|
|
|
|
class EnableLateInitProperties { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
class EnableLateInitProperties |
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties |
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|
@Import(MutableDataClassProperties::class) |
|
|
|
|
class MutableDataClassPropertiesImporter { |
|
|
|
|
} |
|
|
|
|
class MutableDataClassPropertiesImporter |
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(prefix = "mutable") |
|
|
|
|
data class MutableDataClassProperties( |
|
|
|
|
|