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 ActiveMQ Artemis ClientProducer bound to a specific address 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 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
Constructors Modifier Constructor Description protectedActiveMQProducerExtension(String url)ActiveMQProducerExtension(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(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator)ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String address)protectedActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String username, String password)ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String address, String username, String password)ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, SimpleString address)ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, SimpleString address, String username, String password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddMessageProperties(org.apache.activemq.artemis.api.core.client.ClientMessage message, Map<String,Object> properties)voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context)protected voidcreateClient()org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage()org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage(byte[] body)org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage(byte[] body, Map<String,Object> properties)org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage(String body)org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage(String body, Map<String,Object> properties)org.apache.activemq.artemis.api.core.client.ClientMessagecreateMessage(Map<String,Object> properties)booleanisAutoCreateQueue()booleanisUseDurableMessage()org.apache.activemq.artemis.api.core.client.ClientMessagesendMessage(byte[] body)org.apache.activemq.artemis.api.core.client.ClientMessagesendMessage(byte[] body, Map<String,Object> properties)org.apache.activemq.artemis.api.core.client.ClientMessagesendMessage(String body)org.apache.activemq.artemis.api.core.client.ClientMessagesendMessage(String body, Map<String,Object> properties)org.apache.activemq.artemis.api.core.client.ClientMessagesendMessage(Map<String,Object> properties)voidsendMessage(org.apache.activemq.artemis.api.core.client.ClientMessage message)voidsetAutoCreateQueue(boolean autoCreateQueue)voidsetUseDurableMessage(boolean useDurableMessage)protected voidstopClient()
-
-
-
Constructor Detail
-
ActiveMQProducerExtension
protected ActiveMQProducerExtension(String url, String username, String password)
-
ActiveMQProducerExtension
protected ActiveMQProducerExtension(String url)
-
ActiveMQProducerExtension
protected ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String username, String password)
-
ActiveMQProducerExtension
protected ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(String url, String address, String username, String password)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(String url, SimpleString address, String username, String password)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(String url, SimpleString address)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String address, String username, String password)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, String address)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, SimpleString address, String username, String password)
-
ActiveMQProducerExtension
public ActiveMQProducerExtension(org.apache.activemq.artemis.api.core.client.ServerLocator serverLocator, SimpleString address)
-
-
Method Detail
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
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
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage()
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(byte[] body)
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(String body)
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(Map<String,Object> properties)
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(byte[] body, Map<String,Object> properties)- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
createMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage createMessage(String body, Map<String,Object> properties)
- Specified by:
createMessagein interfaceActiveMQProducerOperations
-
sendMessage
public void sendMessage(org.apache.activemq.artemis.api.core.client.ClientMessage message)
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(byte[] body)
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String body)
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(Map<String,Object> properties)
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(byte[] body, Map<String,Object> properties)- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
sendMessage
public org.apache.activemq.artemis.api.core.client.ClientMessage sendMessage(String body, Map<String,Object> properties)
- Specified by:
sendMessagein interfaceActiveMQProducerOperations
-
addMessageProperties
public static void addMessageProperties(org.apache.activemq.artemis.api.core.client.ClientMessage message, Map<String,Object> properties)
-
isAutoCreateQueue
public boolean isAutoCreateQueue()
-
setAutoCreateQueue
public void setAutoCreateQueue(boolean autoCreateQueue)
-
-