From a9c3e437d87625c049ac78b0811064cd646a9f2e Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Fri, 24 Mar 2017 16:05:18 +0000 Subject: [PATCH] ARTEMIS-1068 Add Routing Exclusivity test for JMS AMQP --- .../tests/integration/amqp/ProtonTest.java | 45 +++++++++++++++++++ .../integration/client/AcknowledgeTest.java | 1 - .../tests/integration/client/RoutingTest.java | 1 - 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java index 1308c37b3b..fb5e90a3ae 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/ProtonTest.java @@ -79,6 +79,7 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.utils.ByteUtil; import org.apache.activemq.artemis.utils.TimeUtils; +import org.apache.activemq.artemis.utils.UUIDGenerator; import org.apache.activemq.artemis.utils.VersionLoader; import org.apache.activemq.transport.amqp.client.AmqpClient; import org.apache.activemq.transport.amqp.client.AmqpConnection; @@ -1855,6 +1856,50 @@ public class ProtonTest extends ProtonTestBase { } } + /** + * If we have an address configured with both ANYCAST and MULTICAST routing types enabled, we must ensure that any + * messages sent specifically to MULTICAST (e.g. JMS TopicProducer) are only delivered to MULTICAST queues (e.g. + * i.e. subscription queues) and **NOT** to ANYCAST queues (e.g. JMS Queue). + * + * @throws Exception + */ + @Test + public void testRoutingExclusivity() throws Exception { + + // Create Address with both ANYCAST and MULTICAST enabled + String testAddress = "testRoutingExclusivity"; + SimpleString ssTestAddress = new SimpleString(testAddress); + + AddressInfo addressInfo = new AddressInfo(ssTestAddress); + addressInfo.addRoutingType(RoutingType.MULTICAST); + addressInfo.addRoutingType(RoutingType.ANYCAST); + + server.addAddressInfo(addressInfo); + server.createQueue(ssTestAddress, RoutingType.ANYCAST, ssTestAddress, null, true, false); + + Connection connection = createConnection(UUIDGenerator.getInstance().generateStringUUID()); + + try { + + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + + Topic topic = session.createTopic(testAddress); + javax.jms.Queue queue = session.createQueue(testAddress); + + MessageProducer producer = session.createProducer(topic); + + MessageConsumer queueConsumer = session.createConsumer(queue); + MessageConsumer topicConsumer = session.createConsumer(topic); + + producer.send(session.createTextMessage("testMessage")); + + assertNotNull(topicConsumer.receive(1000)); + assertNull(queueConsumer.receive(1000)); + } finally { + connection.close(); + } + } + @Test public void testReleaseDisposition() throws Exception { AmqpClient client = new AmqpClient(new URI(tcpAmqpConnectionUri), userName, password); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java index 604b630811..d7c9855701 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java @@ -28,7 +28,6 @@ import org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException; import org.apache.activemq.artemis.api.core.ICoreMessage; import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.RefCountMessage; -import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java index 8de6958d49..9d66b61637 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/RoutingTest.java @@ -19,7 +19,6 @@ package org.apache.activemq.artemis.tests.integration.client; import java.util.HashSet; import java.util.Set; -import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage;