/spring_cloud_contract_client_api_sample

Sample application to demonstrate the use of Consumer Driven Contract (CDC) with SpringBoot 2.3.0 + Spring Cloud Contract 2.2 + OpenFeign client - Client / Contract consumer sample application

Primary LanguageJava

Producer-driven Contract + Consumer-Driven Contract tests Sample - Client application

Sample application to demonstrate the use of Producer Driven Contract and Consumer Driven Contract tests with SpringBoot 2.3.0 + Spring Cloud Contract 2.2 - Client/contract consumer sample application.

This application uses:

  • Spring Boot 2.3.0
  • Spring Cloud Hoxton.SR4
  • Spring Cloud Contract 2.2
  • Spring Web+Rest
  • Lombok
  • Java 8
  • Gradle (Gradle wrapper)
  • JUnit 5 e Mockito
  • Open Feign
  • StubRunner (will run in local mode, on port 8082)
  • WireMock

You can see the server / REST API provider application here: https://github.com/bovino/spring_cloud_contract_server_api_sample

TODO List for this sample project

  • Adding Docker and maybe Kubernetes support
  • Adding continuos integration with Jenkins (or similars)
  • Adding code validation with SonarQube (or similars)
  • Adding more contract sample with others DSLs instead of only Groovy (Yaml, Java and Kotlin)
  • Implement a Consumer-driven sample using an Angular application + Pact
  • using a remote StubRunner instead of a local one
  • publishing the contracts to a Git repository instead of using Maven local repo
  • adding a video-tutorial showing all the steps from the beginning, starting with the generation of the codebase from Spring Initializer
  • Do you have other ideas for improvements? Please tell me! Reach out to me on Linkedin: https://www.linkedin.com/in/bovino/

Getting Started

This application uses Gradle (Gradle wrapper) and a few useful commands are:

  • Basic Build: gradlew clean build
  • Publish (includes generation and publish of contract stubs for your local maven repository): gradlew clean publishToMavenLocal
  • Run tests (including the contract tests): gradlew clean test

Before using this application you will need:

  • Some IDE with Lombok support (i like IntelliJ)
  • Any Rest API client (i like Postman)
  • JDK 1.8,0_251 or newer
  • Configure your JAVA_HOME environment variable
  • You need the ports 8080 (server API), 8081 (client API) and 8082 (local StubRunner) to be free

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use and setup some features more concretely:

Additional Links

These additional references should also help you: