wiremock

Check for null values in request body using Wiremock

血红的双手。 提交于 2021-02-17 02:04:52
问题 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 seem to like it. I can't find any examples of what I want online so not sure if it's even possible. My Bad Request body: { "cat": null, "dog": { "id": 1344 }, "horse": { "id": 1 }, "fish": 1 } My Stub: wireMockServer.stubFor(post(urlEqualTo("

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

穿精又带淫゛_ 提交于 2021-02-08 10:45:18
问题 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 am not able to set as they are dynamic values. As these are dynamic in nature, I mean value of the property is random-auto-genarated values. Is there a way to ignore these properties and remaining all properties are anyhow matching. I know that

Connection refused when using wiremock

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 14:54:29
问题 I have this piece of code in a Junit, where I clearly set the port to 8888 when(clientUtils.getLinkUrl(eq(HOSTELS_MICROSERVICE.name()), eq(HOSTELS_MICROSERVICE.name()), anyMap())) .thenReturn("http://localhost:8888/HOSTELS/HOSTELSMethods"); stubFor(com.github.tomakehurst.wiremock.client.WireMock.get("/HOSTELS/HOSTELS_LIST").willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_JSON_VALUE) .withBody(ResourceUtils.getResourceFileAsString ("__files/HOSTELS.json"))));

Connection refused when using wiremock

*爱你&永不变心* 提交于 2021-02-07 14:53:53
问题 I have this piece of code in a Junit, where I clearly set the port to 8888 when(clientUtils.getLinkUrl(eq(HOSTELS_MICROSERVICE.name()), eq(HOSTELS_MICROSERVICE.name()), anyMap())) .thenReturn("http://localhost:8888/HOSTELS/HOSTELSMethods"); stubFor(com.github.tomakehurst.wiremock.client.WireMock.get("/HOSTELS/HOSTELS_LIST").willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_JSON_VALUE) .withBody(ResourceUtils.getResourceFileAsString ("__files/HOSTELS.json"))));

Wiremock - Cannot Get Response When Request HTTPS

你说的曾经没有我的故事 提交于 2021-01-29 19:30:40
问题 I want to mock an https service like https://jsonplaceholder.typicode.com. Its proxy and sending by Postman on 8089 port. However when I tried to get request 'https://jsonplaceholder.typicode.com/todos/1' I am getting; 2019-04-02 17:43:28.291 Opened Socket[addr=/127.0.0.1,port=65409,localport=8089] 2019-04-02 17:43:28.362 Incoming bytes: CONNECT jsonplaceholder.typicode.com:443 HTTP/1.1 cache-control: no-cache User-Agent: PostmanRuntime/7.6.0 Accept: */* host: jsonplaceholder.typicode.com:443

Load wiremock stub files

对着背影说爱祢 提交于 2021-01-29 05:50:33
问题 I wanted to load all my wiremock stub files before start-up my cucumber-jvm tests. As per wiremock docs via API only one file can be pushed. Not bulk. I was think using java code within the test project before kick-off tests. Whats would be the best way of doing this through the code. 回答1: By calling wiremock api you can upload multiple stubs in one go as per below solution. Solution Try POSTing it to http://localhost:8080/__admin/mappings/import 来源: https://stackoverflow.com/questions

WireMock: How to mock file download process?

邮差的信 提交于 2021-01-24 03:10:13
问题 I'm new in WireMock . I am running the WireMock server as a standalone process. I am able to mock simple rest api, by configuring json files under /mappings folder. Now, I want to mock a file downloading end point. How can I do that? I don't know if it helps, the end point is in Java/Spring, which looks like this: @RequestMapping(value = "xxx/get", method = {RequestMethod.GET}) public ResponseEntity<Object> getFile(HttpServletResponse response) throws Exception { final Resource fileResource =

WireMock: How to mock file download process?

天大地大妈咪最大 提交于 2021-01-24 03:01:52
问题 I'm new in WireMock . I am running the WireMock server as a standalone process. I am able to mock simple rest api, by configuring json files under /mappings folder. Now, I want to mock a file downloading end point. How can I do that? I don't know if it helps, the end point is in Java/Spring, which looks like this: @RequestMapping(value = "xxx/get", method = {RequestMethod.GET}) public ResponseEntity<Object> getFile(HttpServletResponse response) throws Exception { final Resource fileResource =

WireMock: How to mock file download process?

自闭症网瘾萝莉.ら 提交于 2021-01-24 02:57:48
问题 I'm new in WireMock . I am running the WireMock server as a standalone process. I am able to mock simple rest api, by configuring json files under /mappings folder. Now, I want to mock a file downloading end point. How can I do that? I don't know if it helps, the end point is in Java/Spring, which looks like this: @RequestMapping(value = "xxx/get", method = {RequestMethod.GET}) public ResponseEntity<Object> getFile(HttpServletResponse response) throws Exception { final Resource fileResource =

WireMock: How to mock file download process?

为君一笑 提交于 2021-01-24 02:55:35
问题 I'm new in WireMock . I am running the WireMock server as a standalone process. I am able to mock simple rest api, by configuring json files under /mappings folder. Now, I want to mock a file downloading end point. How can I do that? I don't know if it helps, the end point is in Java/Spring, which looks like this: @RequestMapping(value = "xxx/get", method = {RequestMethod.GET}) public ResponseEntity<Object> getFile(HttpServletResponse response) throws Exception { final Resource fileResource =