wiremock-testcontainers-java
                                
                                
                                
                                    wiremock-testcontainers-java copied to clipboard
                            
                            
                            
                        Add a Demo for WireMock as a proxy in front of another service
Proposal
One can use Testcontainers for Java to deploy multiple instances in Docker Compose, and we have a concept for that but not existing demo. It would be nice to have an API service provisioned in Testcontainers, and a WireMock mocking a particular request (e,g, injecting a fault) just for one request. The service suggestions are welcome!
References
No response
I have started working on the same.
Hello, @oleg-nenashev, @kapishmalik - is this still needed? I wouldn't mind working on a little demo/tutorial
Yes, this item is still relevant
Hello @oleg-nenashev, I started looking into this :)
If I understood well, we want to test the interaction between a simple "client" app and the service it depends on. This "server" will expose a REST API and it will be provisioned for testing via Testconatienrs and docker compose.
Then, we'll use a WireMock to proxy the "server" app running in the testcontainer. We can showcase tests for the happy flow, as well as inject errors or delays to test the corner cases.
I have prepared a small demo trying to keep things very simple, here is a link: etrandafir93/wiremock-testcontainers-practice.
As you'll see in the example, I have tried to keep things simple by:
- Using only one class per service/app
 - Avoid starting S.B. and the web layer for the tested service, I have just instantiated the tested class instead
 - Using wiremock-standalone instead of the wiremock testcontainer
 
Finally, I wanted to mention that everything here is very raw. But if you think the direction is good, I can write a Baeldung-style article describing how to set up everything.
Let me know what you think, Cheers, Emanuel
Hi @etrandafir93 . Any documentation is always welcome. If you do not use the testcontainers module for this use case, maybe it is better to target the WireMock blog or another resource. @leeturner can probably support you, please reach out to him on slack
Hey @oleg-nenashev - I have joined slack and got in contact with Lee.
I have created this PR for the wiremock-exampels repo, thanks!