Package io.helidon.messaging.connectors.mock


package io.helidon.messaging.connectors.mock
Helidon messaging mock connector for testing purposes. Mock connector can be used for testing Helidon messaging without the need of connection to actual messaging broker.

 @HelidonTest
 @DisableDiscovery
 @AddBean(MockConnector.class)
 @AddExtension(MessagingCdiExtension.class)
 //Use mock connector as an upstream for channel test-channel-incoming
 @AddConfig(key = "mp.messaging.incoming.test-channel-incoming", value = MockConnector.CONNECTOR_NAME)
 //mock-data-type is optional, defaults to String.class
 @AddConfig(key = "mp.messaging.incoming.test-channel-incoming.mock-data-type", value = "java.lang.Long")
 //mock-data is optional, can generate data to the connected channel right after start
 @AddConfig(key = "mp.messaging.incoming.test-channel-incoming.mock-data", value = "9,10,11,12")
 //Use mock connector as a downstream for channel test-channel-outgoing
 @AddConfig(key = "mp.messaging.outoging.test-channel-outgoing.connector", value = MockConnector.CONNECTOR_NAME)
 public class MockConnectorTest {

     @Inject
     @TestConnector
     private MockConnector mockConnector;

     @Incoming("test-channel-incoming")
     @Outgoing("test-channel-outgoing")
     public long sampleProcessorMethod(long payload) {
         return payload;
     }

     @Test
     void sampleTestMethod() {
         mockConnector.outgoing("test-channel-outgoing", Long.TYPE)
                 .awaitMessage(TIMEOUT, longMessage -> longMessage.getPayload() == 12L)
                 .assertPayloads(9L, 10L, 11L, 12L);
     }
 }
 
  • Class
    Description
    Helidon messaging mock connector for testing purposes.
    Mock-able incoming channel connected to the mock connector.
    Mock-able outgoing channel connected to the mock connector.
    Qualifier annotation for Helidon messaging test connector.