Skip to content

Allow running Wiremock without HTTP Server #1572

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

Merged
merged 1 commit into from
Oct 19, 2021

Conversation

jamietanna
Copy link
Collaborator

@jamietanna jamietanna commented Jul 30, 2021

As noted in #1476, a common search online is to run Wiremock without
needing an HTTP server, for instance if using a serverless deployment
model.

It is currently possible to do this using the WireMockApp, which
relies on internal APIs, which will break when we move to Java Modules.

To avoid this, we can implement the DirectCallHttpServer as a first
class citizen, which, when created, will allow consumers to retrieve the
mapped Response (whatever it may be) for Stub and Admin requests.

We can use the existing Jetty stopTimeout configuration to control the
configuration for this server's async timeouts, so consumers can
override it in cases they need delays on responses.

Because we're using the HttpResponders as callbacks, we need to use
Mockito's doAnswer to invoke the real HttpResponder from our mock.

We also add the Mockito Jupiter bindings to more easily write JUnit
Jupiter tests using Mockito.

Finally, we want to add an example test to show consumers how they can
use it for themselves.

Closes #1476.


Depends on #1565, but otherwise ready for reviews

  • What did we want to do docs-wise?
  • This doesn't handle the chunked delay distributions
  • This doesn't handle Faults

@jamietanna jamietanna marked this pull request as draft July 30, 2021 14:11
@jamietanna jamietanna marked this pull request as ready for review September 13, 2021 17:43
@tomakehurst
Copy link
Member

Hey, please could you rebase this against master?

@jamietanna
Copy link
Collaborator Author

Thanks Tom, have done 👍

As noted in wiremock#1476, a common search online is to run Wiremock without
needing an HTTP server, for instance if using a serverless deployment
model.

It is currently possible to do this using the `WireMockApp`, which
relies on internal APIs, which will break when we move to Java Modules.

To avoid this, we can implement the `DirectCallHttpServer` as a first
class citizen, which, when created, will allow consumers to retrieve the
mapped `Response` (whatever it may be) for Stub and Admin requests.

We can use the existing Jetty `stopTimeout` configuration to control the
configuration for this server's async timeouts, so consumers can
override it in cases they need delays on responses.

Because we're using the `HttpResponder`s as callbacks, we need to use
Mockito's `doAnswer` to invoke the real `HttpResponder` from our mock.

We also add the Mockito Jupiter bindings to more easily write JUnit
Jupiter tests using Mockito.

Finally, we want to add an example test to show consumers how they can
use it for themselves.

Closes wiremock#1476.
@tomakehurst tomakehurst merged commit 461444d into wiremock:master Oct 19, 2021
class Stop {
@Test
void doesNothing() {
assertDoesNotThrow(() -> server.start());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertDoesNotThrow(() -> server.start());
assertDoesNotThrow(() -> server.stop());

jamietanna added a commit to jamietanna/wiremock that referenced this pull request Oct 21, 2021
tomakehurst pushed a commit that referenced this pull request Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document running Wiremock without HTTP Server
3 participants