MysqlKontainer
class MysqlKontainer(kontainerSpec: KontainerSpec, delegate: PlatformKontainer) : GenericTcpKontainer, JdbcKontainer
Content copied to clipboard
Provides a Kontainer for MySQL.
Author
Scott Rossillo
Samples
import io.microkt.kontainers.junit5.annotation.Kontainers
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Tags
import org.junit.jupiter.api.Test
import java.sql.Statement
import javax.sql.DataSource
fun main() {
//sampleStart
@Kontainers
@Tags(
Tag("docker"),
Tag("kubernetes")
)
internal class MysqlKontainerTest(private val mysql: MysqlKontainer) {
private var dataSource: DataSource = buildHikariDataSource(mysql)
@Test
fun testQuery() {
val statement: Statement = dataSource.connection.createStatement()
statement.execute("SELECT 1")
val resultSet = statement.resultSet
resultSet.next()
val resultInt = resultSet.getInt(1)
assertEquals(1, resultInt, "SELECT 1; should return 1")
}
@Test
fun testValidPort() {
assertNotNull(mysql.getPort(mysqlKontainerSpec.ports.first().port))
}
}
//sampleEnd
}Constructors
Link copied to clipboard
fun MysqlKontainer(kontainerSpec: KontainerSpec, delegate: PlatformKontainer)
Content copied to clipboard
Creates a new MysqlKontainer with the given kontainerSpec and parent Kontainer.
Types
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Waits for the TCP socket to be ready and delays an extra 10 seconds for MySQL to configure and restart itself.