You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/08/20 14:57:36 UTC
[activemq-artemis] 02/03: ARTEMIS-2451 Some additional tests
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit a48e2c9b6f2b54481acdcd26cdbe2caf50f715c1
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue Aug 20 10:49:39 2019 -0400
ARTEMIS-2451 Some additional tests
---
.../integration/amqp/QueueAutoCreationTest.java | 56 ++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java
index ed72104..5de4fb4 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java
@@ -134,6 +134,62 @@ public class QueueAutoCreationTest extends JMSClientTestSupport {
Assert.assertTrue(((ActiveMQDestination) topic).isCreated());
}
+ @Test(timeout = 30000)
+ // QueueAutoCreationTest was created to validate auto-creation of queues
+ // and this test was added to validate a regression: https://issues.apache.org/jira/browse/ARTEMIS-2238
+ public void testAutoCreateOnTopicManySends() throws Exception {
+ ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:5672");
+ Connection connection = factory.createConnection();
+ SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID();
+ System.out.println("Address is " + addressName);
+ clientSession.createAddress(addressName, RoutingType.ANYCAST, false);
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ for (int i = 0; i < 10; i++) {
+ Topic topic = new ActiveMQTopic(addressName.toString());
+ MessageProducer producer = session.createProducer(topic);
+ producer.send(session.createTextMessage("hello"));
+ producer.close();
+ Assert.assertTrue(((ActiveMQDestination) topic).isCreated());
+ }
+
+ }
+
+ @Test(timeout = 30000)
+ // QueueAutoCreationTest was created to validate auto-creation of queues
+ // and this test was added to validate a regression: https://issues.apache.org/jira/browse/ARTEMIS-2238
+ public void testAutoCreateOnTopicAndConsume() throws Exception {
+ ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:5672");
+ Connection connection = factory.createConnection();
+ SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID();
+ System.out.println("Address is " + addressName);
+ clientSession.createAddress(addressName, RoutingType.ANYCAST, false);
+
+ Connection recConnection = factory.createConnection();
+ Session recSession = recConnection.createSession(Session.AUTO_ACKNOWLEDGE);
+ Topic topicConsumer = recSession.createTopic(addressName.toString());
+ MessageConsumer consumer = recSession.createConsumer(topicConsumer);
+ recConnection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ for (int i = 0; i < 10; i++) {
+ Topic topic = session.createTopic(addressName.toString());
+ MessageProducer producer = session.createProducer(topic);
+ producer.send(session.createTextMessage("hello"));
+ producer.close();
+ Assert.assertTrue(((ActiveMQDestination) topic).isCreated());
+ }
+
+ for (int i = 0; i < 10; i++) {
+ TextMessage message = (TextMessage)consumer.receive(10_000);
+ Assert.assertNotNull(message);
+ Assert.assertEquals("hello", message.getText());
+ }
+
+ Assert.assertNull(consumer.receiveNoWait());
+
+ }
+
private void sendStringOfSize(int msgSize, boolean useCoreReceive) throws JMSException {
Connection conn = this.createConnection();