wiremock / wiremock.org

WireMock website, powered by Jekyll. Contributions are welcome!
https://wiremock.org/
MIT License
11 stars 50 forks source link

Update for Spring Boot documentation #15

Open ebendal opened 1 year ago

ebendal commented 1 year ago

The Spring Boot docs are a bit outdated (with a dead link) and it did not help me achieve what I wanted with Spring Boot and WireMock.

Attached is a proposal of updated documentation to help future readers to achieve this faster. If wanted, you could simply replace _docs/spring-boot.md with this.

spring-boot.md

oleg-nenashev commented 1 year ago

I agree the documentation is dated and not helpful. IMHO we should update the page to focus on https://github.com/maciejwalkowiak/wiremock-spring-boot from @maciejwalkowiak. We could still document a "vanilla" flow, but TBH I see no value in that when there is a dedicated library

ebendal commented 1 year ago

Referencing to the articles and libraries is IMHO enough. Further reading can take place there. I added the third party library to the text.

---
layout: docs
title: "Using with Spring Boot"
meta_title: Running WireMock with Spring Boot | WireMock
toc_rank: 116
description: It is possible to run WireMock together with Spring Boot and let the frameworks complement each other
---

Running WireMock in a Spring `TestContext` is possible with multiple approaches:
- Plain WireMock by using [`new WireMockServer()`](/docs/java-usage/), but it will start a second application server on a different port (assuming the `TestContext` uses a web server).
- The team behind Spring Cloud Contract have created a library to support running WireMock using the "ambient" HTTP server of the `TestContext`. It also simplifies some aspects of configuration and eliminates some common issues that occur when running Spring Boot and WireMock together. See [Spring Cloud Contract WireMock](https://docs.spring.io/spring-cloud-contract/docs/current/reference/html/project-features.html#features-wiremock) for details.
- A library called WireMock Spring Boot drastically simplifies WireMock configuration in a Spring Boot and JUnit 5 application. [See WireMock Spring Boot](https://github.com/maciejwalkowiak/wiremock-spring-boot) for details.

Running WireMock in a Spring `ApplicationContext` has no native support by Spring or third party libraries. 
The article [Building a Stub Server using WireMock and Spring Boot](https://blog.jdriven.com/2023/02/building-a-stub-server-using-wiremock-and-spring-boot/) from JDriven's blog shows how this can be achieved by using the [servlet support](/docs/getting-started/#deploying-into-a-servlet-container) of WireMock. 
oleg-nenashev commented 1 year ago

@ebendal let's see, but I agree it is a good start. Could you please submit a pull request so that I integrate it before adding a bigger patch? https://github.com/wiremock/wiremock.org/blob/main/CONTRIBUTING.md

oleg-nenashev commented 1 year ago

Will also need to add https://github.com/wiremock/wiremock.org/pull/64 to the same page