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
10
votes
5 answers

Wiremock CORS not working

I've been used wiremock effectively for some time now, and I wanted to enable CORS access to the mocked APIs. I've tried setting Access-Control-Allow-Origin: * and other headers in the response header, both to no avail. Here's an example of a…
johncougar
  • 276
  • 2
  • 3
  • 10
9
votes
2 answers

Stub calls to third party services using WireMock

I tried to find a way to stub calls to external services via WireMock. WireMock easily mocks any relative URL, but what if we want to intercept a REST call, which was sent from our node to some 3rd party service and return predefined response? Is…
Alesto
  • 639
  • 4
  • 13
  • 29
8
votes
5 answers

Conflicting module versions. Module [groovy-xml is loaded in version 4.x.x and you are trying to load version 3.x.x

I am working to setup wiremock for springboot rest api and using rest assured and spring-cloud-starter-contract-stub-runner from spring cloud. when i run the sample integration test i encounter module conflict error
Guru Cse
  • 2,805
  • 2
  • 18
  • 15
8
votes
1 answer

Wiremock simulate a proxy server running

I want to add a test for the following e2e scenario: My app is making a web request to an external service through an internal proxy server, the proxy server manipulates the request body, forwards the request to the desination host and returns the…
v78
  • 2,803
  • 21
  • 44
8
votes
2 answers

Wiremock with Spring Boot JUnit 5 test: Address in Use after test run

We have a Spring Boot 2.2.0.RELEASE application that we're testing with a JUnit 5 test class using WireMock. The test runs fine locally, but on our Jenkins, it fails with an "Address already in use" message after the test has run…
daniu
  • 14,137
  • 4
  • 32
  • 53
8
votes
1 answer

WireMock error while trying to mock an HttpClient with Proxy

I have an Http Client which uses a proxy in real life to send a request to an API. I am trying to use WireMock to run my http client tests and mock the responses for the API. However, I could not manage to make Wiremock work with a proxy setup. I…
8
votes
2 answers

Wiremock.Net query parameter with SOQL Query

I'm using WireMock-Net for stubbing requests. I want to do the following request: Request: http://localhost:63078/services/query/?q=SELECT Id from User where username='user@gmail.com' The request is composed by a SOQL Query. Here's a snippet of…
8
votes
2 answers

Wiremock error - there are no stub mappings in this WireMock instance

I have implemented a basic WireMock with a sample REST/HTTP request simulation. The server code implemented as below. With this code, I get the following error when I issue the GET request from Postman (i.e. GET http://127.0.0.1:8089/some/thing).…
AnilJ
  • 1,951
  • 2
  • 33
  • 60
8
votes
4 answers

Wiremock Standalone with Dynamic response

I have a standalone instance of Wiremock server. The mappings are stored as json files under the mappings folder. I have a POST request that needs to return a dynamic ID(integer) in the response. Is there a way to configure this in the json file?
alltej
  • 6,787
  • 10
  • 46
  • 87
8
votes
1 answer

Wiremock not matching regex

I'm using wiremock to mock certain requests and their respective response, but I'm trying to add a regex. Unfortunately, this just throws an exception stating that the request was not matched. { "request" : { "method": "GET", …
masha.knezevic
  • 121
  • 1
  • 1
  • 8
8
votes
4 answers

Wiremock match request POST by params

I have a simple POST request sending params using application/x-www-form-urlencoded encoding. Looking in the wiremock docs I can't find a way to match the request by the params values, something like the querystring match I mean. Furthermore it…
rascio
  • 8,968
  • 19
  • 68
  • 108
8
votes
3 answers

Why WireMock says that the Request not matches? Spring cloud contract

Wiremock logs that the following request not matches: WireMock : Request was not matched: { "url" : "/api/accounts?username=defaultuser", "absoluteUrl" :…
7
votes
4 answers

Wiremock - sometimes it throws "Software caused connection abort: recv failed"

I encountered a very strange situation when using Spring and Wiremock for integration testing: suddenly, one specific test started failing intermittently. A snippet of the error below: org.springframework.web.client.ResourceAccessException: I/O…
Victor
  • 1,001
  • 2
  • 14
  • 25
7
votes
1 answer

How to configure wiremock to send different responses (same url and requests) after reaching previous count of request?

It is possible to configure wiremock to send different responses on same URL and same request after particular count of previous responses? For example: 1st request -> 503 response 2nd request -> 503 response 3rd request -> 503 response 4th request…
madafaka
  • 133
  • 2
  • 7
7
votes
2 answers

WireMock behaves weird sometime

In most of the integration tests I'm using spring-boot-test(2.1.9.RELEASE) and spring-cloud-contract-wiremock(2.0.2.RELEASE). The test is starting up WireMock server based on : @AutoConfigureWireMock(port = 0), so I'm not using any WireMockRule or…
brebDev
  • 774
  • 10
  • 27
1 2
3
59 60