From 2c633c9ea7c1a28cb27337b8dc58969e0018fff5 Mon Sep 17 00:00:00 2001 From: Robert Mathew Date: Wed, 10 Jul 2024 12:35:59 +0530 Subject: [PATCH] Added Test container --- gradle/libs.versions.toml | 3 +++ modules/admin-server/build.gradle.kts | 3 +++ .../oid/fed/server/admin/DatabaseTest.kt | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7a25a76a..8f8f7c66 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,6 +37,9 @@ springboot-data-jdbc = { group = "org.springframework.boot", name = "spring-boot springboot-devtools = { group = "org.springframework.boot", name = "spring-boot-devtools" } springboot-test = { group = "org.springframework.boot", name = "spring-boot-starter-test" } postgres = { module = "org.postgresql:postgresql" } +springboot-testcontainer = { group = "org.springframework.boot", name = "spring-boot-testcontainers"} +testcontainer-postgres = { group = "org.testcontainers", name = "postgresql"} +testcontainer-junit = { group = "org.testcontainers", name = "junit-jupiter"} [plugins] androidApplication = { id = "com.android.application", version.ref = "agp" } diff --git a/modules/admin-server/build.gradle.kts b/modules/admin-server/build.gradle.kts index b1def3cc..b43c23cc 100644 --- a/modules/admin-server/build.gradle.kts +++ b/modules/admin-server/build.gradle.kts @@ -21,6 +21,9 @@ dependencies { implementation(libs.springboot.data.jdbc) implementation(libs.kotlin.reflect) testImplementation(libs.springboot.test) + testImplementation(libs.testcontainer.junit) + testImplementation(libs.springboot.testcontainer) + testImplementation(libs.testcontainer.postgres) runtimeOnly(libs.postgres) runtimeOnly(libs.springboot.devtools) } diff --git a/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt new file mode 100644 index 00000000..2c8b2b94 --- /dev/null +++ b/modules/admin-server/src/test/kotlin/com/sphereon/oid/fed/server/admin/DatabaseTest.kt @@ -0,0 +1,18 @@ +package com.sphereon.oid.fed.server.admin + +import org.junit.jupiter.api.Test +import org.testcontainers.containers.PostgreSQLContainer +import org.testcontainers.junit.jupiter.Container +import org.testcontainers.junit.jupiter.Testcontainers + +@Testcontainers +class DatabaseTest { + + @Container + val postgres: PostgreSQLContainer<*> = PostgreSQLContainer("postgres:14") + + @Test + fun `test database connection`() { + assert(postgres.isRunning) + } +} \ No newline at end of file