Skip to content

Commit

Permalink
Oppdater build.gradle.kts (#248)
Browse files Browse the repository at this point in the history
* Rename til FellesTestOppsett

* Bump Testcontainers

* Oppdater build.gradle.kts

* Riktig Testcontainer

* Sorter build.gradle.kts
  • Loading branch information
nilsjorgen authored Feb 13, 2024
1 parent def8d0d commit e03dc06
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
46 changes: 25 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "3.2.2"
Expand All @@ -21,7 +21,7 @@ repositories {
}
}

ext["okhttp3.version"] = "4.9.3" // Token-support tester trenger Mockwebserver.
ext["okhttp3.version"] = "4.12" // Token-support tester trenger MockWebServer.

val testContainersVersion = "1.19.4"
val tokenSupportVersion = "4.1.3"
Expand All @@ -40,19 +40,17 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.hibernate.validator:hibernate-validator")
implementation("org.springframework.kafka:spring-kafka")
implementation("org.springframework.retry:spring-retry")
implementation("org.slf4j:slf4j-api")
implementation("org.flywaydb:flyway-core")
implementation("org.postgresql:postgresql")
implementation("org.flywaydb:flyway-core")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.aspectj:aspectjrt")
implementation("org.aspectj:aspectjweaver")
implementation("org.hibernate.validator:hibernate-validator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("net.logstash.logback:logstash-logback-encoder:$logstashLogbackEncoderVersion")
implementation("no.nav.security:token-client-spring:$tokenSupportVersion")
implementation("no.nav.security:token-validation-spring:$tokenSupportVersion")
implementation("net.logstash.logback:logstash-logback-encoder:$logstashLogbackEncoderVersion")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.openhtmltopdf:openhtmltopdf-pdfbox:$openHtmlToPdfVersion")
implementation("com.openhtmltopdf:openhtmltopdf-slf4j:$openHtmlToPdfVersion")
implementation("com.openhtmltopdf:openhtmltopdf-svg-support:$openHtmlToPdfVersion")
Expand All @@ -63,31 +61,37 @@ dependencies {

testImplementation(platform("org.testcontainers:testcontainers-bom:$testContainersVersion"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testcontainers:kafka")
testImplementation("org.testcontainers:postgresql")
testImplementation("org.testcontainers:kafka")
testImplementation("org.awaitility:awaitility")
testImplementation("no.nav.security:token-validation-spring-test:$tokenSupportVersion")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion")
testImplementation("org.amshove.kluent:kluent:$kluentVersion")
}

tasks.getByName<org.springframework.boot.gradle.tasks.bundling.BootJar>("bootJar") {
this.archiveFileName.set("app.jar")
}

tasks.withType<KotlinCompile> {
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.add("-Xjsr305=strict")

if (System.getenv("CI") == "true") {
allWarningsAsErrors.set(true)
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("STANDARD_OUT", "STARTED", "PASSED", "FAILED", "SKIPPED")

tasks {
test {
useJUnitPlatform()
jvmArgs("-XX:+EnableDynamicAgentLoading")
testLogging {
events("PASSED", "FAILED", "SKIPPED")
exceptionFormat = TestExceptionFormat.FULL
}
failFast = false
}
}

tasks {
bootJar {
archiveFileName = "app.jar"
}
}
2 changes: 1 addition & 1 deletion src/test/kotlin/no/nav/helse/flex/ApplicationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package no.nav.helse.flex

import org.junit.jupiter.api.Test

class ApplicationTest : Testoppsett() {
class ApplicationTest : FellesTestOppsett() {
@Test
fun contextLoads() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import org.testcontainers.containers.PostgreSQLContainer
import org.testcontainers.utility.DockerImageName
import org.verapdf.gf.foundry.VeraGreenfieldFoundryProvider

private class PostgreSQLContainer12 : PostgreSQLContainer<PostgreSQLContainer12>("postgres:12-alpine")
private class PostgreSQLContainer14 : PostgreSQLContainer<PostgreSQLContainer14>("postgres:14-alpine")

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@SpringBootTest
@EnableMockOAuth2Server
@AutoConfigureMockMvc
abstract class Testoppsett {
abstract class FellesTestOppsett {
@Autowired
lateinit var arkivertVedtakRepository: ArkivertVedtakRepository

Expand All @@ -34,14 +34,14 @@ abstract class Testoppsett {
init {
VeraGreenfieldFoundryProvider.initialise()

PostgreSQLContainer12().also {
PostgreSQLContainer14().also {
it.start()
System.setProperty("spring.datasource.url", it.jdbcUrl)
System.setProperty("spring.datasource.username", it.username)
System.setProperty("spring.datasource.password", it.password)
}

KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.1")).also {
KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.5.3")).also {
it.start()
System.setProperty("KAFKA_BROKERS", it.bootstrapServers)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import java.time.Instant
import java.time.OffsetDateTime
import java.time.ZoneId

class HentingOgPdfGenereringTest : Testoppsett() {
class HentingOgPdfGenereringTest : FellesTestOppsett() {
@Autowired
lateinit var arkivaren: PdfSkaperen

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/no/nav/helse/flex/IntegrasjonTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import java.util.*
import java.util.concurrent.TimeUnit

@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class IntegrasjonTest : Testoppsett() {
class IntegrasjonTest : FellesTestOppsett() {
@Autowired
lateinit var kafkaProducer: KafkaProducer<String, String>

Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/no/nav/helse/flex/PdfTestHjelperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired
import java.io.File
import java.time.OffsetDateTime

class PdfTestHjelperTest : Testoppsett() {
class PdfTestHjelperTest : FellesTestOppsett() {
@Autowired
lateinit var arkivaren: PdfSkaperen

Expand Down

0 comments on commit e03dc06

Please sign in to comment.