update postgres test container
- update README.md - update PostgresContainer - add TestExecutionListeners - remove ExtendWith - update PostgresInitializer - cleanup - use properties for script and container - add afterTestClass - add beforeTestClass - extend TestExecutionListener - remove PostgresExtension - add debug logging to PostgresExecutor - add ContainerUtils - add dependencies - extract function from PostgresExtension to PostgresExecutor
This commit is contained in:
26
src/main/kotlin/ltd/hlaeja/test/util/ContainerUtil.kt
Normal file
26
src/main/kotlin/ltd/hlaeja/test/util/ContainerUtil.kt
Normal file
@@ -0,0 +1,26 @@
|
||||
package ltd.hlaeja.test.util
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext
|
||||
import org.springframework.core.io.ClassPathResource
|
||||
import org.springframework.test.context.TestContext
|
||||
|
||||
fun ConfigurableApplicationContext.getProperty(
|
||||
property: String,
|
||||
): String? = this.environment.getProperty(property)
|
||||
|
||||
fun ConfigurableApplicationContext.getProperty(
|
||||
property: String,
|
||||
default: String,
|
||||
): String = this.environment.getProperty(property, default)
|
||||
|
||||
fun TestContext.getProperty(
|
||||
property: String,
|
||||
): String? = this.applicationContext.environment.getProperty(property)
|
||||
|
||||
fun String.isResourceFile(): ClassPathResource? {
|
||||
val resource = ClassPathResource(this)
|
||||
return when {
|
||||
resource.exists() && resource.isReadable -> resource
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user