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

634 questions
27
votes
6 answers

How to write integration tests with spring-cloud-netflix and feign

I use Spring-Cloud-Netflix for communication between micro services. Let's say I have two services, Foo and Bar, and Foo consumes one of Bar's REST endpoints. I use an interface annotated with @FeignClient: @FeignClient public interface BarClient { …
Bastian Voigt
  • 4,617
  • 5
  • 34
  • 61
20
votes
4 answers

Is it possible to simulate connection timeout using wiremock tools?

I know that it can simulate SocketTimeoutException by using withFixedDelay, but what about ConnectionTimeoutException?
Developer87
  • 1,918
  • 3
  • 17
  • 40
18
votes
3 answers

How to enable verbose logging in non standalone wiremock

I see that there are instructions on enabling verbose logging for wiremock when running it in standalone fashion at http://wiremock.org/running-standalone.html (see --verbose). How do I enable the same when starting it from a java code?
Superaghu
  • 695
  • 1
  • 5
  • 14
17
votes
1 answer

wiremock equivalent for websockets?

I have used wiremock for testing http calls, but my current work requires websockets and I was wondering if anyone has found/used a library for standing up a localhost that will create a websocket connection that you can mock responses. I have…
Randy
  • 1,111
  • 2
  • 9
  • 28
15
votes
3 answers

Stubbing with Wiremock - WithBodyFile Location other than _files

Wiremock Documentation states that the location of the file specified in withBodyFile should be in src/test/resources/__files. I would like to have file in src/test/resources/Testing_ABC/Testcase2/myfile.xml. Is there any way I can achieve this ? I…
Ragini
  • 1,339
  • 4
  • 22
  • 39
15
votes
3 answers

Can't turn off debug logging for Wiremock

I'm using Wiremock for my tests in a Spring Boot app. I can't seem to get the logging to not output all debug logs, which makes my test runs very verbose. I see it use SLF4J on startup: DEBUG wiremock.org.eclipse.jetty.util.log - Logging to…
James McMahon
  • 45,276
  • 62
  • 194
  • 274
15
votes
4 answers

Wiremock returning 404 for a stubbed url

I have defined wireMock server as follows:- private WireMockServer wireMockServer; @Before public void preSetup() throws Exception { wireMockServer = new WireMockServer(56789); wireMockServer.start(); …
tuk
  • 4,173
  • 6
  • 49
  • 116
14
votes
3 answers

Using WireMock with SOAP Web Services in Java

I am totally new to WireMock. Until now, I have been using mock responses using SOAPUI. My use case is simple: Just firing SOAP XML requests to different endpoints (http://localhost:9001/endpoint1) and getting canned XML response back. But MockWrire…
Anurag
  • 713
  • 3
  • 13
  • 29
13
votes
2 answers

Wiremock: Multiple responses for the same URL and Content?

Also shared here: https://github.com/tomakehurst/wiremock/issues/625 I'm writing an integration test to verify that my application that interacts with a REST API handles unsuccessful requests appropriately. To do this, I'm wanting to simulate a…
rugden
  • 405
  • 1
  • 4
  • 10
12
votes
1 answer

WireMock in Junit in Jenkins - BindException: Address already in use

I have some Junit test in which I use WireMock. Locally the tests pass, but on Jenkins I get an error of java.lang.RuntimeException: java.net.BindException: Address already in use In the WireMock configuration I set dynamicHttpsPort() (which…
yishaiz
  • 1,968
  • 2
  • 23
  • 44
11
votes
3 answers

How to fix "NoHttpResponseException" when running Wiremock on jenkins?

I start a wiremock server in a integration test. The IT pass in my local BUT some case failed in jenkins server, the error is localhost:8089 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:8089 failed to…
Alvin
  • 113
  • 1
  • 7
11
votes
6 answers

Set property with wiremock random port in spring boot test

I have a Spring Boot test that uses wiremock to mock an external service. In order to avoid conflicts with parallel builds I don't want to set a fixed port number for wiremock and would like to rely on its dynamic port configuration. The application…
11
votes
1 answer

Why would I use MockWebServer instead of WireMock?

Every time when I need to mock some http requests my first choise is WireMock (which is actually standard for that I think), but today I discovered some alternative tool - MockWebServer. What are pros and cons of WireMock vs MockWebServer?
Paweł Szymczyk
  • 1,185
  • 11
  • 15
11
votes
4 answers

Matching data in JsonPath with wiremock

I'm trying to create mocks for my login procedure. I use POST method with a couple of fields and login object (with login, password, etc.) For that I'm using JsonPath. Code below: { "request": { "method": "POST", "url": "/login", …
a_dzik
  • 827
  • 2
  • 11
  • 23
10
votes
2 answers

Wiremock - "URL does not match" even though it is same

I am facing an issue that Wiremock says my URLs don't match even though they are the same. Obviously I am missing something. What am I doing wrong? WireMock.stubFor(WireMock.get(WireMock.urlPathEqualTo("/test/url?bookingCode=XYZ123&lastName=TEST")) …
Abbin Varghese
  • 1,469
  • 1
  • 17
  • 36
1
2 3
42 43