Class ActiveMQProducerExtension

java.lang.Object
org.apache.activemq.artemis.junit.ActiveMQProducerExtension
All Implemented Interfaces:
ActiveMQProducerOperations, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension

public class ActiveMQProducerExtension extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, ActiveMQProducerOperations
A JUnit Extension that embeds an Apache Artemis ClientProducer bound to a specific address into a test.

This JUnit Extension is designed to simplify using Apache Artemis clients in unit tests. Adding the extension to a test will startup a ClientProducer, which can then be used to feed messages to the bound address on an ActiveMQ Artemis server.

public class SimpleTest {
    @RegisterExtension
    private ActiveMQProducerExtension producer = new ActiveMQProducerExtension( "vm://0", "test.queue");

    @Test
    public void testSomething() throws Exception {
        // Use the embedded ClientProducer here
        producer.sendMessage( "String Body" );
    }
}