com.dimafeng.testcontainers.MSSQLServerContainer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testcontainers-scala-mssqlserver_3 Show documentation
Show all versions of testcontainers-scala-mssqlserver_3 Show documentation
testcontainers-scala-mssqlserver
package com.dimafeng.testcontainers
import org.testcontainers.containers.{MSSQLServerContainer => JavaMSSQLServerContainer}
import org.testcontainers.utility.DockerImageName
import scala.concurrent.duration._
case class MSSQLServerContainer(
dockerImageName: DockerImageName = DockerImageName.parse(MSSQLServerContainer.defaultDockerImageName),
dbPassword: String = MSSQLServerContainer.defaultPassword,
urlParams: Map[String, String] = Map.empty,
commonJdbcParams: JdbcDatabaseContainer.CommonParams = MSSQLServerContainer.defaultCommonJdbcParams
) extends SingleContainer[JavaMSSQLServerContainer[_]] with JdbcDatabaseContainer {
override val container: JavaMSSQLServerContainer[_] = {
val c: JavaMSSQLServerContainer[_] = new JavaMSSQLServerContainer(dockerImageName)
c.withPassword(dbPassword)
urlParams.foreach { case (key, value) =>
c.withUrlParam(key, value)
}
commonJdbcParams.applyTo(c)
c
}
def testQueryString: String = container.getTestQueryString
}
object MSSQLServerContainer {
val defaultDockerImageName = s"${JavaMSSQLServerContainer.IMAGE}:${JavaMSSQLServerContainer.DEFAULT_TAG}"
val defaultPassword = "A_Str0ng_Required_Password"
val defaultCommonJdbcParams: JdbcDatabaseContainer.CommonParams = JdbcDatabaseContainer.CommonParams().copy(
startupTimeout = 240.seconds,
connectTimeout = 240.seconds
)
case class Def(
dockerImageName: DockerImageName = DockerImageName.parse(MSSQLServerContainer.defaultDockerImageName),
password: String = MSSQLServerContainer.defaultPassword,
urlParams: Map[String, String] = Map.empty,
commonJdbcParams: JdbcDatabaseContainer.CommonParams = MSSQLServerContainer.defaultCommonJdbcParams
) extends ContainerDef {
override type Container = MSSQLServerContainer
override def createContainer(): MSSQLServerContainer = {
new MSSQLServerContainer(
dockerImageName = dockerImageName,
dbPassword = password,
urlParams = urlParams,
commonJdbcParams = commonJdbcParams
)
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy