You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2014/12/22 17:39:49 UTC

[1/7] qpid-jms git commit: move/remove some test-only constants

Repository: qpid-jms
Updated Branches:
  refs/heads/master 512418727 -> 04d7f274c


move/remove some test-only constants


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/d516e8eb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/d516e8eb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/d516e8eb

Branch: refs/heads/master
Commit: d516e8ebb34b2a7304d0bbc0201c82e22ae2fe1c
Parents: 5124187
Author: Robert Gemmell <ro...@apache.org>
Authored: Sun Dec 21 20:51:43 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Sun Dec 21 20:51:43 2014 +0000

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelper.java     | 12 ++-----
 .../jms/integration/MessageIntegrationTest.java |  4 +--
 .../amqp/message/AmqpDestinationHelperTest.java | 37 ++++++++++----------
 3 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d516e8eb/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index da10adb..f2c2cb3 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -44,15 +44,9 @@ public class AmqpDestinationHelper {
     public static final byte TEMP_TOPIC_TYPE = 0x03;
 
     // For support of old string type values
-    static final String QUEUE_ATTRIBUTE = "queue";
-    static final String TOPIC_ATTRIBUTE = "topic";
-    static final String TEMPORARY_ATTRIBUTE = "temporary";
-
-    // TODO - Can we move these to the test code as we don't write these anymore.
-    public static final String QUEUE_ATTRIBUTES_STRING = QUEUE_ATTRIBUTE;
-    public static final String TOPIC_ATTRIBUTES_STRING = TOPIC_ATTRIBUTE;
-    public static final String TEMP_QUEUE_ATTRIBUTES_STRING = QUEUE_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
-    public static final String TEMP_TOPIC_ATTRIBUTES_STRING = TOPIC_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
+    public static final String QUEUE_ATTRIBUTE = "queue";
+    public static final String TOPIC_ATTRIBUTE = "topic";
+    public static final String TEMPORARY_ATTRIBUTE = "temporary";
 
     /**
      * Decode the provided To address, type description, and consumer destination

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d516e8eb/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
index ba64434..7f7a4b5 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
@@ -752,7 +752,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Queue queue = session.createQueue("myQueue");
 
             MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
-            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTES_STRING);
+            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
 
             PropertiesDescribedType props = new PropertiesDescribedType();
             String myTopicAddress = "myTopicAddress";
@@ -794,7 +794,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Queue queue = session.createQueue("myQueue");
 
             MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
-            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTES_STRING);
+            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
 
             PropertiesDescribedType props = new PropertiesDescribedType();
             String myTopicAddress = "myTopicAddress";

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d516e8eb/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
index 852199f..54a5dcd 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
@@ -16,14 +16,13 @@
  */
 package org.apache.qpid.jms.provider.amqp.message;
 
-import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_ATTRIBUTE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_TYPE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
-import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TEMP_QUEUE_ATTRIBUTES_STRING;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TEMPORARY_ATTRIBUTE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TEMP_QUEUE_TYPE;
-import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TEMP_TOPIC_ATTRIBUTES_STRING;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TEMP_TOPIC_TYPE;
-import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TOPIC_ATTRIBUTES_STRING;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TOPIC_ATTRIBUTE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TOPIC_TYPE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
 import static org.junit.Assert.assertEquals;
@@ -46,6 +45,8 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class AmqpDestinationHelperTest {
+    public static final String TEMP_QUEUE_ATTRIBUTES_STRING = QUEUE_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
+    public static final String TEMP_TOPIC_ATTRIBUTES_STRING = TOPIC_ATTRIBUTE + "," + TEMPORARY_ATTRIBUTE;
 
     private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
 
@@ -56,7 +57,7 @@ public class AmqpDestinationHelperTest {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getToAddress()).thenReturn(null);
         Mockito.when(message.getMessageAnnotation(
-            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
 
         assertNull(helper.getJmsDestination(message, null));
     }
@@ -66,7 +67,7 @@ public class AmqpDestinationHelperTest {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getToAddress()).thenReturn(null);
         Mockito.when(message.getMessageAnnotation(
-            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
 
         JmsDestination consumerDestination = new JmsQueue("ConsumerDestination");
         assertSame(consumerDestination, helper.getJmsDestination(message, consumerDestination));
@@ -203,7 +204,7 @@ public class AmqpDestinationHelperTest {
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
 
         JmsDestination destination = helper.getJmsDestination(message, null);
         assertNotNull(destination);
@@ -219,7 +220,7 @@ public class AmqpDestinationHelperTest {
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TOPIC_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TOPIC_ATTRIBUTE);
 
         JmsDestination destination = helper.getJmsDestination(message, null);
         assertNotNull(destination);
@@ -263,7 +264,7 @@ public class AmqpDestinationHelperTest {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(null);
         Mockito.when(message.getMessageAnnotation(
-            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
 
         assertNull(helper.getJmsDestination(message, null));
     }
@@ -273,7 +274,7 @@ public class AmqpDestinationHelperTest {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(null);
         Mockito.when(message.getMessageAnnotation(
-            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
         JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         assertNull(helper.getJmsReplyTo(message, consumerDestination));
@@ -408,7 +409,7 @@ public class AmqpDestinationHelperTest {
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTE);
 
         JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);
@@ -424,7 +425,7 @@ public class AmqpDestinationHelperTest {
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TOPIC_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TOPIC_ATTRIBUTE);
 
         JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);
@@ -646,27 +647,27 @@ public class AmqpDestinationHelperTest {
         assertNull(helper.splitAttributesString(null));
 
         // test a single comma separator produces expected set
-        assertEquals(set, helper.splitAttributesString(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+        assertEquals(set, helper.splitAttributesString(QUEUE_ATTRIBUTE + "," +
                                                  AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
 
         // test trailing comma doesn't alter produced set
-        assertEquals(set, helper.splitAttributesString(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+        assertEquals(set, helper.splitAttributesString(QUEUE_ATTRIBUTE + "," +
                                                  AmqpDestinationHelper.TEMPORARY_ATTRIBUTE + ","));
 
         // test leading comma doesn't alter produced set
-        assertEquals(set, helper.splitAttributesString("," + AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ","
+        assertEquals(set, helper.splitAttributesString("," + QUEUE_ATTRIBUTE + ","
                                                      + AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
 
         // test consecutive central commas don't alter produced set
-        assertEquals(set, helper.splitAttributesString(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ",," +
+        assertEquals(set, helper.splitAttributesString(QUEUE_ATTRIBUTE + ",," +
                                                  AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
 
         // test consecutive trailing commas don't alter produced set
-        assertEquals(set, helper.splitAttributesString(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+        assertEquals(set, helper.splitAttributesString(QUEUE_ATTRIBUTE + "," +
                                                  AmqpDestinationHelper.TEMPORARY_ATTRIBUTE + ",,"));
 
         // test consecutive leading commas don't alter produced set
-        assertEquals(set, helper.splitAttributesString("," + AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ","
+        assertEquals(set, helper.splitAttributesString("," + QUEUE_ATTRIBUTE + ","
                                                      + AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
     }
 }


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


[5/7] qpid-jms git commit: add support for queue+topic prefixes being defined by the server via connection properties

Posted by ro...@apache.org.
add support for queue+topic prefixes being defined by the server via connection properties


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/c6a5498d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/c6a5498d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/c6a5498d

Branch: refs/heads/master
Commit: c6a5498d05a46141543c80bb6cf9618126617cd5
Parents: d4016cb
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 22 14:26:57 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 22 14:26:57 2014 +0000

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpConnection.java  |  12 +
 .../provider/amqp/AmqpConnectionProperties.java |  28 ++-
 .../jms/integration/MessageIntegrationTest.java | 225 +++++++++++++++++++
 3 files changed, 264 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c6a5498d/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
index 1bc1f53..6423365 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnection.java
@@ -125,6 +125,18 @@ public class AmqpConnection extends AmqpAbstractResource<JmsConnectionInfo, Conn
             this.properties = new AmqpConnectionProperties(
                 getEndpoint().getRemoteOfferedCapabilities(), getEndpoint().getRemoteProperties());
 
+            String brokerQueuePrefix = properties.getQueuePrefix();
+            if (brokerQueuePrefix != null) {
+                queuePrefix = brokerQueuePrefix;
+                resource.setQueuePrefix(brokerQueuePrefix);
+            }
+
+            String brokerTopicPrefix = properties.getTopicPrefix();
+            if (brokerTopicPrefix != null) {
+                topicPrefix = brokerTopicPrefix;
+                resource.setTopicPrefix(brokerTopicPrefix);
+            }
+
             connectionSession.open(new AsyncResult() {
 
                 @Override

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c6a5498d/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
index c3b0297..de513f5 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConnectionProperties.java
@@ -30,8 +30,12 @@ import org.apache.qpid.proton.amqp.Symbol;
 public class AmqpConnectionProperties {
 
     public static final Symbol ANONYMOUS_RELAY = Symbol.valueOf("ANONYMOUS-RELAY");
+    public static final Symbol QUEUE_PREFIX = Symbol.valueOf("queue-prefix");
+    public static final Symbol TOPIC_PREFIX = Symbol.valueOf("topic-prefix");
 
     private boolean anonymousRelaySupported = false;
+    private String queuePrefix = null;
+    private String topicPrefix = null;
 
     /**
      * Creates a new instance of this class from the given remote capabilities and properties.
@@ -61,10 +65,32 @@ public class AmqpConnectionProperties {
     }
 
     protected void processProperties(Map<Symbol, Object> properties) {
-        // TODO - Inspect properties for configuration options
+        if (properties.containsKey(QUEUE_PREFIX)) {
+            Object o = properties.get(QUEUE_PREFIX);
+            if (o instanceof String) {
+                queuePrefix = (String) o;
+            }
+        }
+
+        if (properties.containsKey(TOPIC_PREFIX)) {
+            Object o = properties.get(TOPIC_PREFIX);
+            if (o instanceof String) {
+                topicPrefix = (String) o;
+            }
+        }
+
+        // TODO - Inspect properties for any other configuration options
     }
 
     public boolean isAnonymousRelaySupported() {
         return anonymousRelaySupported;
     }
+
+    public String getQueuePrefix() {
+        return queuePrefix;
+    }
+
+    public String getTopicPrefix() {
+        return topicPrefix;
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/c6a5498d/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
index 6590fc2..a36307b 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
@@ -26,9 +26,12 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
 
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
 import javax.jms.Connection;
@@ -44,6 +47,7 @@ import javax.jms.Topic;
 
 import org.apache.qpid.jms.JmsClientProperties;
 import org.apache.qpid.jms.JmsConnection;
+import org.apache.qpid.jms.provider.amqp.AmqpConnectionProperties;
 import org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper;
 import org.apache.qpid.jms.provider.amqp.message.AmqpMessageIdHelper;
 import org.apache.qpid.jms.provider.amqp.message.AmqpMessageSupport;
@@ -652,6 +656,227 @@ public class MessageIntegrationTest extends QpidJmsTestCase
         }
     }
 
+    /**
+     * Tests that a connection with 'prefixes' set on it via broker-provided connection properties
+     * strips the prefix from the to/reply-to fields for incoming messages with Topic destinations.
+     */
+    @Test(timeout = 2000)
+    public void testReceivedMessageWithTopicDestinationsOnConnectionWithBrokerDefinedPrefixProperties() throws Exception {
+        Class<? extends Destination> destType = Topic.class;
+        String destPrefix = "t-broker-provided-prefix-";
+        String destName = "myTopic";
+        String replyName = "myReplyTopic";
+        String destAddress = destPrefix + destName;
+        String replyAddress = destPrefix + replyName;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+        Byte annotationValue = AmqpDestinationHelper.TOPIC_TYPE;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+        Byte replyAnnotationValue = AmqpDestinationHelper.TOPIC_TYPE;
+
+        doReceivedMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(destType, destPrefix, destName, replyName,
+                                                                        destAddress, replyAddress, annotationName,
+                                                                        annotationValue, replyAnnotationName, replyAnnotationValue);
+    }
+
+    /**
+     * Tests that a connection with 'prefixes' set on it via broker-provided connection properties
+     * strips the prefix from the to/reply-to fields for incoming messages with Queue destinations.
+     */
+    @Test(timeout = 2000)
+    public void testReceivedMessageWithQueueDestinationsOnConnectionWithBrokerDefinedPrefixProperties() throws Exception {
+        Class<? extends Destination> destType = Queue.class;
+        String destPrefix = "q-broker-provided-prefix-";
+        String destName = "myQueue";
+        String replyName = "myReplyQueue";
+        String destAddress = destPrefix + destName;
+        String replyAddress = destPrefix + replyName;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+        Byte annotationValue = AmqpDestinationHelper.QUEUE_TYPE;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+        Byte replyAnnotationValue = AmqpDestinationHelper.QUEUE_TYPE;
+
+        doReceivedMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(destType, destPrefix, destName, replyName,
+                                                                        destAddress, replyAddress, annotationName,
+                                                                        annotationValue, replyAnnotationName, replyAnnotationValue);
+    }
+
+    private void doReceivedMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(Class<? extends Destination> destType,
+                                                                                  String destPrefix,
+                                                                                  String destName,
+                                                                                  String replyName,
+                                                                                  String destAddress,
+                                                                                  String replyAddress,
+                                                                                  String annotationName,
+                                                                                  Object annotationValue,
+                                                                                  String replyAnnotationName,
+                                                                                  Object replyAnnotationValue) throws Exception {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) {
+            // Have the test peer provide the destination prefixes as connection properties
+            Map<Symbol, Object> properties = new HashMap<Symbol, Object>();
+            properties.put(AmqpConnectionProperties.QUEUE_PREFIX, destPrefix);
+            properties.put(AmqpConnectionProperties.TOPIC_PREFIX, destPrefix);
+
+            Connection connection = testFixture.establishConnecton(testPeer, null, null, properties);
+            connection.start();
+
+            testPeer.expectBegin(true);
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            // Create the destination
+            Destination dest = null;
+            if (destType == Topic.class) {
+                dest= session.createTopic(destName);
+            } else if (destType == Queue.class) {
+                dest = session.createQueue(destName);
+            } else {
+                fail("non-temporary destination type set");
+            }
+
+            MessageAnnotationsDescribedType msgAnnotations = null;
+            if (annotationName != null || replyAnnotationName != null) {
+                msgAnnotations = new MessageAnnotationsDescribedType();
+                if (annotationName != null) {
+                    msgAnnotations.setSymbolKeyedAnnotation(annotationName, annotationValue);
+                }
+
+                if (replyAnnotationName != null) {
+                    msgAnnotations.setSymbolKeyedAnnotation(replyAnnotationName, replyAnnotationValue);
+                }
+            }
+
+            PropertiesDescribedType props = new PropertiesDescribedType();
+            props.setTo(destAddress);
+            props.setReplyTo(replyAddress);
+            DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);
+
+            SourceMatcher sourceMatcher = new SourceMatcher();
+            sourceMatcher.withAddress(equalTo(destAddress));
+
+            testPeer.expectReceiverAttach(notNullValue(), sourceMatcher);
+            testPeer.expectLinkFlowRespondWithTransfer(null, msgAnnotations, props, null, amqpValueNullContent);
+            testPeer.expectDispositionThatIsAcceptedAndSettled();
+
+            MessageConsumer messageConsumer = session.createConsumer(dest);
+            Message receivedMessage = messageConsumer.receive(1000);
+
+            testPeer.waitForAllHandlersToComplete(2000);
+            assertNotNull(receivedMessage);
+
+            Destination jmsDest = receivedMessage.getJMSDestination();
+            Destination jmsReplyTo = receivedMessage.getJMSReplyTo();
+
+            assertNotNull("Expected JMSDestination but got null", jmsDest);
+            assertNotNull("Expected JMSReplyTo but got null", jmsReplyTo);
+
+            // Verify destination/replyto names on received message
+            String recievedName = null;
+            String recievedReplyName = null;
+            if (destType == Topic.class) {
+                recievedName = ((Topic) jmsDest).getTopicName();
+                recievedReplyName = ((Topic) jmsReplyTo).getTopicName();
+            } else if (destType == Queue.class) {
+                recievedName = ((Queue) jmsDest).getQueueName();
+                recievedReplyName = ((Queue) jmsReplyTo).getQueueName();
+            }
+
+            assertEquals("Unexpected name for JMSDestination", destName, recievedName);
+            assertEquals("Unexpected name for JMSReplyTo", replyName, recievedReplyName);
+        }
+    }
+
+    /**
+     * Tests that the a connection with a 'queue prefix' set on it via broker-provided connection
+     * properties adds the prefix to the content of the to/reply-to fields for outgoing messages.
+     */
+    @Test(timeout = 2000)
+    public void testSendMessageWithQueueDestinationsOnConnectionWithBrokerDefinedPrefixProperties() throws Exception {
+        Class<? extends Destination> destType = Queue.class;
+        String destPrefix = "q-broker-provided-prefix-";
+        String destName = "myQueue";
+        String destAddress = destPrefix + destName;
+        Byte annotationValue = AmqpDestinationHelper.QUEUE_TYPE;
+
+        doSendMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(destType, destPrefix, destName, destAddress, annotationValue);
+    }
+
+    /**
+     * Tests that the a connection with a 'topic prefix' set on it via broker-provided connection
+     * properties adds the prefix to the content of the to/reply-to fields for outgoing messages.
+     */
+    @Test(timeout = 2000)
+    public void testSendMessageWithTopicDestinationsOnConnectionWithBrokerDefinedPrefixProperties() throws Exception {
+        Class<? extends Destination> destType = Topic.class;
+        String destPrefix = "t-broker-provided-prefix-";
+        String destName = "myTopic";
+        String destAddress = destPrefix + destName;
+        Byte annotationValue = AmqpDestinationHelper.TOPIC_TYPE;
+
+        doSendMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(destType, destPrefix, destName, destAddress, annotationValue);
+    }
+
+    private void doSendMessageOnConnectionWithBrokerDefinedPrefixPropertiesTestImpl(Class<? extends Destination> destType,
+                                                             String destPrefix,
+                                                             String destName,
+                                                             String destAddress,
+                                                             Byte destTypeAnnotationValue) throws Exception {
+        try (TestAmqpPeer testPeer = new TestAmqpPeer(IntegrationTestFixture.PORT);) {
+            // Have the test peer provide the destination prefixes as connection properties
+            Map<Symbol, Object> properties = new HashMap<Symbol, Object>();
+            properties.put(AmqpConnectionProperties.QUEUE_PREFIX, destPrefix);
+            properties.put(AmqpConnectionProperties.TOPIC_PREFIX, destPrefix);
+
+            Connection connection = testFixture.establishConnecton(testPeer, null, null, properties);
+
+            connection.start();
+
+            testPeer.expectBegin(true);
+
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+            // Create the destination
+            Destination dest = null;
+            if (destType == Topic.class) {
+                dest = session.createTopic(destName);
+            } else if (destType == Queue.class) {
+                dest = session.createQueue(destName);
+            } else {
+                fail("non-temporary destination type set");
+            }
+
+            TargetMatcher targetMatcher = new TargetMatcher();
+            targetMatcher.withAddress(equalTo(destAddress));
+
+            testPeer.expectSenderAttach(targetMatcher, false, false);
+
+            MessageProducer producer = session.createProducer(dest);
+
+            MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true);
+            MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
+            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME), equalTo(destTypeAnnotationValue));
+            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME), equalTo(destTypeAnnotationValue));
+            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
+            propsMatcher.withTo(equalTo(destAddress));
+            propsMatcher.withReplyTo(equalTo(destAddress));
+
+            TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
+            messageMatcher.setHeadersMatcher(headersMatcher);
+            messageMatcher.setMessageAnnotationsMatcher(msgAnnotationsMatcher);
+            messageMatcher.setPropertiesMatcher(propsMatcher);
+
+            //TODO: currently we aren't sending any body section, decide if this is allowed
+            //messageMatcher.setMessageContentMatcher(new EncodedAmqpValueMatcher(null));
+            testPeer.expectTransfer(messageMatcher);
+
+            Message message = session.createMessage();
+            message.setJMSReplyTo(dest);
+
+            producer.send(message);
+
+            testPeer.waitForAllHandlersToComplete(2000);
+        }
+    }
+
     // --- byte type annotation values --- //
 
     /**


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


[4/7] qpid-jms git commit: add support to test peer for sending server connection properties

Posted by ro...@apache.org.
add support to test peer for sending server connection properties


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/d4016cb9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/d4016cb9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/d4016cb9

Branch: refs/heads/master
Commit: d4016cb9fb32ad373ad3eebfaf42569b57b223a2
Parents: 84383f0
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 22 13:18:39 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 22 13:18:39 2014 +0000

----------------------------------------------------------------------
 .../jms/integration/IntegrationTestFixture.java     | 16 +++++++++++-----
 .../apache/qpid/jms/test/testpeer/TestAmqpPeer.java |  8 +++++++-
 2 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d4016cb9/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IntegrationTestFixture.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IntegrationTestFixture.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IntegrationTestFixture.java
index 6dd0244..7688da5 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IntegrationTestFixture.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/IntegrationTestFixture.java
@@ -20,6 +20,8 @@ package org.apache.qpid.jms.integration;
 
 import static org.junit.Assert.assertNull;
 
+import java.util.Map;
+
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
@@ -32,19 +34,23 @@ public class IntegrationTestFixture {
     static final int PORT = 25672;
 
     Connection establishConnecton(TestAmqpPeer testPeer) throws JMSException {
-        return establishConnecton(testPeer, null, null);
+        return establishConnecton(testPeer, null, null, null);
     }
 
     Connection establishConnecton(TestAmqpPeer testPeer, String optionsString) throws JMSException {
-        return establishConnecton(testPeer, optionsString, null);
+        return establishConnecton(testPeer, optionsString, null, null);
     }
 
     Connection establishConnecton(TestAmqpPeer testPeer, Symbol[] serverCapabilities) throws JMSException {
-        return establishConnecton(testPeer, null, serverCapabilities);
+        return establishConnecton(testPeer, null, serverCapabilities, null);
+    }
+
+    Connection establishConnecton(TestAmqpPeer testPeer, Symbol[] serverCapabilities, Map<Symbol, Object> serverProperties) throws JMSException {
+        return establishConnecton(testPeer, null, serverCapabilities, serverProperties);
     }
 
-    Connection establishConnecton(TestAmqpPeer testPeer, String optionsString, Symbol[] serverCapabilities) throws JMSException {
-        testPeer.expectPlainConnect("guest", "guest", serverCapabilities);
+    Connection establishConnecton(TestAmqpPeer testPeer, String optionsString, Symbol[] serverCapabilities, Map<Symbol, Object> serverProperties) throws JMSException {
+        testPeer.expectPlainConnect("guest", "guest", serverCapabilities, serverProperties);
 
         // Each connection creates a session for managing temporary destinations etc
         testPeer.expectBegin(true);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d4016cb9/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index 51f3825..3cf94aa 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -27,6 +27,7 @@ import static org.hamcrest.Matchers.nullValue;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -315,7 +316,7 @@ public class TestAmqpPeer implements AutoCloseable
                     null)));
     }
 
-    public void expectPlainConnect(String username, String password, Symbol[] serverCapabilities)
+    public void expectPlainConnect(String username, String password, Symbol[] serverCapabilities, Map<Symbol, Object> serverProperties)
     {
         SaslMechanismsFrame saslMechanismsFrame = new SaslMechanismsFrame().setSaslServerMechanisms(Symbol.valueOf("PLAIN"));
         addHandler(new HeaderHandlerImpl(AmqpHeader.SASL_HEADER, AmqpHeader.SASL_HEADER,
@@ -355,6 +356,11 @@ public class TestAmqpPeer implements AutoCloseable
             open.setOfferedCapabilities(serverCapabilities);
         }
 
+        if(serverProperties != null)
+        {
+            open.setProperties(serverProperties);
+        }
+
         addHandler(new OpenMatcher()
             .withContainerId(notNullValue(String.class))
             .onSuccess(new FrameSender(


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


[2/7] qpid-jms git commit: check new byte annotations first for JMSDestination/JMSReplyTo type on received messages

Posted by ro...@apache.org.
check new byte annotations first for JMSDestination/JMSReplyTo type on received messages


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/7756fa37
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/7756fa37
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/7756fa37

Branch: refs/heads/master
Commit: 7756fa3728b13795849dd7174dbcdcee1d09d95b
Parents: d516e8e
Author: Robert Gemmell <ro...@apache.org>
Authored: Sun Dec 21 21:03:07 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Sun Dec 21 21:03:07 2014 +0000

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelper.java     | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/7756fa37/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index f2c2cb3..81ac956 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -31,19 +31,19 @@ import org.apache.qpid.jms.provider.amqp.AmqpConnection;
  * destination fields in a Message that's being sent or received.
  */
 public class AmqpDestinationHelper {
-
     public static final AmqpDestinationHelper INSTANCE = new AmqpDestinationHelper();
 
-    public static final String TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-to-type";
-    public static final String REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-reply-type";
-
     // For support of current byte type values
+    public static final String JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-jms-dest";
+    public static final String JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-jms-reply-to";
     public static final byte QUEUE_TYPE = 0x00;
     public static final byte TOPIC_TYPE = 0x01;
     public static final byte TEMP_QUEUE_TYPE = 0x02;
     public static final byte TEMP_TOPIC_TYPE = 0x03;
 
     // For support of old string type values
+    public static final String TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-to-type";
+    public static final String REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME = "x-opt-reply-type";
     public static final String QUEUE_ATTRIBUTE = "queue";
     public static final String TOPIC_ATTRIBUTE = "topic";
     public static final String TEMPORARY_ATTRIBUTE = "temporary";
@@ -63,7 +63,12 @@ public class AmqpDestinationHelper {
      */
     public JmsDestination getJmsDestination(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
         String to = message.getToAddress();
-        Byte typeByte = getTypeByte(message, TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Byte typeByte = getTypeByte(message, JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        if (typeByte == null) {
+            // Try the legacy string type annotation
+            typeByte = getTypeByte(message, TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        }
+
         String name = stripPrefixIfNecessary(to, message.getConnection(), typeByte, consumerDestination);
 
         return createDestination(name, typeByte, consumerDestination, false);
@@ -71,7 +76,12 @@ public class AmqpDestinationHelper {
 
     public JmsDestination getJmsReplyTo(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
         String replyTo = message.getReplyToAddress();
-        Byte typeByte = getTypeByte(message, REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Byte typeByte = getTypeByte(message, JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        if (typeByte == null) {
+            // Try the legacy string type annotation
+            typeByte = getTypeByte(message, REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        }
+
         String name = stripPrefixIfNecessary(replyTo, message.getConnection(), typeByte, consumerDestination);
 
         return createDestination(name, typeByte, consumerDestination, true);


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


[7/7] qpid-jms git commit: update ConnectionFactory defaults to ensure no local prefix values

Posted by ro...@apache.org.
update ConnectionFactory defaults to ensure no local prefix values


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/04d7f274
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/04d7f274
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/04d7f274

Branch: refs/heads/master
Commit: 04d7f274c45a962314e2ea5d683f8c7ce3b852df
Parents: 5ef833a
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 22 16:24:11 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 22 16:24:11 2014 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/qpid/jms/JmsConnectionFactory.java  | 4 ++--
 .../apache/qpid/jms/integration/MessageIntegrationTest.java  | 6 +++---
 .../apache/qpid/jms/integration/SessionIntegrationTest.java  | 8 ++++----
 .../java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java | 4 +---
 4 files changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/04d7f274/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
index 293749f..5e02cd8 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsConnectionFactory.java
@@ -59,8 +59,8 @@ public class JmsConnectionFactory extends JNDIStorable implements ConnectionFact
     private boolean sendAcksAsync;
     private boolean omitHost;
     private boolean messagePrioritySupported = true;
-    private String queuePrefix = "queue://";
-    private String topicPrefix = "topic://";
+    private String queuePrefix = null;
+    private String topicPrefix = null;
     private long sendTimeout = JmsConnectionInfo.DEFAULT_SEND_TIMEOUT;
     private long requestTimeout = JmsConnectionInfo.DEFAULT_REQUEST_TIMEOUT;
     private long closeTimeout = JmsConnectionInfo.DEFAULT_CLOSE_TIMEOUT;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/04d7f274/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
index a36307b..f6cb671 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
@@ -125,7 +125,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
 
             MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
 
-            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo("queue://" + queueName));
+            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(queueName));
 
             TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
             messageMatcher.setHeadersMatcher(headersMatcher);
@@ -898,7 +898,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
             msgAnnotationsMatcher.withEntry(annotationKey, equalTo(AmqpDestinationHelper.TOPIC_TYPE));
 
-            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo("topic://" + topicName));
+            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo(topicName));
 
             TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
             messageMatcher.setHeadersMatcher(headersMatcher);
@@ -937,7 +937,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
             msgAnnotationsMatcher.withEntry(annotationKey, equalTo(AmqpDestinationHelper.TOPIC_TYPE));
 
-            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withReplyTo(equalTo("topic://" + replyTopicName));
+            MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withReplyTo(equalTo(replyTopicName));
 
             TransferPayloadCompositeMatcher messageMatcher = new TransferPayloadCompositeMatcher();
             messageMatcher.setHeadersMatcher(headersMatcher);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/04d7f274/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
index 21e8285..12908c7 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java
@@ -119,7 +119,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
             //sourceMatcher.withDefaultOutcome(outcomeMatcher);
 
             TargetMatcher targetMatcher = new TargetMatcher();
-            targetMatcher.withAddress(equalTo("queue://" + queueName));
+            targetMatcher.withAddress(equalTo(queueName));
 
             testPeer.expectSenderAttach(sourceMatcher, targetMatcher, false, false);
 
@@ -332,7 +332,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
 
             //Expect a link to a topic node, which we will then refuse
             TargetMatcher targetMatcher = new TargetMatcher();
-            targetMatcher.withAddress(equalTo("topic://" + topicName)); //TODO: remove prefix
+            targetMatcher.withAddress(equalTo(topicName));
             targetMatcher.withDynamic(nullValue());//default = false
             targetMatcher.withDurable(nullValue());//default = none/0
 
@@ -377,7 +377,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
             //Expect a new message sent by the above producer to cause creation of a new
             //sender link to the given destination, then closing the link after the message is sent.
             TargetMatcher targetMatcher = new TargetMatcher();
-            targetMatcher.withAddress(equalTo("topic://" + topicName)); //TODO: remove prefix
+            targetMatcher.withAddress(equalTo(topicName));
             targetMatcher.withDynamic(nullValue());//default = false
             targetMatcher.withDurable(nullValue());//default = none/0
 
@@ -698,7 +698,7 @@ public class SessionIntegrationTest extends QpidJmsTestCase {
             Queue queue = session.createQueue(queueName);
 
             SourceMatcher sourceMatcher = new SourceMatcher();
-            sourceMatcher.withAddress(equalTo("queue://" + queueName));
+            sourceMatcher.withAddress(equalTo(queueName));
             sourceMatcher.withDynamic(equalTo(false));
             sourceMatcher.withOutcomes(arrayContaining(Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL));
             ModifiedMatcher outcomeMatcher = new ModifiedMatcher().withDeliveryFailed(equalTo(true)).withUndeliverableHere(equalTo(false));

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/04d7f274/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
index 3cf94aa..162b204 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/test/testpeer/TestAmqpPeer.java
@@ -646,10 +646,8 @@ public class TestAmqpPeer implements AutoCloseable
 
     public void expectDurableSubscriberAttach(String topicName, String subscriptionName)
     {
-        String topicPrefix = "topic://"; //TODO: this will be removed, delete when tests start failing
-
         SourceMatcher sourceMatcher = new SourceMatcher();
-        sourceMatcher.withAddress(equalTo(topicPrefix + topicName));
+        sourceMatcher.withAddress(equalTo(topicName));
         sourceMatcher.withDynamic(equalTo(false));
         //TODO: will possibly be changed to a 1/config durability
         sourceMatcher.withDurable(equalTo(TerminusDurability.UNSETTLED_STATE));


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


[3/7] qpid-jms git commit: set new type annotations for JMSDestination/JMSReplyTo type on sent messages

Posted by ro...@apache.org.
set new type annotations for JMSDestination/JMSReplyTo type on sent messages


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/84383f0f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/84383f0f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/84383f0f

Branch: refs/heads/master
Commit: 84383f0ff3fa48ebcf9eceb9749647396c389ada
Parents: 7756fa3
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 22 10:55:52 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 22 10:55:52 2014 +0000

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelper.java     | 14 +++--
 .../amqp/message/AmqpMessageSupport.java        | 16 ------
 .../jms/integration/MessageIntegrationTest.java | 36 ++++++------
 .../amqp/message/AmqpDestinationHelperTest.java | 59 ++++++++++++++++----
 4 files changed, 75 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/84383f0f/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index 81ac956..e3eb84a 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -160,10 +160,13 @@ public class AmqpDestinationHelper {
         message.setToAddress(address);
 
         if (address == null || typeValue == null) {
-            message.removeMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+            message.removeMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         } else {
-            message.setMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, typeValue);
+            message.setMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME, typeValue);
         }
+
+        // Always clear the legacy string type annotation
+        message.removeMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message, JmsDestination destination) {
@@ -173,10 +176,13 @@ public class AmqpDestinationHelper {
         message.setReplyToAddress(replyToAddress);
 
         if (replyToAddress == null || typeValue == null) {
-            message.removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+            message.removeMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         } else {
-            message.setMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, typeValue);
+            message.setMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, typeValue);
         }
+
+        // Always clear the legacy string type annotation
+        message.removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     private String getDestinationAddress(JmsDestination destination, AmqpConnection conn) {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/84383f0f/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
index 92f4617..88b8ae1 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageSupport.java
@@ -28,22 +28,6 @@ import org.apache.qpid.proton.message.Message;
 public final class AmqpMessageSupport {
 
     /**
-     * The Annotation name to store the destination name that the Message
-     * will be sent to.  The Message should also be tagged with the appropriate
-     * destination attribute to allow the receiver to determine the correct
-     * destination type.
-     */
-    public static final String AMQP_TO_ANNOTATION = "x-opt-to-type";
-
-    /**
-     * The Annotation name to store the destination name that the sender wants
-     * to receive replies on.  The Message should also be tagged with the
-     * appropriate destination attribute to allow the receiver to determine the
-     * correct destination type.
-     */
-    public static final String AMQP_REPLY_TO_ANNOTATION = "x-opt-reply-type";
-
-    /**
      * Attribute used to mark the Application defined correlation Id that has been
      * set for the message.
      */

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/84383f0f/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
index 7f7a4b5..6590fc2 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/MessageIntegrationTest.java
@@ -287,9 +287,9 @@ public class MessageIntegrationTest extends QpidJmsTestCase
         String replyName = "myReplyTopic";
         String destAddress = destPrefix + destName;
         String replyAddress = destPrefix + replyName;
-        String annotationName = AmqpMessageSupport.AMQP_TO_ANNOTATION;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte annotationValue = AmqpDestinationHelper.TOPIC_TYPE;
-        String replyAnnotationName = AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte replyAnnotationValue = AmqpDestinationHelper.TOPIC_TYPE;
 
         doReceivedMessageOnConnectionWithPrefixTestImpl(destType, destPrefix, destName, replyName,
@@ -332,9 +332,9 @@ public class MessageIntegrationTest extends QpidJmsTestCase
         String replyName = "myReplyQueue";
         String destAddress = destPrefix + destName;
         String replyAddress = destPrefix + replyName;
-        String annotationName = AmqpMessageSupport.AMQP_TO_ANNOTATION;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte annotationValue = AmqpDestinationHelper.QUEUE_TYPE;
-        String replyAnnotationName = AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte replyAnnotationValue = AmqpDestinationHelper.QUEUE_TYPE;
 
         doReceivedMessageOnConnectionWithPrefixTestImpl(destType, destPrefix, destName, replyName,
@@ -377,9 +377,9 @@ public class MessageIntegrationTest extends QpidJmsTestCase
         String replyName = "temp-queue://myReplyTempQueue";
         String destAddress = destName; // We won't manipulate the temporary addresses generated by the broker
         String replyAddress = replyName; // We won't manipulate the temporary addresses generated by the broker
-        String annotationName = AmqpMessageSupport.AMQP_TO_ANNOTATION;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte annotationValue = AmqpDestinationHelper.TEMP_QUEUE_TYPE;
-        String replyAnnotationName = AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte replyAnnotationValue = AmqpDestinationHelper.TEMP_QUEUE_TYPE;
 
         doReceivedMessageOnConnectionWithPrefixTestImpl(destType, destPrefix, destName, replyName,
@@ -399,9 +399,9 @@ public class MessageIntegrationTest extends QpidJmsTestCase
         String replyName = "temp-topic://myReplyTempTopic";
         String destAddress = destName; // We won't manipulate the temporary addresses generated by the broker
         String replyAddress = replyName; // We won't manipulate the temporary addresses generated by the broker
-        String annotationName = AmqpMessageSupport.AMQP_TO_ANNOTATION;
+        String annotationName = AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte annotationValue = AmqpDestinationHelper.TEMP_TOPIC_TYPE;
-        String replyAnnotationName = AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION;
+        String replyAnnotationName = AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
         Byte replyAnnotationValue = AmqpDestinationHelper.TEMP_TOPIC_TYPE;
 
         doReceivedMessageOnConnectionWithPrefixTestImpl(destType, destPrefix, destName, replyName,
@@ -628,8 +628,8 @@ public class MessageIntegrationTest extends QpidJmsTestCase
 
             MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true);
             MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
-            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpMessageSupport.AMQP_TO_ANNOTATION), equalTo(destTypeAnnotationValue));
-            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION), equalTo(destTypeAnnotationValue));
+            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME), equalTo(destTypeAnnotationValue));
+            msgAnnotationsMatcher.withEntry(Symbol.valueOf(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME), equalTo(destTypeAnnotationValue));
             MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true);
             propsMatcher.withTo(equalTo(destAddress));
             propsMatcher.withReplyTo(equalTo(destAddress));
@@ -655,7 +655,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
     // --- byte type annotation values --- //
 
     /**
-     * Tests that the {@link AmqpMessageSupport#AMQP_TO_ANNOTATION} is set as a byte on
+     * Tests that the {@link AmqpDestinationHelper#JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME} is set as a byte on
      * a sent message to indicate its 'to' address represents a Topic JMSDestination.
      */
     @Test(timeout = 5000)
@@ -670,7 +670,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
 
             MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
             MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
-            Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpMessageSupport.AMQP_TO_ANNOTATION);
+            Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
             msgAnnotationsMatcher.withEntry(annotationKey, equalTo(AmqpDestinationHelper.TOPIC_TYPE));
 
             MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withTo(equalTo("topic://" + topicName));
@@ -692,7 +692,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
     }
 
     /**
-     * Tests that the {@link AmqpMessageSupport#AMQP_REPLY_TO_ANNOTATION} is set as a byte on
+     * Tests that the {@link AmqpDestinationHelper#JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} is set as a byte on
      * a sent message to indicate its 'reply-to' address represents a Topic JMSDestination.
      */
     @Test(timeout = 5000)
@@ -709,7 +709,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
 
             MessageHeaderSectionMatcher headersMatcher = new MessageHeaderSectionMatcher(true).withDurable(equalTo(true));
             MessageAnnotationsSectionMatcher msgAnnotationsMatcher = new MessageAnnotationsSectionMatcher(true);
-            Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION);
+            Symbol annotationKey = AmqpMessageSupport.getSymbol(AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
             msgAnnotationsMatcher.withEntry(annotationKey, equalTo(AmqpDestinationHelper.TOPIC_TYPE));
 
             MessagePropertiesSectionMatcher propsMatcher = new MessagePropertiesSectionMatcher(true).withReplyTo(equalTo("topic://" + replyTopicName));
@@ -736,7 +736,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
     // --- old string type annotation values --- //
 
     /**
-     * Tests that the {@link AmqpMessageSupport#AMQP_TO_ANNOTATION} set on a message to
+     * Tests that the {@link AmqpDestinationHelper#TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message to
      * indicate its 'to' address represents a Topic results in the JMSDestination object being a
      * Topic. Ensure the consumers destination is not used by consuming from a Queue.
      */
@@ -752,7 +752,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Queue queue = session.createQueue("myQueue");
 
             MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
-            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
+            msgAnnotations.setSymbolKeyedAnnotation(AmqpDestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
 
             PropertiesDescribedType props = new PropertiesDescribedType();
             String myTopicAddress = "myTopicAddress";
@@ -778,7 +778,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
     }
 
     /**
-     * Tests that the {@link AmqpMessageSupport#AMQP_REPLY_TO_ANNOTATION} set on a message to
+     * Tests that the {@link AmqpDestinationHelper#REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME} set on a message to
      * indicate its 'reply-to' address represents a Topic results in the JMSReplyTo object being a
      * Topic. Ensure the consumers destination is not used by consuming from a Queue.
      */
@@ -794,7 +794,7 @@ public class MessageIntegrationTest extends QpidJmsTestCase
             Queue queue = session.createQueue("myQueue");
 
             MessageAnnotationsDescribedType msgAnnotations = new MessageAnnotationsDescribedType();
-            msgAnnotations.setSymbolKeyedAnnotation(AmqpMessageSupport.AMQP_REPLY_TO_ANNOTATION, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
+            msgAnnotations.setSymbolKeyedAnnotation(AmqpDestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, AmqpDestinationHelper.TOPIC_ATTRIBUTE);
 
             PropertiesDescribedType props = new PropertiesDescribedType();
             String myTopicAddress = "myTopicAddress";

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/84383f0f/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
index 54a5dcd..dea756b 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.qpid.jms.provider.amqp.message;
 
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_ATTRIBUTE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.QUEUE_TYPE;
 import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
@@ -51,6 +53,7 @@ public class AmqpDestinationHelperTest {
     private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
 
     //--------------- Test getJmsDestination method --------------------------//
+    //========================================================================//
 
     @Test
     public void testGetJmsDestinationWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
@@ -258,6 +261,7 @@ public class AmqpDestinationHelperTest {
     }
 
     //--------------- Test getJmsReplyTo method ------------------------------//
+    //========================================================================//
 
     @Test
     public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
@@ -463,13 +467,14 @@ public class AmqpDestinationHelperTest {
     }
 
     //--------------- Test setToAddressFromDestination method ----------------//
+    //========================================================================//
 
     @Test
     public void testSetToAddressFromDestinationWithNullDestination() {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setToAddressFromDestination(message, null);
         Mockito.verify(message).setToAddress(null);
-        Mockito.verify(message).removeMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Mockito.verify(message).removeMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     @Test(expected=NullPointerException.class)
@@ -484,6 +489,20 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
+    public void testSetToAddressFromDestinationWithQueueClearsLegacyAnnotation() {
+        String testAddress = "testAddress";
+        JmsDestination destination = new JmsQueue("testAddress");
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        AmqpConnection conn = Mockito.mock(AmqpConnection.class);
+        Mockito.when(message.getConnection()).thenReturn(conn);
+
+        helper.setToAddressFromDestination(message, destination);
+
+        Mockito.verify(message).setToAddress(testAddress);
+        Mockito.verify(message).removeMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+    }
+
+    @Test
     public void testSetToAddressFromDestinationWithQueue() {
         String testAddress = "testAddress";
         JmsDestination destination = new JmsQueue("testAddress");
@@ -494,7 +513,7 @@ public class AmqpDestinationHelperTest {
         helper.setToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, QUEUE_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME, QUEUE_TYPE);
     }
 
     @Test
@@ -508,7 +527,7 @@ public class AmqpDestinationHelperTest {
         helper.setToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TOPIC_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TOPIC_TYPE);
     }
 
     @Test
@@ -520,7 +539,7 @@ public class AmqpDestinationHelperTest {
         helper.setToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_QUEUE_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_QUEUE_TYPE);
     }
 
     @Test
@@ -532,7 +551,7 @@ public class AmqpDestinationHelperTest {
         helper.setToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_TOPIC_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_TOPIC_TYPE);
     }
 
     @Test
@@ -545,17 +564,18 @@ public class AmqpDestinationHelperTest {
         helper.setToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setToAddress(testAddress);
-        Mockito.verify(message).removeMessageAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Mockito.verify(message).removeMessageAnnotation(JMS_DEST_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     //--------------- Test setReplyToAddressFromDestination method -----------//
+    //========================================================================//
 
     @Test
     public void testSetReplyToAddressFromDestinationWithNullDestination() {
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         helper.setReplyToAddressFromDestination(message, null);
         Mockito.verify(message).setReplyToAddress(null);
-        Mockito.verify(message).removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Mockito.verify(message).removeMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     @Test(expected=NullPointerException.class)
@@ -580,7 +600,21 @@ public class AmqpDestinationHelperTest {
         helper.setReplyToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setReplyToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, QUEUE_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, QUEUE_TYPE);
+    }
+
+    @Test
+    public void testSetReplyToAddressFromDestinationWithQueueClearsLegacyAnnotation() {
+        String testAddress = "testAddress";
+        JmsDestination destination = new JmsQueue("testAddress");
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        AmqpConnection conn = Mockito.mock(AmqpConnection.class);
+        Mockito.when(message.getConnection()).thenReturn(conn);
+
+        helper.setReplyToAddressFromDestination(message, destination);
+
+        Mockito.verify(message).setReplyToAddress(testAddress);
+        Mockito.verify(message).removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     @Test
@@ -594,7 +628,7 @@ public class AmqpDestinationHelperTest {
         helper.setReplyToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setReplyToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TOPIC_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TOPIC_TYPE);
     }
 
     @Test
@@ -606,7 +640,7 @@ public class AmqpDestinationHelperTest {
         helper.setReplyToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setReplyToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_QUEUE_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_QUEUE_TYPE);
     }
 
     @Test
@@ -618,7 +652,7 @@ public class AmqpDestinationHelperTest {
         helper.setReplyToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setReplyToAddress(testAddress);
-        Mockito.verify(message).setMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_TOPIC_TYPE);
+        Mockito.verify(message).setMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME, TEMP_TOPIC_TYPE);
     }
 
     @Test
@@ -631,10 +665,11 @@ public class AmqpDestinationHelperTest {
         helper.setReplyToAddressFromDestination(message, destination);
 
         Mockito.verify(message).setReplyToAddress(testAddress);
-        Mockito.verify(message).removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
+        Mockito.verify(message).removeMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
     //--------------- Test Support Methods -----------------------------------//
+    //========================================================================//
 
     @Test
     public void testSplitAttributeWithExtraneousCommas() throws Exception {


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


[6/7] qpid-jms git commit: consolodate on a single method to handle address prefixing, resolve defect of prefixing with null

Posted by ro...@apache.org.
consolodate on a single method to handle address prefixing, resolve defect of prefixing with null


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/5ef833a6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/5ef833a6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/5ef833a6

Branch: refs/heads/master
Commit: 5ef833a6b1140010872c64b2ba6e54766a78e21f
Parents: c6a5498
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Dec 22 15:50:23 2014 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Dec 22 15:50:23 2014 +0000

----------------------------------------------------------------------
 .../qpid/jms/provider/amqp/AmqpConsumer.java    |  3 ++-
 .../jms/provider/amqp/AmqpFixedProducer.java    |  3 ++-
 .../qpid/jms/provider/amqp/AmqpSession.java     | 27 --------------------
 .../amqp/message/AmqpDestinationHelper.java     |  2 +-
 4 files changed, 5 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5ef833a6/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
index 19b4560..3319297 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpConsumer.java
@@ -35,6 +35,7 @@ import org.apache.qpid.jms.meta.JmsConsumerInfo;
 import org.apache.qpid.jms.provider.AsyncResult;
 import org.apache.qpid.jms.provider.ProviderConstants.ACK_TYPE;
 import org.apache.qpid.jms.provider.ProviderListener;
+import org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper;
 import org.apache.qpid.jms.provider.amqp.message.AmqpJmsMessageBuilder;
 import org.apache.qpid.jms.util.IOExceptionSupport;
 import org.apache.qpid.proton.amqp.Binary;
@@ -138,7 +139,7 @@ public class AmqpConsumer extends AmqpAbstractResource<JmsConsumerInfo, Receiver
     @Override
     protected void doOpen() {
         JmsDestination destination  = resource.getDestination();
-        String subscription = session.getQualifiedName(destination);
+        String subscription = AmqpDestinationHelper.INSTANCE.getDestinationAddress(destination, session.getConnection());
 
         Source source = new Source();
         source.setAddress(subscription);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5ef833a6/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
index 75fa850..d05824d 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpFixedProducer.java
@@ -30,6 +30,7 @@ import org.apache.qpid.jms.message.JmsOutboundMessageDispatch;
 import org.apache.qpid.jms.message.facade.JmsMessageFacade;
 import org.apache.qpid.jms.meta.JmsProducerInfo;
 import org.apache.qpid.jms.provider.AsyncResult;
+import org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper;
 import org.apache.qpid.jms.provider.amqp.message.AmqpJmsMessageFacade;
 import org.apache.qpid.jms.util.IOExceptionSupport;
 import org.apache.qpid.proton.amqp.Binary;
@@ -238,7 +239,7 @@ public class AmqpFixedProducer extends AmqpProducer {
 
         if (resource.getDestination() != null) {
             JmsDestination destination = resource.getDestination();
-            targetAddress = session.getQualifiedName(destination);
+            targetAddress = AmqpDestinationHelper.INSTANCE.getDestinationAddress(destination, session.getConnection());
         }
 
         Symbol[] outcomes = new Symbol[]{Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL};

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5ef833a6/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java
index d6e0abc..08c974b 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSession.java
@@ -215,33 +215,6 @@ public class AmqpSession extends AmqpAbstractResource<JmsSessionInfo, Session> {
     }
 
     /**
-     * Adds Topic or Queue qualifiers to the destination target.  We don't add qualifiers to
-     * Temporary Topics and Queues since AMQP works a bit differently.
-     *
-     * @param destination
-     *        The destination to Qualify.
-     *
-     * @return the qualified destination name.
-     */
-    public String getQualifiedName(JmsDestination destination) {
-        if (destination == null) {
-            return null;
-        }
-
-        String result = destination.getName();
-
-        if (!destination.isTemporary()) {
-            if (destination.isTopic()) {
-                result = connection.getTopicPrefix() + destination.getName();
-            } else {
-                result = connection.getQueuePrefix() + destination.getName();
-            }
-        }
-
-        return result;
-    }
-
-    /**
      * Query the Session to see if there are any registered consumer instances that have
      * a durable subscription with the given subscription name.
      *

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/5ef833a6/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
index e3eb84a..d04e403 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelper.java
@@ -185,7 +185,7 @@ public class AmqpDestinationHelper {
         message.removeMessageAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
     }
 
-    private String getDestinationAddress(JmsDestination destination, AmqpConnection conn) {
+    public String getDestinationAddress(JmsDestination destination, AmqpConnection conn) {
         if (destination == null) {
             return null;
         }


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