Skip to main content

Example Java Wiremock Consumer

Source Code#

https://github.com/pactflow/example-consumer-wiremock

Build Status

This is an example of a Java consumer that uses Wiremock (with Junit5), Pactflow and Travis CI to ensure that it is compatible with the expectations its consumers have of it.

The project uses a Makefile to simulate a very simple build pipeline with two stages - test and deploy.

It is using a public tenant on Pactflow, which you can access here using the credentials dXfltyFMgNOFZAxr8io9wJ37iUpY42M/O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1.

See the canonical consumer example here: https://github.com/pactflow/example-consumer See also the full Pactflow CI/CD Workshop for which this can be substituted in as the "consumer".

Bi-directional provider#

This project is currently compatible with the following providers:

Pre-requisites#

Software:

Environment variables#

To be able to run some of the commands locally, you will need to export the following environment variables into your shell:

  • PACT_BROKER_TOKEN: a valid API token for Pactflow
  • PACT_BROKER_BASE_URL: a fully qualified domain name with protocol to your pact broker e.g. https://testdemo.pactflow.io
  • PACT_PROVIDER: You can use this to override the name of the provider you want to test for this. It defaults to pactflow-example-provider-restassured for compatibility with the Java RestAssured provider

Usage#

  • make test - run the tests locally
  • make fake_ci - run the CI process locally