Class ActiveMQProducerResource

java.lang.Object
org.junit.rules.ExternalResource
org.apache.activemq.artemis.junit.ActiveMQProducerResource
All Implemented Interfaces:
ActiveMQProducerOperations, org.junit.rules.TestRule

public class ActiveMQProducerResource extends org.junit.rules.ExternalResource implements ActiveMQProducerOperations
A JUnit Rule that embeds an ActiveMQ Artemis ClientProducer bound to a specific address into a test.

This JUnit Rule is designed to simplify using ActiveMQ Artemis clients in unit tests. Adding the rule 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 {
    @Rule
    public ActiveMQProducerResource producer = new ActiveMQProducerResource( "vm://0", "test.queue");

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