Last active
June 16, 2019 00:29
-
-
Save schrepfler/c40088c086664df502029002e518c032 to your computer and use it in GitHub Desktop.
Scala testcontainers Cassandra wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.dimafeng.testcontainers.SingleContainer | |
import org.testcontainers.containers.{CassandraContainer => OTCCassandraContainer, GenericContainer => OTCGenericContainer} | |
class CassandraContainer(dockerImageNameOverride: Option[String] = None, | |
configurationOverride: Option[String] = None, | |
initScript: Option[String] = None, | |
jmxReporting: Boolean = false) extends SingleContainer[OTCCassandraContainer[_]] { | |
type OTCContainer = OTCGenericContainer[T] forSome {type T <: OTCCassandraContainer[T]} | |
var cassandraContainer: OTCCassandraContainer[Nothing] = null | |
if (dockerImageNameOverride.isEmpty) { | |
cassandraContainer = new OTCCassandraContainer() | |
} else { | |
cassandraContainer = new OTCCassandraContainer(dockerImageNameOverride.get) | |
} | |
if (configurationOverride.isDefined) cassandraContainer.withConfigurationOverride(configurationOverride.get) | |
if (initScript.isDefined) cassandraContainer.withConfigurationOverride(initScript.get) | |
if (jmxReporting) cassandraContainer.withJmxReporting(jmxReporting) | |
override val container: OTCCassandraContainer[_] = cassandraContainer | |
} | |
object CassandraContainer { | |
def apply(dockerImageNameOverride: String = null, | |
configurationOverride: String = null, | |
initScript: String = null, | |
jmxReporting: Boolean = false) = new CassandraContainer( | |
Option(dockerImageNameOverride), | |
Option(configurationOverride), | |
Option(initScript), | |
jmxReporting | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment