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" );
}
}
-
Constructor Summary
ConstructorsConstructorDescriptionActiveMQProducerResource(String url, String address) ActiveMQProducerResource(String url, String username, String password) ActiveMQProducerResource(String url, String address, String username, String password) ActiveMQProducerResource(String url, SimpleString address) ActiveMQProducerResource(String url, SimpleString address, String username, String password) ActiveMQProducerResource(ServerLocator serverLocator) ActiveMQProducerResource(ServerLocator serverLocator, String address) ActiveMQProducerResource(ServerLocator serverLocator, String username, String password) ActiveMQProducerResource(ServerLocator serverLocator, String address, String username, String password) ActiveMQProducerResource(ServerLocator serverLocator, SimpleString address) ActiveMQProducerResource(ServerLocator serverLocator, SimpleString address, String username, String password) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMessageProperties(ClientMessage message, Map<String, Object> properties) protected voidafter()protected voidbefore()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 voidMethods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
-
ActiveMQProducerResource
public ActiveMQProducerResource(ServerLocator serverLocator, String address, String username, String password) -
ActiveMQProducerResource
-
ActiveMQProducerResource
public ActiveMQProducerResource(ServerLocator serverLocator, SimpleString address, String username, String password) -
ActiveMQProducerResource
-
-
Method Details
-
before
-
after
protected void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-
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)
-