Skip to content

kirsteend/spring-cloud-contract-samples

 
 

Repository files navigation

CircleCI

Spring Cloud Contract samples

This repository contains the consumer and the producer applications to use with Spring Cloud Contract project. It shows examples of

  • storing contracts on the producer side

  • storing contracts in a common repo

  • passing stubs via Rest docs

Both for REST and Messaging. Built with Maven and Gradle. Also some additional Spring Cloud Contract plugin configuration is present.

Projects

Common

Contains the JAR with common classes used in the contracts on the producer side.

Beer_contracts

Contains the repo with all contracts for all applications. It can be used when you want to store all contracts in a single place.

Producer

The producer application contains contracts for both REST and messaging communication. From these contracts tests and stubs will be generated.

Producer_with_external_contracts

The producer application that downloads its contracts for both REST and messaging communication, from the Beer-contracts JAR. From these contracts tests and stubs will be generated.

Producer_with_restdocs

The producer application that uses both contracts and Spring Cloud Contract WireMock with RESTDocs. Contracts are used for messaging but the HTTP stubs are created via REST Docs tests.

Consumer

The consumer application is using the stubs of the producer for both rest and messaging.

Consumer_with_discovery

The consumer application is using the stubs of the producer for rest. It sends requests via a load balanced rest template. In the tests Spring Cloud Contract stubs out any discovery service infrastructure.

Consumer_with_restdocs

The consumer application is using the stubs of the producer for both rest and messaging. The stubs come from the test compile dependency of the producer.

How to build it?

You can run Maven from the root folder

./mvnw clean install

The order should be as follows

  • common

  • beer-contracts

  • producer

  • producer_with_external_contracts

  • consumer

  • consumer_with_discovery

  • producer_with_restdocs

  • consumer_with_restdocs

If the order is different then your apps will blow up most likely due to missing stubs.

You can also go to each of the projects and run Gradle wrapper:

./gradlew clean build publishToMavenLocal

How to test it?

You can run the script

./scripts/runAcceptanceTests.sh

About

Samples for Spring Cloud Contract project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 39.6%
  • Java 31.4%
  • Batchfile 25.9%
  • Groovy 3.1%