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

Wiremock stubs for an API client that has hardcoded urls

I am trying to test a small service with wiremock tests. I am fine with stubbing out most of the third party service URLs however I run into problems when using client libraries that have their sanbox URL hardcoded. The current example is for…
JoeyHolloway
  • 458
  • 7
  • 19
2
votes
2 answers

Implement different response with WireMock when no request(s) match

I'm trying to stub a RESTful API. One of the resources return the details when the resource is (indeed) found, or an HTTP 404 (Not Found) when, eventually, there is no resource for the given URL. This is my simplified stub/mapping: { "mappings":…
x80486
  • 6,627
  • 5
  • 52
  • 111
2
votes
1 answer

Wiremock does not receive any requests

I am writing an integrationtest for a resource (Jax-rs with resteasy) which invokes a thirdparty request to the Trustpilot Api to get a review link for a product. In my tests I wanted to mock this call by using Wiremock and invoke the request by…
P.Raber
  • 80
  • 6
2
votes
0 answers

Is there a way to have a wildcard in the bodyFileName for a wiremock stub mapping?

My issue is that I want to give my response file names a more meaningful name but to do this I need to be able to match on any text following the id. Here is my current mapping: { "priority": 10, "request": { "urlPattern":…
2
votes
1 answer

How to respond with the same header in Wiremock?

I am using Wiremock Java API to create a stub for a REST HTTP service.I want to make this stub "mirror" the header in a response, i.e. put the same header and value that it got in a request. The header is generated in runtime so, unfortunately,…
fyrkov
  • 2,245
  • 16
  • 41
2
votes
0 answers

WireMock memory consumption when idle

I'm seeing strange memory consumption patterns when using WireMock for API-stubbing. Our mocks run in standalone mode in Docker containers, which can typically run unchanged for days. Strangely enough, WireMock seems to be allocating memory when…
Stefan Haberl
  • 9,812
  • 7
  • 72
  • 81
2
votes
1 answer

Avoid logging specific requests in Wiremock

I'm using Wiremock 2.28.1 in a Scala 2.13 project and I would like to skip logging specific requests/responses in Wiremock because they are just liveness/readiness HTTP calls targeting health/ready and health/alive endpoints: { "mappings": [ …
sentenza
  • 1,608
  • 3
  • 29
  • 51
2
votes
2 answers

Are mappings subdirectories supported in wiremock?

I am trying to put mappings json files in a subdirectories due to different requirements based on diff profiles. I have it working with default /mappings directory and all mappings work ok in postman. WiremockConfiguration options =…
Skyblue
  • 31
  • 6
2
votes
1 answer

Wiremock stubbing error: "Unrecognized field \"timestamp\" (class com.github.tomakehurst.wiremock.common.Errors), not marked as ignorable"

here I come because I have not found any solution to my problem. I'm actually trying to stub a response with wiremock (that call to the Mocked service is be done via FeignClient). My intention is to get a fake response with the real feign client,…
2
votes
0 answers

Verify that header only contains one value in Wiremock

I'm looking for an easy way to verify that a request was made with only one value for a specific header. The below snippet passes when the 'Authorization' header has multiple values. verify( getRequestedFor(urlEqualTo("/url")) …
JSextonn
  • 226
  • 3
  • 13
2
votes
4 answers

How to resolve nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/session/SessionDataStore?

I am migrating an old multi-module project. I cannot migrate as it has many dependencies, so I am making a single migration, hoping it will be easier. I upgraded Spring-boot to version 2.4.3 and constantly getting these errors: Caused by:…
Dmytro Chasovskyi
  • 3,209
  • 4
  • 40
  • 82
2
votes
1 answer

Extending wiremock to store request response in DB

I am trying to write an extension where in I can store the request and response in the database. I extended PostActionServe, now there are 2 problems After starting the mock server, I submitted the post request to…
Ambuj Jauhari
  • 1,187
  • 4
  • 26
  • 46
2
votes
1 answer

Spring Cloud Contract consumer side test returns 404

While running Spring Contract test on consumer side using stubs. I got following response first for endpoint creation then for request that was sent to it and then for the response. Both type1 and type2 are enum fields, the other fields are…
Hyphen
  • 500
  • 1
  • 5
  • 15
2
votes
1 answer

How to return request body in a field in response using Wiremock

I have a JSON request as below: { "fieldOne": 12345, "fieldTwo": 1234, "fieldThree": "2019-12-05T12:32:42.323905", "fieldFour": "string", "fieldFive": 5432, "fieldSix": "string", "fieldSeven": "string", "fieldEight":…
firstpostcommenter
  • 2,328
  • 4
  • 30
  • 59
2
votes
1 answer

Dynamic wiremock to capture path parameter and return in response

I am trying to create dynamic mocks using WireMock. I have a situation where if I specify URL like http://localhost:8989/api/account/121 then I should receive response like this: "cycleSpecification": { "id": "121" } } In brief,…
sagar verma
  • 404
  • 4
  • 10