Class ActiveMQConsumerExtension
java.lang.Object
org.apache.activemq.artemis.junit.ActiveMQConsumerExtension
- All Implemented Interfaces:
ActiveMQConsumerOperations, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.Extension
public class ActiveMQConsumerExtension
extends Object
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, ActiveMQConsumerOperations
A JUnit Extension that embeds an Apache Artemis ClientConsumer 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 ClientConsumer, which can then be used to consume messages from an Apache Artemis server.
public class SimpleTest {
@RegisterExtension
private ActiveMQConsumerExtension client = new ActiveMQConsumerExtension( "vm://0", "test.queue" );
@Test
public void testSomething() throws Exception {
// Use the embedded client here
ClientMessage message = client.receiveMessage();
}
}
-
Constructor Summary
ConstructorsConstructorDescriptionActiveMQConsumerExtension(String url, String queueName) ActiveMQConsumerExtension(String url, String queueName, String username, String password) ActiveMQConsumerExtension(String url, SimpleString queueName) ActiveMQConsumerExtension(String url, SimpleString queueName, String username, String password) ActiveMQConsumerExtension(ServerLocator serverLocator, String queueName) ActiveMQConsumerExtension(ServerLocator serverLocator, String queueName, String username, String password) ActiveMQConsumerExtension(ServerLocator serverLocator, SimpleString queueName) ActiveMQConsumerExtension(ServerLocator serverLocator, SimpleString queueName, 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 voidlongbooleanreceiveMessage(long timeout) voidsetAutoCreateQueue(boolean autoCreateQueue) voidsetDefaultReceiveTimeout(long defaultReceiveTimeout) protected void
-
Constructor Details
-
ActiveMQConsumerExtension
-
ActiveMQConsumerExtension
-
ActiveMQConsumerExtension
public ActiveMQConsumerExtension(String url, SimpleString queueName, String username, String password) -
ActiveMQConsumerExtension
-
ActiveMQConsumerExtension
public ActiveMQConsumerExtension(ServerLocator serverLocator, String queueName, String username, String password) -
ActiveMQConsumerExtension
-
ActiveMQConsumerExtension
public ActiveMQConsumerExtension(ServerLocator serverLocator, SimpleString queueName, String username, String password) -
ActiveMQConsumerExtension
-
-
Method Details
-
beforeAll
-
afterAll
-
getDefaultReceiveTimeout
public long getDefaultReceiveTimeout()- Specified by:
getDefaultReceiveTimeoutin interfaceActiveMQConsumerOperations
-
setDefaultReceiveTimeout
public void setDefaultReceiveTimeout(long defaultReceiveTimeout) - Specified by:
setDefaultReceiveTimeoutin interfaceActiveMQConsumerOperations
-
createClient
protected void createClient() -
stopClient
protected void stopClient() -
isAutoCreateQueue
public boolean isAutoCreateQueue()- Specified by:
isAutoCreateQueuein interfaceActiveMQConsumerOperations
-
setAutoCreateQueue
public void setAutoCreateQueue(boolean autoCreateQueue) - Specified by:
setAutoCreateQueuein interfaceActiveMQConsumerOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceActiveMQConsumerOperations
-
receiveMessage
- Specified by:
receiveMessagein interfaceActiveMQConsumerOperations
-
addMessageProperties
-