Class ActiveMQDynamicProducerExtension

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

    public class ActiveMQDynamicProducerExtension
    extends Object
    implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, ActiveMQDynamicProducerOperations, ActiveMQProducerOperations
    A JUnit Extension that embeds an dynamic (i.e. unbound) ActiveMQ Artemis ClientProducer 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 an unbound ClientProducer, which can then be used to feed messages to any address on the ActiveMQ Artemis server.

    
     public class SimpleTest {
         @RegisterExtension
         private ActiveMQDynamicProducerExtension producer = new ActiveMQDynamicProducerExtension("vm://0");
    
         @Test
         public void testSomething() throws Exception {
             // Use the embedded ClientProducer here
             producer.sendMessage( "test.address", "String Body" );
         }
     }