All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.harmonysoft.oss.redis.RedisTestEnvironment.kt Maven / Gradle / Ivy

There is a newer version: 3.5.0
Show newest version
package tech.harmonysoft.oss.redis

import jakarta.inject.Named
import tech.harmonysoft.oss.environment.TestContext
import tech.harmonysoft.oss.environment.TestEnvironment
import tech.harmonysoft.oss.redis.config.TestRedisConfig
import tech.harmonysoft.oss.redis.spi.RedisEnvironmentSpi

@Named
class RedisTestEnvironment(
    private val spi: RedisEnvironmentSpi,
    private val manager: TestRedisManager
) : TestEnvironment {

    override val id = spi.environmentId

    override val configClass = TestRedisConfig::class

    override fun isRunning(config: TestRedisConfig): Boolean {
        return try {
            manager.buildClient(config).get("test")
            true
        } catch (ignore: Exception) {
            false
        }
    }

    override fun start(context: TestContext): TestRedisConfig {
        return spi.start(context)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy