You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/09/25 00:07:03 UTC

[3/3] git commit: Add getters and setters for the To and ReplyTo address values from the underlying AMQP message to the message facade and use those in destination helper. Create a new test to start covering the variations of things in AmqpDestinationHe

Add getters and setters for the To and ReplyTo address values from the
underlying AMQP message to the message facade and use those in
destination helper.  Create a new test to start covering the variations
of things in AmqpDestinationHelper

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

Branch: refs/heads/master
Commit: 2943002c3046b871bd800efda5908663082115a1
Parents: 18adb4e
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Sep 24 18:06:51 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Sep 24 18:06:51 2014 -0400

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelper.java     |  8 ++--
 .../amqp/message/AmqpJmsMessageFacade.java      | 16 +++++++
 .../amqp/message/AmqpDestinationHelperTest.java | 50 ++++++++++++++++++++
 3 files changed, 70 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/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 3b84029..d84399d 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
@@ -73,7 +73,7 @@ public class AmqpDestinationHelper {
      */
 
     public JmsDestination getJmsDestination(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
-        String to = message.getAmqpMessage().getAddress();
+        String to = message.getToAddress();
         String toTypeString = (String) message.getAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;
 
@@ -85,7 +85,7 @@ public class AmqpDestinationHelper {
     }
 
     public JmsDestination getJmsReplyTo(AmqpJmsMessageFacade message, JmsDestination consumerDestination) {
-        String replyTo = message.getAmqpMessage().getReplyTo();
+        String replyTo = message.getReplyToAddress();
         String replyToTypeString = (String) message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
         Set<String> typeSet = null;
 
@@ -142,7 +142,7 @@ public class AmqpDestinationHelper {
         String address = destination.getName();
         String typeString = toTypeAnnotation(destination);
 
-        message.getAmqpMessage().setAddress(address);
+        message.setToAddress(address);
 
         if (address == null || typeString == null) {
             message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
@@ -155,7 +155,7 @@ public class AmqpDestinationHelper {
         String replyToAddress = destination.getName();
         String typeString = toTypeAnnotation(destination);
 
-        message.getAmqpMessage().setReplyTo(replyToAddress);
+        message.setReplyToAddress(replyToAddress);
 
         if (replyToAddress == null || typeString == null) {
             message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index 0bb7fb7..d0ee5af 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -727,6 +727,22 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
         message.setApplicationProperties(null);
     }
 
+    String getToAddress() {
+        return message.getAddress();
+    }
+
+    void setToAddress(String address) {
+        message.setAddress(address);
+    }
+
+    String getReplyToAddress() {
+        return message.getReplyTo();
+    }
+
+    void setReplyToAddress(String address) {
+        this.message.setReplyTo(address);
+    }
+
     private Long getAbsoluteExpiryTime() {
         Long result = null;
         if (message.getProperties() != null) {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/2943002c/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
new file mode 100644
index 0000000..d03765e
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpDestinationHelperTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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.REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+import static org.apache.qpid.jms.provider.amqp.message.AmqpDestinationHelper.TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class AmqpDestinationHelperTest {
+
+    private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
+
+    @Test
+    public void testGetJmsDestinationWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getToAddress()).thenReturn(null);
+        Mockito.when(message.getAnnotation(
+            TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+
+        assertNull(helper.getJmsDestination(message, null));
+    }
+
+    @Test
+    public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getToAddress()).thenReturn(null);
+        Mockito.when(message.getAnnotation(
+            REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+
+        assertNull(helper.getJmsDestination(message, null));
+    }
+}


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