Skip to content

Commit

Permalink
fix(deps): update dependency com.github.tomakehurst:wiremock-jre8 to …
Browse files Browse the repository at this point in the history
…v3 (#200)

* fix(deps): update dependency com.github.tomakehurst:wiremock-jre8 to v3

* fix wiremock warnings

* fix wiremock warnings

* use wiremock standalone instead of wiremock since spring-boot jetty deps are affected by it

* remove unncessary overriding

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Oguzhan Soykan <[email protected]>
  • Loading branch information
renovate[bot] and osoykan authored Sep 7, 2023
1 parent 10cfed5 commit 1f1ca59
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TestSystemConfig : AbstractProjectConfig() {
WireMockSystemOptions(
port = 9090,
removeStubAfterRequestMatched = true,
afterRequest = { e, _, _ ->
afterRequest = { e, _ ->
logger.info(e.request.toString())
}
)
Expand Down
1 change: 0 additions & 1 deletion examples/spring-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
dependencies {
testImplementation(testLibs.kotest.property.jvm)
testImplementation(testLibs.kotest.runner.junit5)
testImplementation(testLibs.kotest.extensions.spring)
testImplementation(project(":lib:stove-testing-e2e"))
testImplementation(project(":lib:stove-testing-e2e-http"))
testImplementation(project(":lib:stove-testing-e2e-wiremock"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestSystemConfig : AbstractProjectConfig() {
WireMockSystemOptions(
port = 9099,
removeStubAfterRequestMatched = true,
afterRequest = { e, _, _ ->
afterRequest = { e, _ ->
logger.info(e.request.toString())
}
)
Expand Down
6 changes: 2 additions & 4 deletions gradle/libs-test.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ spring-boot = "2.7.15"
spring-kafka = "2.9.12"
junit = "5.10.0"
kotest = "5.7.2"
kotest-spring = "1.1.3"
mockito = "5.1.0"
wiremock = "2.35.1"
wiremock = "3.0.3"
testcontainers = "1.19.0"
ktor = "2.3.4"

Expand All @@ -20,8 +19,7 @@ junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jun
kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
kotest-property-jvm = { module = "io.kotest:kotest-property-jvm", version.ref = "kotest" }
kotest-framework-api-jvm = { module = "io.kotest:kotest-framework-api-jvm", version.ref = "kotest" }
kotest-extensions-spring = { module = "io.kotest.extensions:kotest-extensions-spring", version.ref = "kotest-spring" }
wiremock = { module = "com.github.tomakehurst:wiremock-jre8", version.ref = "wiremock" }
wiremock = { module = "org.wiremock:wiremock-standalone", version.ref = "wiremock" }
ktor-server-tests-jvm = { module = "io.ktor:ktor-server-tests-jvm", version.ref = "ktor" }
testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" }
testcontainers-jdbc = { module = "org.testcontainers:jdbc", version.ref = "testcontainers" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ data class WireMockSystemOptions(
/**
* Called after stub removed
*/
val afterStubRemoved: AfterStubRemoved = { _, _, _ -> },
val afterStubRemoved: AfterStubRemoved = { _, _ -> },

/**
* Called after request handled
*/
val afterRequest: AfterRequestHandler = { _, _, _ -> },
val afterRequest: AfterRequestHandler = { _, _ -> },

/**
* ObjectMapper for serialization/deserialization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.trendyol.stove.testing.e2e.wiremock

import com.github.tomakehurst.wiremock.core.Admin
import com.github.tomakehurst.wiremock.extension.PostServeAction
import com.github.tomakehurst.wiremock.extension.Parameters
import com.github.tomakehurst.wiremock.extension.ServeEventListener
import com.github.tomakehurst.wiremock.stubbing.ServeEvent
import com.github.tomakehurst.wiremock.stubbing.StubMapping
import java.util.UUID
import java.util.*
import java.util.concurrent.ConcurrentMap

class WireMockRequestListener(
private val stubLog: ConcurrentMap<UUID, StubMapping>,
private val afterRequest: AfterRequestHandler
) : PostServeAction() {
) : ServeEventListener {
override fun getName(): String = WireMockRequestListener::class.java.simpleName

override fun doGlobalAction(
serveEvent: ServeEvent,
admin: Admin
): Unit = afterRequest(serveEvent, admin, stubLog)
override fun beforeResponseSent(
serveEvent: ServeEvent?,
parameters: Parameters?
): Unit = afterRequest(serveEvent!!, stubLog)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder
import com.github.tomakehurst.wiremock.client.WireMock
import com.github.tomakehurst.wiremock.client.WireMock.aResponse
import com.github.tomakehurst.wiremock.client.WireMock.equalToJson
import com.github.tomakehurst.wiremock.core.Admin
import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import com.github.tomakehurst.wiremock.extension.Extension
import com.github.tomakehurst.wiremock.matching.ContainsPattern
Expand All @@ -22,14 +21,14 @@ import com.trendyol.stove.testing.e2e.system.abstractions.PluggedSystem
import com.trendyol.stove.testing.e2e.system.abstractions.RunAware
import com.trendyol.stove.testing.e2e.system.abstractions.ValidatedSystem
import kotlinx.coroutines.runBlocking
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import wiremock.org.slf4j.Logger
import wiremock.org.slf4j.LoggerFactory
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap

typealias AfterStubRemoved = (ServeEvent, Admin, ConcurrentMap<UUID, StubMapping>) -> Unit
typealias AfterRequestHandler = (ServeEvent, Admin, ConcurrentMap<UUID, StubMapping>) -> Unit
typealias AfterStubRemoved = (ServeEvent, ConcurrentMap<UUID, StubMapping>) -> Unit
typealias AfterRequestHandler = (ServeEvent, ConcurrentMap<UUID, StubMapping>) -> Unit

class WireMockSystem(
override val testSystem: TestSystem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.trendyol.stove.testing.e2e.wiremock

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.core.Admin
import com.github.tomakehurst.wiremock.extension.PostServeAction
import com.github.tomakehurst.wiremock.extension.Parameters
import com.github.tomakehurst.wiremock.extension.ServeEventListener
import com.github.tomakehurst.wiremock.stubbing.ServeEvent
import com.github.tomakehurst.wiremock.stubbing.StubMapping
import com.trendyol.stove.functional.Try
import com.trendyol.stove.functional.recover
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.util.UUID
import wiremock.org.slf4j.Logger
import wiremock.org.slf4j.LoggerFactory
import java.util.*
import java.util.concurrent.ConcurrentMap

class WireMockVacuumCleaner(
private val stubLog: ConcurrentMap<UUID, StubMapping>,
private val afterStubRemoved: AfterStubRemoved
) : PostServeAction() {
) : ServeEventListener {

private lateinit var wireMock: WireMockServer
private val logger: Logger = LoggerFactory.getLogger(javaClass)
Expand All @@ -25,10 +25,7 @@ class WireMockVacuumCleaner(
this.wireMock = wireMockServer
}

override fun doGlobalAction(
serveEvent: ServeEvent,
admin: Admin
) {
override fun beforeResponseSent(serveEvent: ServeEvent, parameters: Parameters?) {
if (!serveEvent.wasMatched) {
return
}
Expand All @@ -45,7 +42,7 @@ class WireMockVacuumCleaner(
synchronized(stubLog) {
stubLog.remove(serveEvent.stubMapping.id)
}
afterStubRemoved(serveEvent, admin, stubLog)
afterStubRemoved(serveEvent, stubLog)
}
}.recover { throwable -> logger.warn(throwable.message) }
}
Expand Down

0 comments on commit 1f1ca59

Please sign in to comment.