Class ActiveMQConsumerExtension

  • All Implemented Interfaces:
    ActiveMQConsumerOperations, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension

    public class ActiveMQConsumerExtension
    extends Object
    implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, ActiveMQConsumerOperations
    A JUnit Extension that embeds an ActiveMQ Artemis ClientConsumer into a test.

    This JUnit Extension is designed to simplify using ActiveMQ Artemis clients in unit tests. Adding the extension to a test will startup a ClientConsumer, which can then be used to consume messages from an ActiveMQ Artemis server.

    
     public class SimpleTest {
         @RegisterExtension
         private ActiveMQConsumerExtension client = new ActiveMQConsumerExtension( "vm://0", "test.queue" );
    
         @Test
         public void testSomething() throws Exception {
             // Use the embedded client here
             ClientMessage message = client.receiveMessage();
         }
     }