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" );
}
}
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedActiveMQProducerExtension(String url, String address) protectedActiveMQProducerExtension(String url, String username, String password) ActiveMQProducerExtension(String url, String address, String username, String password) ActiveMQProducerExtension(String url, SimpleString address) ActiveMQProducerExtension(String url, SimpleString address, String username, String password) protectedActiveMQProducerExtension(ServerLocator serverLocator) ActiveMQProducerExtension(ServerLocator serverLocator, String address) protectedActiveMQProducerExtension(ServerLocator serverLocator, String username, String password) ActiveMQProducerExtension(ServerLocator serverLocator, String address, String username, String password) ActiveMQProducerExtension(ServerLocator serverLocator, SimpleString address) ActiveMQProducerExtension(ServerLocator serverLocator, SimpleString address, String username, String password) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMessageProperties(ClientMessage message, Map<String, Object> properties) voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) protected voidcreateMessage(byte[] body) createMessage(byte[] body, Map<String, Object> properties) createMessage(String body) createMessage(String body, Map<String, Object> properties) createMessage(Map<String, Object> properties) booleanbooleansendMessage(byte[] body) sendMessage(byte[] body, Map<String, Object> properties) sendMessage(String body) sendMessage(String body, Map<String, Object> properties) sendMessage(Map<String, Object> properties) voidsendMessage(ClientMessage message) voidsetAutoCreateQueue(boolean autoCreateQueue) voidsetUseDurableMessage(boolean useDurableMessage) protected void
-
Constructor Details
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(String url, SimpleString address, String username, String password) -
ActiveMQProducerExtension
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(ServerLocator serverLocator, String address, String username, String password) -
ActiveMQProducerExtension
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(ServerLocator serverLocator, SimpleString address, String username, String password) -
ActiveMQProducerExtension
-
-
Method Details
-
beforeAll
-
afterAll
-
isUseDurableMessage
public boolean isUseDurableMessage()- Specified by:
isUseDurableMessagein interfaceActiveMQProducerOperations
-
setUseDurableMessage
public void setUseDurableMessage(boolean useDurableMessage) - Specified by:
setUseDurableMessagein interfaceActiveMQProducerOperations
-
createClient
protected void createClient() -
stopClient
protected void stopClient() -
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
addMessageProperties
-
isAutoCreateQueue
public boolean isAutoCreateQueue() -
setAutoCreateQueue
public void setAutoCreateQueue(boolean autoCreateQueue)
-