Skip to content

A template project for those who want to create a new WireMock extension/plugin

License

Notifications You must be signed in to change notification settings

wiremock/wiremock-extension-template

WireMock extension template

WireMock Logo

Template for creating new WireMock extensions.

Template usage

This template contains various samples on how you can write your own extension - just clone it and get started.

Not all parts are needed, thus feel free to adapt it. The code is documented and marked with TODO comments to help finding customization points.

Manuals

Overall extension documentation

Extensions can be explicitly configured or auto-detected. This extension supports auto-detection which eases integration in WireMock standalone or docker containers.

For supporting auto-detection as standalone library, this template implements the Java Service Provider Interface, which is used by WireMock to find extensions and packages everything using shadowjar.

When forking this repository, you have to adapt shadowjar/resources/META-INF/services/com.github.tomakehurst.wiremock.extension.ExtensionFactory to point to a class with default constructor which registers all parts of your extension (in this template, this is handled by org.wiremock.extensions.template.StandaloneTemplateExtension).

For non-standalone usages, you can use your own class to instantiate your extension. In this template, this is handled by org.wiremock.extensions.template.TemplateExtension. Having the standalone version using this one helps ensuring a consistent extension setup.

Request matcher

Official documentation on using request matchers: https://wiremock.org/docs/request-matching/ Official documentation on creating request matchers extension: https://wiremock.org/docs/extensibility/custom-matching/

The sample code in this template shows how to read parameters and values which contain handlebar templates to get similar functionalities as when using them in response templates.

See org.wiremock.extensions.template.extensions.RequestMatcher for a sample and org.wiremock.extensions.template.RequestMatcherTest for a corresponding test.

Releases

No releases published

Packages

No packages published

Languages