Class EmbeddedActiveMQResource
java.lang.Object
org.junit.rules.ExternalResource
org.apache.activemq.artemis.junit.EmbeddedActiveMQResource
- All Implemented Interfaces:
EmbeddedActiveMQOperations, org.junit.rules.TestRule
public class EmbeddedActiveMQResource
extends org.junit.rules.ExternalResource
implements EmbeddedActiveMQOperations
A JUnit Rule that embeds an ActiveMQ Artemis server into a test. This JUnit Rule is designed to simplify using
embedded servers in unit tests. Adding the rule to a test will startup an embedded server, which can then be used by
client applications.
public class SimpleTest {
@Rule
public EmbeddedActiveMQResource server = new EmbeddedActiveMQResource();
@Test
public void testSomething() throws Exception {
// Use the embedded server here
}
}
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a default EmbeddedActiveMQResourceEmbeddedActiveMQResource(int serverId) Create a default EmbeddedActiveMQResource with the specified serverIdEmbeddedActiveMQResource(String filename) Creates an EmbeddedActiveMQResource using the specified configuration fileEmbeddedActiveMQResource(Configuration configuration) Creates an EmbeddedActiveMQResource using the specified configuration -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMessageProperties(ClientMessage message, Map<String, Object> properties) Add the specified properties to the specified message.protected voidafter()Invoked by JUnit to tear down the resource - stops the embedded ActiveMQ Artemis serverprotected voidbefore()Invoked by JUnit to setup the resource - start the embedded ActiveMQ Artemis serverbrowseMessage(String queueName) browseMessage(String queueName, long timeout) browseMessage(SimpleString queueName) browseMessage(SimpleString queueName, long timeout) createMessage(byte[] body) createMessage(String body) createMessageWithProperties(byte[] body, Map<String, Object> properties) createMessageWithProperties(String body, Map<String, Object> properties) createMessageWithProperties(Map<String, Object> properties) org.apache.activemq.artemis.core.server.QueuecreateQueue(String name) org.apache.activemq.artemis.core.server.QueuecreateQueue(String address, String name) org.apache.activemq.artemis.core.server.QueuecreateQueue(SimpleString address, SimpleString name) voidcreateSharedQueue(String name, String user) voidcreateSharedQueue(String address, String name, String user) voidcreateSharedQueue(SimpleString address, SimpleString name, SimpleString user) List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(String address) List<org.apache.activemq.artemis.core.server.Queue> getBoundQueues(SimpleString address) longlonggetMessageCount(String queueName) longgetMessageCount(SimpleString queueName) org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQgetVmURL()booleanbooleanorg.apache.activemq.artemis.core.server.QueuelocateQueue(String queueName) org.apache.activemq.artemis.core.server.QueuelocateQueue(SimpleString queueName) receiveMessage(String queueName) receiveMessage(String queueName, long timeout) receiveMessage(SimpleString queueName) receiveMessage(SimpleString queueName, long timeout) sendMessage(String address, byte[] body) sendMessage(String address, String body) voidsendMessage(String address, ClientMessage message) sendMessage(SimpleString address, byte[] body) sendMessage(SimpleString address, String body) voidsendMessage(SimpleString address, ClientMessage message) sendMessageWithProperties(String address, byte[] body, Map<String, Object> properties) sendMessageWithProperties(String address, Map<String, Object> properties) sendMessageWithProperties(SimpleString address, byte[] body, Map<String, Object> properties) sendMessageWithProperties(SimpleString address, String body, Map<String, Object> properties) sendMessageWithProperties(SimpleString address, Map<String, Object> properties) voidsetDefaultReceiveTimeout(long defaultReceiveTimeout) voidsetUseDurableMessage(boolean useDurableMessage) voidsetUseDurableQueue(boolean useDurableQueue) voidstart()voidstop()Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
EmbeddedActiveMQResource
public EmbeddedActiveMQResource()Create a default EmbeddedActiveMQResource -
EmbeddedActiveMQResource
public EmbeddedActiveMQResource(int serverId) Create a default EmbeddedActiveMQResource with the specified serverId- Parameters:
serverId- server id
-
EmbeddedActiveMQResource
Creates an EmbeddedActiveMQResource using the specified configuration- Parameters:
configuration- ActiveMQServer configuration
-
EmbeddedActiveMQResource
Creates an EmbeddedActiveMQResource using the specified configuration file- Parameters:
filename- ActiveMQServer configuration file name
-
-
Method Details
-
addMessageProperties
Add the specified properties to the specified message.- See Also:
-
start
public void start()- Specified by:
startin interfaceEmbeddedActiveMQOperations
-
stop
public void stop()- Specified by:
stopin interfaceEmbeddedActiveMQOperations
-
before
-
after
protected void after()Invoked by JUnit to tear down the resource - stops the embedded ActiveMQ Artemis server- Overrides:
afterin classorg.junit.rules.ExternalResource
-
isUseDurableMessage
public boolean isUseDurableMessage()- Specified by:
isUseDurableMessagein interfaceEmbeddedActiveMQOperations
-
setUseDurableMessage
public void setUseDurableMessage(boolean useDurableMessage) - Specified by:
setUseDurableMessagein interfaceEmbeddedActiveMQOperations
-
isUseDurableQueue
public boolean isUseDurableQueue()- Specified by:
isUseDurableQueuein interfaceEmbeddedActiveMQOperations
-
setUseDurableQueue
public void setUseDurableQueue(boolean useDurableQueue) - Specified by:
setUseDurableQueuein interfaceEmbeddedActiveMQOperations
-
getDefaultReceiveTimeout
public long getDefaultReceiveTimeout()- Specified by:
getDefaultReceiveTimeoutin interfaceEmbeddedActiveMQOperations
-
setDefaultReceiveTimeout
public void setDefaultReceiveTimeout(long defaultReceiveTimeout) - Specified by:
setDefaultReceiveTimeoutin interfaceEmbeddedActiveMQOperations
-
getServer
public org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ getServer()- Specified by:
getServerin interfaceEmbeddedActiveMQOperations
-
getServerName
- Specified by:
getServerNamein interfaceEmbeddedActiveMQOperations
-
getVmURL
- Specified by:
getVmURLin interfaceEmbeddedActiveMQOperations
-
getMessageCount
- Specified by:
getMessageCountin interfaceEmbeddedActiveMQOperations
-
getMessageCount
- Specified by:
getMessageCountin interfaceEmbeddedActiveMQOperations
-
locateQueue
- Specified by:
locateQueuein interfaceEmbeddedActiveMQOperations
-
locateQueue
- Specified by:
locateQueuein interfaceEmbeddedActiveMQOperations
-
getBoundQueues
- Specified by:
getBoundQueuesin interfaceEmbeddedActiveMQOperations
-
getBoundQueues
- Specified by:
getBoundQueuesin interfaceEmbeddedActiveMQOperations
-
createQueue
- Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createQueue
- Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createQueue
public org.apache.activemq.artemis.core.server.Queue createQueue(SimpleString address, SimpleString name) - Specified by:
createQueuein interfaceEmbeddedActiveMQOperations
-
createMessage
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations
-
createMessage
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations
-
createMessage
- Specified by:
createMessagein interfaceEmbeddedActiveMQOperations
-
createMessageWithProperties
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
createMessageWithProperties
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
createMessageWithProperties
- Specified by:
createMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(String address, byte[] body, Map<String, Object> properties) - Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(String address, String body, Map<String, Object> properties) - Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessage
- Specified by:
sendMessagein interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
- Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(SimpleString address, byte[] body, Map<String, Object> properties) - Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
sendMessageWithProperties
public ClientMessage sendMessageWithProperties(SimpleString address, String body, Map<String, Object> properties) - Specified by:
sendMessageWithPropertiesin interfaceEmbeddedActiveMQOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceEmbeddedActiveMQOperations
-
browseMessage
- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations
-
browseMessage
- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations
-
browseMessage
- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations
-
browseMessage
- Specified by:
browseMessagein interfaceEmbeddedActiveMQOperations
-