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
3
votes
2 answers

Wiremock: how to match a JSON request that does NOT have a specific property?

I'm trying to mock an API call that accepts a JSON body in a POST and it has two possible responses: if body contains SearchCenter property, answer with response A if body does NOT contain SearchCenter, answer with response B In the Request…
Dimitri De Franciscis
  • 1,022
  • 11
  • 20
3
votes
1 answer

springboot WireMock mock without parameters

I have this mock that is working fine stubFor(WireMock.get("/varela/offerszones?channel=123").willReturn(aResponse() .withStatus(200) .withHeader("content-type", "application/json") …
Sandro Rey
  • 2,429
  • 13
  • 36
  • 80
3
votes
1 answer

wiremock post request json body property value is dynamic generated value how to stub

Am new to wiremock, am using wiremock in my spring boot integration test for mocking one of the external http call. My json request body contains two dynamic properties, all other fields am able to set and stub in the request only two field values…
Rajendra
  • 33
  • 1
  • 1
  • 3
3
votes
1 answer

How to capture HTTP request and mock its response in Java?

Say that Java application makes requests to http://www.google.com/... and there's no way to configure the inherited library (making such requests internally), so I can not stub or replace this URL. Please, share some best practices to create a mock…
diziaq
  • 6,881
  • 16
  • 54
  • 96
3
votes
1 answer

Is it possible to pass in a file as part of the request body using WireMock?

I am currently writing an integration test using Wiremock. At the moment I am defining the id and organization id as parameters. Instead of repeating this process for say 50 fields, is it possible to pass in a JSON file as the request instead? ie…
Coder
  • 197
  • 1
  • 17
3
votes
2 answers

Check for null values in request body using Wiremock

I am trying to setup a wiremock stub that will return a 400 error if any field has a null value in the json payload. Basically to simulate a Bad Request. I've been trying with a regex that matches any lowercase string for the json key but it doesn't…
Aimee Jones
  • 881
  • 2
  • 18
  • 38
3
votes
0 answers

Wiremock server returning HTTP ERROR 500 when calling

I am using wireMock and I am getting a consistent response of 500 Internal Server Error. I am using below code to create mock server, wiremock version : 2.24.0 final URI listenUri = URI.create(listenAddress); final Duration responseTimeout =…
3
votes
1 answer

Push a pdf file on wiremock

I'm using a wiremock standlaone service to mock several json Object. Actually I want to mock a pdf file: it works fine on my local by just adding my pdf to the __files folder However I'm trying to use a POSTMAN (or curl) to push the pdf on the…
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
3
votes
2 answers

Run WireMock Server as a SpringBoot application

I am new to WireMock framework. My request is to run WireMock as a server that can accept stubs on a Spring Boot application. I tried to use the Spring Cloud Contract dependency but that only helps me in running the tests. Any direction or samples…
Sundar
  • 85
  • 4
  • 10
3
votes
0 answers

Is there a way to convert OpenAPI specifications to json mappings in maven?

I need to convert OpenAPI specifications into json mappings so I could use them in my wiremock server, but I'm not sure if there is an available plugin to do this type of conversion. This is an example of an OpenAPI I'm using openapi:…
Linda Naoui
  • 147
  • 13
3
votes
1 answer

Making stubs permanent on wiremock

I am new to wiremock and would like to create permanent custom stubs. I was able to create stubs by running a standalone wiremock instance and sending post requests using curl commands to make the stubs. That works fine, but as soon as I restart…
Rayan Ahmed
  • 165
  • 2
  • 11
3
votes
2 answers

Is there a way to include multiple json files in the response based on the query params?

I'm trying to use Wiremock standalone process to mock answers from the server. The case is that for the particular endpoint (let's call it /items) I can provide multiple query parameters (like /items?item=1&item=10&item=12). I would like to "build"…
buccaneer
  • 96
  • 5
3
votes
1 answer

Wiremock Integration Issue with Scalatest

I am having trouble integrating Wiremock with a Scalatest specification. I am using this version of Wiremock: "com.github.tomakehurst" % "wiremock-jre8" % "2.22.0" % "test", I created a WiremockSpec looks like this: trait WiremockSpec…
user3248346
3
votes
1 answer

How to match JSON in wiremock which has values same for fields but may not be in same order

I have request JSON body [ {"name" : "Ram"}, {"name" : "Sam"} ] and this is the input for wiremock request I need to match the request even if the JSON has same content but values may not be in same order. Example, …
user9920500
  • 606
  • 7
  • 21
3
votes
1 answer

Huge or infinite response with WireMock

I would like to test our app using a HTTP client with a huge amount of data. Is it possible to create an infinite or several gigabytes length output with WireMock without allocating a byte array or String with that size? As far as I see…
palacsint
  • 28,416
  • 10
  • 82
  • 109