Watch
1
0
Fork
You've already forked jme-cdct-provider-example
0
mirror of https://github.com/jme-admin-ch/jme-cdct-provider-example.git synced 2026-08-17 13:04:55 +00:00
Read-only mirror of https://github.com/jme-admin-ch/jme-cdct-provider-example — Bundesamt für Informatik und Telekommunikation. Issues & pull requests at the source. Catalog: https://www.opensource.admin.ch/en/softwares/hflcjv https://www.opensource.admin.ch/en/softwares/hflcjv
  • Java 98%
  • Shell 2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-17 01:10:04 +02:00
.github/workflows JEAP-7322 Adapted github build workflow 2026-07-30 07:47:57 +02:00
.mvn Update dependency maven to v3.9.16 2026-05-28 12:50:27 +00:00
jme-cdct-auth-scs Update dependency ch.admin.bit.jeap:jeap-oauth-mock-server to v9 2026-08-16 23:00:27 +00:00
jme-cdct-provider-service Update dependency ch.admin.bit.jeap:jeap-oauth-mock-server to v9 2026-08-16 23:00:27 +00:00
jme-cdct-provider-test Update dependency ch.admin.bit.jeap:jeap-oauth-mock-server to v9 2026-08-16 23:00:27 +00:00
.gitignore JEAP-6286: Initial OSS release. 2025-12-04 15:12:42 +01:00
CHANGELOG.md Update dependency ch.admin.bit.jeap:jeap-oauth-mock-server to v9 2026-08-16 23:00:27 +00:00
CONTRIBUTING.md JEAP-6286: Initial OSS release. 2025-12-04 15:12:42 +01:00
LICENSE JEAP-6286: Initial OSS release. 2025-12-04 15:12:42 +01:00
mvnw JEAP-6707 Update Maven wrapper 2026-02-27 08:41:50 +01:00
mvnw.cmd JEAP-6707 Update Maven wrapper 2026-02-27 08:41:50 +01:00
pom.xml Update dependency ch.admin.bit.jeap:jeap-oauth-mock-server to v9 2026-08-16 23:00:27 +00:00
publiccode.yml Update version/date in publiccode.yml 2026-08-17 01:10:04 +02:00
README.md JEAP-6287: Update parent from 30.1.0 to 30.4.0, some corrections 2025-12-17 13:29:10 +01:00
SECURITY.md JEAP-6286: Initial OSS release. 2025-12-04 15:12:42 +01:00
setPomVersions.sh JEAP-6743 Add integration tests for CDCT provider 2026-03-18 17:33:46 +01:00
THIRD-PARTY-LICENSES.md Updating THIRD-PARTY-LICENSES.md 2026-08-13 13:33:46 +02:00

JME Consumer Driven Contract Testing Example Provider

Overview

This project demonstrates consumer-driven contract testing using Pact in a Java-based microservice environment. It includes a sample provider service that fulfills contracts defined by consumer services. The contracts between the consumers and the provider are verified using Pact JVM and a Pact Broker.

Prerequisites

Before you begin, ensure you have the following installed:

  • Java 25 or higher
  • Docker and Docker Compose

Related Project: This provider project works with the JME CDCT Consumer Example and JME CDCT Consumer 2 Example projects for complete contract testing. Make sure to generate and publish the consumer pacts before verifying them with this provider project.

Getting Started

1. Ensure the Local Pact Broker is Running

The Pact Broker is managed by the consumer project (JME CDCT Consumer Example). Both the consumer and provider projects use the same Pact Broker instance for contract testing.

Before running the provider verification, ensure the local Pact Broker is running and holds consumer pacts for the provider. See the consumer project README.md for instructions on how to start the local Pact Broker and on how to publish a consumer pact.

2. Verify the Consumer Pact and Publish the Verification Result

Verify the provider against the consumer pacts from the Pact Broker and publish the verification results:

./mvnw verify -Plocal-pact-broker -Pcdct-enable-publishing-local

This command will:

  • Run the provider verification tests
  • Fetch pacts from the local Pact Broker
  • Verify the provider implementation against each pact
  • Publish verification results back to the Pact Broker

Maven Profile Explanations:

  • local-pact-broker: Configures the Pact Broker URL to point to the local instance (http://localhost:9292)
  • cdct-enable-publishing-local: Enables verification result publishing from local (non-CI) builds

Note: Usually, verification results are published in CI/CD pipelines only (to a remote Pact Broker instance).

3. View Verification Results

Open the Pact Broker UI in your browser (http://localhost:9292) and navigate to the pact matrix of a consumer-provider pair to see the verification results.

Provider Contract Verification

This project uses Pact JVM to verify the provider implementation against consumer contracts. Verification is performed in the JUnit test class TaskControllerProviderTest, which retrieves all relevant pacts from the Pact Broker and tests them against the running provider service. The provider verification test checks if the provider implementation meets all expectations defined by its consumers.

Troubleshooting

Pact Broker Not Accessible

If you cannot access the Pact Broker consult the troubleshooting instructions in the README.md of the (JME CDCT Consumer Example) project.

Verification Fails

If pact verification fails:

  1. Verify the Pact Broker is running and accessible
  2. Check that both profiles are enabled: -Plocal-pact-broker -Pcdct-enable-publishing-local
  3. Check that consumer pacts have been published to the broker

Running the Provider Service Locally

Unlike other jEAP microservice example projects, the primary focus of this project is to execute Pact-related tasks during the build process, rather than running the microservice itself. However, you can still run the provider service locally to test its integration with consumer services.

To run the provider service locally, use the following command:

./mvnw spring-boot:run -pl jme-cdct-provider-service -Dspring-boot.run.profiles=local

Additionally, you need to start the mock authorization server located in the jme-cdc-auth-scs submodule:

./mvnw spring-boot:run -pl jme-cdct-auth-scs -Dspring-boot.run.profiles=local

Consumer services use this mock authorization server to obtain access tokens required for authenticating requests to the provider service. In swagger for example: OIDC (OAuth2, authorization_code with PKCE), client_id and client_secret can be found in the application.yml file of the mock authorization server.

Development Guidelines

This project needs to be versioned using Semantic Versioning, and all changes need to be documented in CHANGELOG.md following the format defined in Keep a Changelog.

Changes

Change log is available at CHANGELOG.md

Note

This repository is part of the open source distribution of jEAP. See github.com/jme-admin-ch/jme for more information.

License

This repository is Open Source Software licensed under the Apache License 2.0.