Mock Connector
Reactive Messaging Mock connector for testing
Overview
Mock connector is a simple application scoped bean that can be used for emitting to a channel or asserting received data in a test environment. All data received are kept in memory only.
Maven Coordinates
To enable Mock Connector, add the following dependency to your project’s
pom.xml (see Managing Dependencies).
pom.xml
<dependency>
<groupId>io.helidon.messaging.mock</groupId>
<artifactId>helidon-messaging-mock</artifactId>
</dependency>
Usage
Mock connector should be used in the test environment only!
For injecting Mock Connector use @TestConnector qualifier:
@Inject
@TestConnector
MockConnector mockConnector;
Emitting Data
Emitting String values a, b, c:
Asserting Data
Awaiting and asserting payloads with custom mapper:
Configuration
| Key | Default value | Description |
|---|---|---|
| mock-data | Initial data emitted to the channel immediately after subscription | |
| mock-data-type | java.lang.String | Type of the emitted initial data to be emitted |
Helidon Test with Mock Connector
Mock connector works great with built-in Helidon test support for JUnit 5 or TestNG.
As Helidon test support makes a bean out of your test, you can inject MockConnector directly into it.