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
1 answer

Wiremock withBodyFile OutOfMemoryError for large files

In the following stub request, I use withBodyFile which loads large files (>300MB) from specific locations on local disk using streams: public void mockGetUrlContent(String url) { stubFor(get(urlEqualTo(url)) .willReturn(ok() …
DeJaVo
  • 3,091
  • 2
  • 17
  • 32
3
votes
1 answer

How to change JSON key from camelCase to snake case for POJO?

I am doing testing with Wiremock and I have following example for POJO: @Data public class DataResponse { private Supply supply; private static class Supply { private List timeSeries; } …
Ulukbek Abylbekov
  • 449
  • 1
  • 6
  • 19
3
votes
0 answers

Run multiple Integration Tests that use Wiremock

In my Specflow project i have a .features file with multiple test scenarios. the thing those tests have in common is that they all use a single Wiremock Server. Now when I run the tests they always fail except for one. This problem also occurs when…
Amin
  • 31
  • 5
3
votes
2 answers

How to make query parameters in wiremock as optional parameters?

How can I make query parameter(pageSize) in below json as optional while using wiremock { "request": { "method": "GET", "urlPath": "/claims-search", "queryParameters" : { "pageSize" : { "equalTo" :…
vinay
  • 33
  • 3
3
votes
2 answers

WireMock.Net How to response sometimes an error and others OK

I'm working with WireMock.Net, and I want to configure Wiremock with the same URI, it sometimes returns OK(200) and sometimes Error Response(500). The examples I've seen is always returning the same status code, for…
3
votes
1 answer

Return Custom Exception while using wiremock

I need to return custom exception while mocking a url like whenever I will hit /test/user/get/ I need to return UserNotFoundException. I m trying to do like this. Can somebody help me how to return exception in wiremock public void…
alka kumari
  • 51
  • 1
  • 7
3
votes
1 answer

Validate Json Body with Wiremock

I'm trying to validate/match a request body against a JSON schema with Wiremock. AFAIK, Wiremock does not have first class support for schema validation, but only supports JSONPath. Unfortunately, I can't wrap my head around the correct JSON-Path…
Stefan Haberl
  • 9,812
  • 7
  • 72
  • 81
3
votes
1 answer

How to enable Spring Cloud Contract Wiremock server logging?

As per official document How to Debug, I need to add following to the property file to enable logging logging.level.org.apache.http.wire=DEBUG logging.level.com.github.tomakehurst.wiremock=DEBUG But, I don't see any logs visible on the console when…
3
votes
1 answer

OAuth2 machine to machine with Spring WebClient

I have been struggling for 2 days already to get Spring WebClient authenticate my service against a (presumably) OAuth2 endpoint. The flow is simple, I need to get a token from some endpoint and set it to authorization header. I thought springboot…
anydoby
  • 408
  • 4
  • 9
3
votes
1 answer

In wiremock mapping json BodyPatterns only the last comparison is happening

I am using wiremock-jre8-standalone-2.27.0 jar to mock an API. My mapping json looks like: { "request": { "url": "/sampleUrl", "method": "POST", "bodyPatterns": [ { "matchesJsonPath" : { "expression":…
3
votes
2 answers

Connection refused when trying to call Wiremock Stub

I'm trying to integrate Cucumber-JVM with WireMock and I keep getting java.net.ConnectException: Connection refused: connect I've tried several tutorials, including the Official Docs from cucumber.io And also tried these below: Introduction to…
Johnnes Souza
  • 361
  • 1
  • 8
  • 22
3
votes
4 answers

How to specify path of WireMock mappings and files present inside executable Spring Boot Jar?

I have built WireMock as a spring boot application using "spring-cloud-contract-wiremock" dependency. I have kept the mapping and _files inside src/test/resources folder. When I run the application from IDE it works perfectly. But when I run the Jar…
Roshni
  • 137
  • 1
  • 2
  • 11
3
votes
3 answers

Wiremock Docker Container not using the supplied port (instead using 8080)

I am using WireMock Docker image and spinning off the container using it. I can verify the container is up and running but after looking at container logs, looks like it is still running on 8080? At least, I am not able to access Wiremock using…
Code-Strings
  • 111
  • 2
  • 10
3
votes
2 answers

Best practice how to manage a lot of wiremock stubs?

My unit tests use wiremock extensively and most of these test classes look like this: class Test { private static WireMockServer wireMockServer; @BeforeAll static void setup() { wireMockServer = new…
SCM
  • 45
  • 1
  • 9
3
votes
2 answers

Wiremock Placeholder isn't recognized

I tried with the following json but the wiremock doesn't recognize my change. I read the documentation of wiremock and I saw that they said: JSON equality matching is based on JsonUnit and therefore supports placeholders. I also tried with both JDK…
Sang Mai
  • 61
  • 2
  • 4