Class ActiveMQDynamicProducerResource

  • All Implemented Interfaces:
    ActiveMQDynamicProducerOperations, ActiveMQProducerOperations, org.junit.rules.TestRule

    public class ActiveMQDynamicProducerResource
    extends org.junit.rules.ExternalResource
    implements ActiveMQDynamicProducerOperations, ActiveMQProducerOperations
    A JUnit Rule that embeds an dynamic (i.e. unbound) ActiveMQ Artemis ClientProducer 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 an unbound ClientProducer, which can then be used to feed messages to any address on the ActiveMQ Artemis server.
     
     public class SimpleTest {
         @Rule
         public ActiveMQDynamicProducerResource producer = new ActiveMQDynamicProducerResource( "vm://0");
    
         @Test
         public void testSomething() throws Exception {
             // Use the embedded ClientProducer here
             producer.sendMessage( "test.address", "String Body" );
         }
     }