Add Kotlin documentation and tests for @DynamicPropertySource

See gh-24540
This commit is contained in:
Sébastien Deleuze
2020-03-24 09:59:34 +01:00
parent 2209e7cb92
commit 60dca027e7
2 changed files with 89 additions and 0 deletions

View File

@@ -4010,6 +4010,31 @@ via `@Value("${redis.host}")` and `@Value("${redis.port}")`, respectively.
}
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@SpringJUnitConfig(/* ... */)
@Testcontainers
class ExampleIntegrationTests {
companion object {
@Container
@JvmStatic
val redis: RedisContainer = RedisContainer()
@DynamicPropertySource
@JvmStatic
fun redisProperties(registry: DynamicPropertyRegistry) {
registry.add("redis.host", redis::getContainerIpAddress)
registry.add("redis.port", redis::getMappedPort)
}
}
// tests ...
}
----
[[testcontext-ctx-management-web]]
===== Loading a `WebApplicationContext`