pl.beone.lib.junit.jupiter.internal.Configuration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-extension-junit5 Show documentation
Show all versions of docker-extension-junit5 Show documentation
pl.beone.lib:docker-extension-junit5
package pl.beone.lib.junit.jupiter.internal
import org.testcontainers.shaded.org.apache.commons.lang.text.StrSubstitutor
import pl.beone.lib.typeconverter.internal.castOrConvert
import java.util.*
class Configuration {
private val baseProperties = Properties().apply {
load("/docker-extension.properties")
}
private val strSubstitutor = StrSubstitutor(baseProperties)
private fun Properties.load(resourcePath: String) {
Configuration::class.java.getResourceAsStream(resourcePath)
?.let { load(it) }
}
fun getProperty(key: String): String =
strSubstitutor.replace(baseProperties.getProperty(key) ?: throw NoSuchElementException("There is no <$key> element"))
fun getProperty(key: String, clazz: Class): T =
getProperty(key).castOrConvert(clazz)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy