Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Demo for WireMock as a proxy in front of another service #81

Open
oleg-nenashev opened this issue Oct 17, 2023 · 6 comments
Open
Labels
enhancement New feature or request hacktoberfest Hacktoberfest ideas help wanted Extra attention is needed testcontainers

Comments

@oleg-nenashev
Copy link
Member

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!

image

References

No response

@oleg-nenashev oleg-nenashev added enhancement New feature or request help wanted Extra attention is needed testcontainers hacktoberfest Hacktoberfest ideas labels Oct 17, 2023
@kapishmalik
Copy link
Contributor

I have started working on the same.

@etrandafir93
Copy link

Hello, @oleg-nenashev, @kapishmalik - is this still needed? I wouldn't mind working on a little demo/tutorial

@oleg-nenashev
Copy link
Member Author

Yes, this item is still relevant

@etrandafir93
Copy link

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

@oleg-nenashev
Copy link
Member Author

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

@etrandafir93
Copy link

Hey @oleg-nenashev - I have joined slack and got in contact with Lee.

I have created this PR for the wiremock-exampels repo, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest Hacktoberfest ideas help wanted Extra attention is needed testcontainers
Projects
None yet
Development

No branches or pull requests

3 participants