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:
2025-03-10 17:41:18 +01:00
parent 902a2a2c0b
commit 6aad7e3d63
7 changed files with 146 additions and 98 deletions

View 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
}
}