This sample project demonstrates how we can practice contract-driven development and contract testing in a SpringBoot (Kotlin) application that depends on an external domain service and JMS.
Here, Specmatic is used to stub calls to domain API service based on its OpenAPI spec and mock JMS based on its AsyncAPI spec.
Please contact us at https://specmatic.io if you wish to try it out.
Here is the domain api contract/open api spec
Here is the AsyncAPI spec of JMS that defines queues and message schema.
- BFF: Backend for Front End
- Domain API: API managing the domain model
- Specmatic Stub/Mock Server: Create a server that can act as a real service using its OpenAPI or AsyncAPI spec
A typical web application might look like this. We can use Specmatic to practice contract-driven development and test all the components mentioned below. In this sample project, we look at how to do this for nodejs BFF which is dependent on Domain API Service and JMS demonstrating both OpenAPI and AsyncAPI support in specmatic.
- Spring boot
- Specmatic
- Specmatic JMS
- Karate
This will start the springBoot BFF server
./gradlew bootRunAccess find orders api at http://localhost:8080/findAvailableProducts _Note: Unless domain api service is running on port 9000 and JMS is set up, above requests will fail.
This will start the specmatic stub server for domain api using the information in specmatic.json and run the karate tests that expects the domain api at port 9000.
./gradlew test