From d4d75254181246fa288e4eb4e36e9e451da9303d Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 18 Oct 2023 20:13:22 +0300 Subject: [PATCH] Use separate Spring profile in integration tests. --- src/test/kotlin/fi/hsl/jore4/timetables/IntTest.kt | 14 ++++++++++++++ .../service/CombineTimetablesServiceTest.kt | 4 ++-- .../service/ReplaceTimetablesServiceTest.kt | 7 ++----- ...tion.properties => application-test.properties} | 2 -- 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 src/test/kotlin/fi/hsl/jore4/timetables/IntTest.kt rename src/test/resources/{application.properties => application-test.properties} (87%) diff --git a/src/test/kotlin/fi/hsl/jore4/timetables/IntTest.kt b/src/test/kotlin/fi/hsl/jore4/timetables/IntTest.kt new file mode 100644 index 00000000..069d9a37 --- /dev/null +++ b/src/test/kotlin/fi/hsl/jore4/timetables/IntTest.kt @@ -0,0 +1,14 @@ +package fi.hsl.jore4.timetables + +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles + +/** + * A custom annotation which configures integration tests which use the test database settings. + */ +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +@MustBeDocumented +@SpringBootTest +@ActiveProfiles("test") +annotation class IntTest diff --git a/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt b/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt index 113ef65a..394a71c7 100644 --- a/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt +++ b/src/test/kotlin/fi/hsl/jore4/timetables/service/CombineTimetablesServiceTest.kt @@ -1,6 +1,7 @@ package fi.hsl.jore4.timetables.service import fi.hsl.jore.jore4.jooq.vehicle_schedule.tables.pojos.VehicleScheduleFrame +import fi.hsl.jore4.timetables.IntTest import fi.hsl.jore4.timetables.TimetablesDataset import fi.hsl.jore4.timetables.enumerated.TimetablesPriority import fi.hsl.jore4.timetables.extensions.deepClone @@ -12,7 +13,6 @@ import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest import java.util.UUID import kotlin.test.assertContains import kotlin.test.assertEquals @@ -20,7 +20,7 @@ import kotlin.test.assertFailsWith import kotlin.test.assertNotNull import kotlin.test.assertNull -@SpringBootTest +@IntTest class CombineTimetablesServiceTest @Autowired constructor( val combineTimetablesService: CombineTimetablesService, var timetablesDataInserterRunner: TimetablesDataInserterRunner, diff --git a/src/test/kotlin/fi/hsl/jore4/timetables/service/ReplaceTimetablesServiceTest.kt b/src/test/kotlin/fi/hsl/jore4/timetables/service/ReplaceTimetablesServiceTest.kt index 0e2d1461..ee17dc8d 100644 --- a/src/test/kotlin/fi/hsl/jore4/timetables/service/ReplaceTimetablesServiceTest.kt +++ b/src/test/kotlin/fi/hsl/jore4/timetables/service/ReplaceTimetablesServiceTest.kt @@ -1,18 +1,17 @@ package fi.hsl.jore4.timetables.service import fi.hsl.jore.jore4.jooq.vehicle_schedule.tables.pojos.VehicleScheduleFrame +import fi.hsl.jore4.timetables.IntTest import fi.hsl.jore4.timetables.TimetablesDataset import fi.hsl.jore4.timetables.enumerated.TimetablesPriority import fi.hsl.jore4.timetables.extensions.deepClone import fi.hsl.jore4.timetables.extensions.getNested import fi.hsl.jore4.timetables.repository.VehicleScheduleFrameRepository -import mu.KotlinLogging import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest import java.time.LocalDate import java.util.UUID import kotlin.test.assertContains @@ -20,9 +19,7 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull -private val LOGGER = KotlinLogging.logger {} - -@SpringBootTest +@IntTest class ReplaceTimetablesServiceTest @Autowired constructor( val replaceTimetablesService: ReplaceTimetablesService, var timetablesDataInserterRunner: TimetablesDataInserterRunner, diff --git a/src/test/resources/application.properties b/src/test/resources/application-test.properties similarity index 87% rename from src/test/resources/application.properties rename to src/test/resources/application-test.properties index fa49ce2d..e83f7255 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application-test.properties @@ -4,5 +4,3 @@ jore4.db.username=@jore4.test.db.username@ jore4.db.password=@jore4.test.db.password@ jore4.db.minConnections=@jore4.test.db.min.connections@ jore4.db.maxConnections=@jore4.test.db.max.connections@ - -jooq.sql.dialect=@jooq.sql.dialect@