Questions tagged [wiremock]

Library used for stubbing and mocking web services.

Wiremock is a library written in Java by Tom Akehurst. It is used for stubbing and mocking web services. It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection, and can be used from within a unit test or deployed into a test environment.

For more information see http://wiremock.org

894 questions
2
votes
2 answers

Remove/disable wiremock stub when it was called one time

I create a stub in Wiremock using this code: getWiremock().stubFor(get(urlMatching("/rs-queue/messages.*")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") …
alexey kurbatov
  • 117
  • 4
  • 10
2
votes
1 answer

Overcoming lack of SocketUtils in Spring Boot 3

I'm preparing to the migration of a Spring Boot service to Spring Boot 3 (I'm trying version 3.0.0-RC1) and unfortunately I'm facing the lack of SocketUtils that has been removed. This means that some libraries that I'm using for testing (e.g.…
Gilberto T.
  • 358
  • 6
  • 19
2
votes
0 answers

Wiremock isn't intercepting okhttp3 call in junit5

When using wiremock to (ty to) intercept and mock calls via okhttp3, it seems that it either doesn't get the call from okhttp or simply makes a passthrough I followed the basic setup from the wiremock website and have the following test…
Rohde Fischer
  • 1,248
  • 2
  • 10
  • 32
2
votes
2 answers

How to check that value of field in request body is json using Wiremock

I have a JSON request and I need to check that the value of one field is json. I'm trying use regex: "request": { ... "bodyPatterns": [ { "equalToJson": { "field_1": "Value", "field_2":…
lojz
  • 23
  • 4
2
votes
0 answers

Wiremock matchesJSONPath if null or empty

I'm trying to add a Wiremock stub that matches if the JSON in a request body is either non-existent OR an empty string. The stub I have at the moment is: { "id" : "e331007e-3e6d-4660-b575-b04e774e88c6", "request" : { "urlPathPattern" :…
Pezholio
  • 2,439
  • 5
  • 27
  • 41
2
votes
1 answer

Wiremock - Connection Refused - JUnit5

I have a stub that I can see under /__admin/ but when making any sort of rest calls nothing registers in either __admin/requests or __admin/requests/unmatched which I feel is strange. Is Wiremock failing to intercept the request? Simplified…
David S
  • 195
  • 5
  • 19
2
votes
1 answer

How to run "--verbose" for wiremock in docker compose file

I want to get verbose output from mockwire when running in docker using docker compose file. I tried these three ways but none of them work. first way services: wiremock: image: wiremock ports: - 8080:8080 restart: always …
2
votes
1 answer

Wiremock request matching with dynamic date - How to check a date in test?

I need to check in my test, that the date in request is exactly Today. How can I do this? Tried different ways from the Doc, but haven't got the desired result. Help please a poor junior qa :) What way I tried (my collegue advised me this one, and…
2
votes
2 answers

How to get to a WireMockServer from Junit 5 WireMockTest test case

Wire mock has a addMockServiceRequestListener function available on the JUnit4 Rule or on a wiremock server instance. How do I get to that function from a test class annotated with JUnit 5's @WireMockTest annotation? More generally, how do I get an…
Gonen I
  • 5,576
  • 1
  • 29
  • 60
2
votes
0 answers

Is there a way to define a Wiremock stub and the verification of the stub at the same time?

As far as I can tell, the standard Wiremock approach is to define stubs and verify the stub invocations separately, which entails duplicating the defined behavior of the endpoint, via something like rule.stubFor(get(url).withHeader("Content-Type",…
cbmanica
  • 3,502
  • 7
  • 36
  • 54
2
votes
1 answer

Could not initialize class com.github.tomakehurst.wiremock.core.WireMockApp

I recently upgraded my Java version to Java11 for 8 and since then i am seeing this error: java.lang.NoClassDefFoundError: Could not initialize class com.github.tomakehurst.wiremock.core.WireMockApp at…
2
votes
0 answers

MbTest(MounteBank) vs WireMock vs Mock-server vs anyother for encrypted payload

we need to decide a mock-server for our applications. We have an ask in which the applications sends encrypted payload in request and response . that encryption is using rsa so the encrypted string changes for same payload so it is not possible to…
2
votes
1 answer

Wiremock - Mocking a reactive backend

Is it possible to use Wiremock to mock a reactive backend. What I want to do is make Wiremock return chunked responses but each chunk should be a valid json string (something that mimics a reactor Flux type response). The scenario is something like…
thisisshantzz
  • 1,067
  • 3
  • 13
  • 33
2
votes
0 answers

Wiremock/Mockserver with custom Domain Name?

I'm trying to do a test where my client allows the use of wildcard certificates (ie. CN=*.dev.domain). I'm trying to setup a mock server that has this certificate in its keystore, but I need to customize the mock server's domain into something like…
John
  • 81
  • 4
2
votes
2 answers

Integration tests with WireMock failing because no ALPN Processors are found

I'm writing some integration tests for a Spring Boot application written in Kotlin. To stub some HTTP requests, I'm using WireMock via spring-cloud-contract-wiremock as dependency. Some anonymized sample code from an integration…
Kaj Nelissen
  • 915
  • 10
  • 29