From 3039b4b2a7eb7963d0952a28ca5fd26328640223 Mon Sep 17 00:00:00 2001
From: Paul-Christian Volkmer
Date: Tue, 8 Aug 2023 13:23:18 +0200
Subject: Add basic Testcontainers test setup
---
.../etl/processor/AbstractTestcontainerTest.kt | 45 ++++++++++++++++++++++
.../etl/processor/BwhcMapperApplicationTests.kt | 37 ++++++++++++++++++
2 files changed, 82 insertions(+)
create mode 100644 src/test/kotlin/dev/dnpm/etl/processor/AbstractTestcontainerTest.kt
create mode 100644 src/test/kotlin/dev/dnpm/etl/processor/BwhcMapperApplicationTests.kt
(limited to 'src/test/kotlin')
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/AbstractTestcontainerTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/AbstractTestcontainerTest.kt
new file mode 100644
index 0000000..3bd934f
--- /dev/null
+++ b/src/test/kotlin/dev/dnpm/etl/processor/AbstractTestcontainerTest.kt
@@ -0,0 +1,45 @@
+/*
+ * This file is part of ETL-Processor
+ *
+ * Copyright (c) 2023 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package dev.dnpm.etl.processor
+
+import org.springframework.test.context.DynamicPropertyRegistry
+import org.springframework.test.context.DynamicPropertySource
+import org.testcontainers.containers.PostgreSQLContainer
+import org.testcontainers.junit.jupiter.Container
+
+abstract class AbstractTestcontainerTest {
+
+ companion object {
+ @Container
+ val dbContainer = PostgreSQLContainer("postgres:10-alpine")
+ .withDatabaseName("test")
+ .withUsername("test")
+ .withPassword("test") ?: throw RuntimeException("Failed to create testcontainer!")
+
+ @DynamicPropertySource
+ @JvmStatic
+ fun registerDynamicProperties(registry: DynamicPropertyRegistry) {
+ registry.add("spring.datasource.url", dbContainer::getJdbcUrl)
+ registry.add("spring.datasource.username", dbContainer::getUsername)
+ registry.add("spring.datasource.password", dbContainer::getPassword)
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/BwhcMapperApplicationTests.kt b/src/test/kotlin/dev/dnpm/etl/processor/BwhcMapperApplicationTests.kt
new file mode 100644
index 0000000..efa6a66
--- /dev/null
+++ b/src/test/kotlin/dev/dnpm/etl/processor/BwhcMapperApplicationTests.kt
@@ -0,0 +1,37 @@
+/*
+ * This file is part of ETL-Processor
+ *
+ * Copyright (c) 2023 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package dev.dnpm.etl.processor
+
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.extension.ExtendWith
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.test.context.junit.jupiter.SpringExtension
+import org.testcontainers.junit.jupiter.Testcontainers
+
+@Testcontainers
+@ExtendWith(SpringExtension::class)
+@SpringBootTest
+class BwhcMapperApplicationTests : AbstractTestcontainerTest() {
+
+ @Test
+ fun contextLoads() {
+ }
+
+}
--
cgit v1.2.3