JMS Mocking with AsyncAPI using Specmatic
Channel: ConfEngine
Date: 2023-07-25

Key features:
- Mocks a real JMS server so that clients can communicate with it seamlessly.
- Validates the messages that it receives against the schema defined in the AsyncAPI specification.
- Provides the ability to set and verify expectations on it.

Sample project: https://github.com/znsio/specmatic-order-bff-jms
Download Specmatic: https://github.com/znsio/specmatic/releases

Learn more about Specmatic: https://specmatic.io/features/jms-contract-driven-development-leverage-asyncapi-specs-as-executable-contracts/

In this video, we explore how to mock JMS using Specmatic for effective contract testing. We start by setting expectations on the JMS mock, describing the messages it should receive. Additionally, we set expectations on Specmatic’s HTTP stub, utilizing OpenAPI specifications for the application’s dependencies. With these in place, Specmatic runs contract tests against the application.

During the contract tests, requests are sent to the application, which passes through the controller and service layer. The service layer fetches data from Specmatic’s HTTP stub and drops messages onto the JMS mock. The JMS mock validates the messages against the specified schema, ensuring accuracy and compatibility. Finally, Specmatic verifies the expectations set on the JMS mock, providing comprehensive validation.

With Specmatic’s seamless integration of JMS mocking, contract testing becomes more efficient and isolated. You can run these tests locally or integrate them into your continuous integration pipeline, providing quick feedback for improved application quality. Take your contract testing to the next level with Specmatic’s JMS mocking capabilities.