qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject qpid-jms-amqp-0-x git commit: QPID-8141: [JMS AMQP 0-x] Enforce resolution of destinations with unset legacy fields
Date Mon, 30 Apr 2018 13:05:59 GMT
Repository: qpid-jms-amqp-0-x
Updated Branches:
  refs/heads/master bcb5f70fd -> 4ef8f7a4e


QPID-8141: [JMS AMQP 0-x] Enforce resolution of destinations with unset legacy fields


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/commit/4ef8f7a4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/tree/4ef8f7a4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/diff/4ef8f7a4

Branch: refs/heads/master
Commit: 4ef8f7a4e313cc92885ad5d2e0c3833df16b7d1e
Parents: bcb5f70
Author: Alex Rudyy <orudyy@apache.org>
Authored: Mon Apr 30 13:54:59 2018 +0100
Committer: Alex Rudyy <orudyy@apache.org>
Committed: Mon Apr 30 13:54:59 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/client/AMQSession.java | 25 +++++++++-
 .../AddressBasedDestinationTest.java            | 48 ++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/4ef8f7a4/client/src/main/java/org/apache/qpid/client/AMQSession.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/qpid/client/AMQSession.java b/client/src/main/java/org/apache/qpid/client/AMQSession.java
index 63cc7a8..cba764e 100644
--- a/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -676,7 +676,30 @@ public abstract class AMQSession<C extends BasicMessageConsumer, P
extends Basic
 
     boolean isResolved(final AMQDestination dest)
     {
-        return _resolvedDestinations.contains(dest);
+        if (!_resolvedDestinations.contains(dest))
+        {
+            return false;
+        }
+
+        if (dest.getAddressType() == AMQDestination.QUEUE_TYPE)
+        {
+            // verify legacy fields are set
+            return dest.getQueueName() != null
+                   && dest.getQueueName().equals(dest.getAddressName())
+                   && dest.getExchangeName() != null
+                   && dest.getExchangeClass() != null
+                   && dest.getRoutingKey() != null;
+        }
+        else if (dest.getAddressType() == AMQDestination.TOPIC_TYPE)
+        {
+            // verify legacy fields are set
+            return dest.getExchangeName() != null
+                   && dest.getExchangeName().equals(dest.getAddressName())
+                   && dest.getExchangeClass() != null
+                   && (dest.getSubject() == null
+                        || (dest.getSubject() != null && dest.getSubject().equals(dest.getRoutingKey())));
+        }
+        return false;
     }
 
     public abstract int resolveAddressType(AMQDestination dest) throws QpidException;

http://git-wip-us.apache.org/repos/asf/qpid-jms-amqp-0-x/blob/4ef8f7a4/systests/src/test/java/org/apache/qpid/systest/destination/AddressBasedDestinationTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/systest/destination/AddressBasedDestinationTest.java
b/systests/src/test/java/org/apache/qpid/systest/destination/AddressBasedDestinationTest.java
index cced94d..395b410 100644
--- a/systests/src/test/java/org/apache/qpid/systest/destination/AddressBasedDestinationTest.java
+++ b/systests/src/test/java/org/apache/qpid/systest/destination/AddressBasedDestinationTest.java
@@ -373,6 +373,54 @@ public class AddressBasedDestinationTest extends JmsTestBase
         }
     }
 
+    @Test
+    public void ensureQueueDestinationAlwaysResolved() throws Exception
+    {
+        String address = String.format("ADDR:%s; {create: always, node: {type: queue}}",
getTestName());
+
+        Session session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+
+        MessageProducer producer = session.createProducer(null);
+        producer.send(session.createQueue(address), session.createTextMessage("A"));
+        producer.send(session.createQueue(address), session.createTextMessage("B"));
+        session.commit();
+
+        MessageConsumer consumer = session.createConsumer(session.createQueue(address));
+        Message messageA = consumer.receive(getReceiveTimeout());
+        assertNotNull("Message A is not received", messageA);
+        assertTrue("Unexpected type of message A", messageA instanceof TextMessage);
+        assertEquals("Unexpected content of message A", "A", ((TextMessage) messageA).getText());
+
+        Message messageB = consumer.receive(getReceiveTimeout());
+        assertNotNull("Message B is not received", messageB);
+        assertTrue("Unexpected type of message B", messageB instanceof TextMessage);
+        assertEquals("Unexpected content of message B", "B", ((TextMessage) messageB).getText());
+    }
+
+
+    @Test
+    public void ensureTopicDestinationAlwaysResolved() throws Exception
+    {
+        String address = String.format("ADDR:amq.topic/%s; {node: {type: topic}}", getTestName());
+        Session session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+        MessageConsumer consumer = session.createConsumer(session.createTopic(address));
+
+        MessageProducer producer = session.createProducer(null);
+        producer.send(session.createTopic(address), session.createTextMessage("A"));
+        producer.send(session.createTopic(address), session.createTextMessage("B"));
+        session.commit();
+
+        Message messageA = consumer.receive(getReceiveTimeout());
+        assertNotNull("Message A is not received", messageA);
+        assertTrue("Unexpected type of message A", messageA instanceof TextMessage);
+        assertEquals("Unexpected content of message A", "A", ((TextMessage) messageA).getText());
+
+        Message messageB = consumer.receive(getReceiveTimeout());
+        assertNotNull("Message B is not received", messageB);
+        assertTrue("Unexpected type of message B", messageB instanceof TextMessage);
+        assertEquals("Unexpected content of message B", "B", ((TextMessage) messageB).getText());
+    }
+
     private void createExchangeImpl(final boolean withExchangeArgs,
                                     final boolean useNonsenseArguments,
                                     final boolean useNonsenseExchangeType) throws Exception


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message