qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [7/9] qpid-jms git commit: add tests for AmqpDestinationHelper#getJmsReplyTo using new byte destination type anntotation, rearrange/group tests for clarity
Date Fri, 02 Jan 2015 16:21:20 GMT
add tests for AmqpDestinationHelper#getJmsReplyTo using new byte destination type anntotation,
rearrange/group tests for clarity


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

Branch: refs/heads/master
Commit: 4302c28f6684e0af2edc99924139f530566a2a36
Parents: b957ce7
Author: Robert Gemmell <robbie@apache.org>
Authored: Fri Jan 2 15:42:22 2015 +0000
Committer: Robert Gemmell <robbie@apache.org>
Committed: Fri Jan 2 15:42:22 2015 +0000

----------------------------------------------------------------------
 .../amqp/message/AmqpDestinationHelperTest.java | 145 ++++++++++++++-----
 1 file changed, 110 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/4302c28f/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 5b468b7..603c8fe 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
@@ -47,8 +47,8 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class AmqpDestinationHelperTest {
-    private static final String TEMP_QUEUE_ATTRIBUTES_STRING = LEGACY_QUEUE_ATTRIBUTE + ","
+ LEGACY_TEMPORARY_ATTRIBUTE;
-    private static final String TEMP_TOPIC_ATTRIBUTES_STRING = LEGACY_TOPIC_ATTRIBUTE + ","
+ LEGACY_TEMPORARY_ATTRIBUTE;
+    private static final String LEGACY_TEMP_QUEUE_ATTRIBUTES = LEGACY_QUEUE_ATTRIBUTE + ","
+ LEGACY_TEMPORARY_ATTRIBUTE;
+    private static final String LEGACY_TEMP_TOPIC_ATTRIBUTES = LEGACY_TOPIC_ATTRIBUTE + ","
+ LEGACY_TEMPORARY_ATTRIBUTE;
 
     private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
 
@@ -314,7 +314,7 @@ public class AmqpDestinationHelperTest {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_QUEUE_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_TEMP_QUEUE_ATTRIBUTES);
 
         JmsDestination destination = helper.getJmsDestination(message, null);
         assertNotNull(destination);
@@ -328,7 +328,7 @@ public class AmqpDestinationHelperTest {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_TOPIC_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(LEGACY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_TEMP_TOPIC_ATTRIBUTES);
 
         JmsDestination destination = helper.getJmsDestination(message, null);
         assertNotNull(destination);
@@ -341,12 +341,12 @@ public class AmqpDestinationHelperTest {
     //--------------- Test getJmsReplyTo method ------------------------------//
     //========================================================================//
 
+    // --- general / no type annotations  --- //
+
     @Test
     public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception
{
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(null);
-        Mockito.when(message.getMessageAnnotation(
-            LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_QUEUE_ATTRIBUTE);
 
         assertNull(helper.getJmsDestination(message, null));
     }
@@ -355,8 +355,6 @@ public class AmqpDestinationHelperTest {
     public void testGetJmsReplyToWithNullAddressWithConsumerDestReturnsNull() throws Exception
{
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(null);
-        Mockito.when(message.getMessageAnnotation(
-            LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_QUEUE_ATTRIBUTE);
         JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         assertNull(helper.getJmsReplyTo(message, consumerDestination));
@@ -370,7 +368,6 @@ public class AmqpDestinationHelperTest {
         Mockito.when(message.getConnection()).thenReturn(conn);
 
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
         JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
@@ -381,13 +378,60 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
+    public void testGetJmsReplyToWithoutTypeAnnotationWithTopicConsumerDest() throws Exception
{
+        String testAddress = "testAddress";
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        AmqpConnection conn = Mockito.mock(AmqpConnection.class);
+        Mockito.when(message.getConnection()).thenReturn(conn);
+        Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+        JmsTopic consumerDestination = new JmsTopic("ConsumerDestination");
+
+        JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+        assertNotNull(destination);
+        assertTrue(destination.isTopic());
+        assertFalse(destination.isTemporary());
+        assertEquals(testAddress, destination.getName());
+    }
+
+    @Test
+    public void testGetJmsReplyToWithoutTypeAnnotationWithTempTopicConsumerDest() throws
Exception {
+        String testAddress = "testAddress";
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        AmqpConnection conn = Mockito.mock(AmqpConnection.class);
+        Mockito.when(message.getConnection()).thenReturn(conn);
+        Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+        JmsTemporaryTopic consumerDestination = new JmsTemporaryTopic("ConsumerDestination");
+
+        JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+        assertNotNull(destination);
+        assertTrue(destination.isTopic());
+        assertTrue(destination.isTemporary());
+        assertEquals(testAddress, destination.getName());
+    }
+
+    @Test
+    public void testGetJmsReplyToWithoutTypeAnnotationWithTempQueueConsumerDest() throws
Exception {
+        String testAddress = "testAddress";
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        AmqpConnection conn = Mockito.mock(AmqpConnection.class);
+        Mockito.when(message.getConnection()).thenReturn(conn);
+        Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+        JmsTemporaryQueue consumerDestination = new JmsTemporaryQueue("ConsumerDestination");
+
+        JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+        assertNotNull(destination);
+        assertTrue(destination.isQueue());
+        assertTrue(destination.isTemporary());
+        assertEquals(testAddress, destination.getName());
+    }
+
+    @Test
     public void testGetJmsReplyToWithoutTypeAnnotationWithAnonymousConsumerDest() {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
 
         JmsDestination consumerDestination = Mockito.mock(JmsDestination.class);
         Mockito.when(consumerDestination.getName()).thenReturn("ConsumerDestination");
@@ -399,14 +443,16 @@ public class AmqpDestinationHelperTest {
         assertEquals(testAddress, destination.getName());
     }
 
+    // --- new byte destination type annotations --- //
+
     @Test
-    public void testGetJmsReplyToWithEmptyTypeAnnotationWithQueueConsumerDest() throws Exception
{
+    public void testGetJmsReplyToWithUnknownTypeAnnotationWithQueueConsumerDest() throws
Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn("");
+        Mockito.when(message.getMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn((byte)
5);
         JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
@@ -416,17 +462,17 @@ public class AmqpDestinationHelperTest {
         assertEquals(testAddress, destination.getName());
     }
 
+
     @Test
-    public void testGetJmsReplyToWithUnknownTypeAnnotationWithQueueConsumerDest() throws
Exception {
+    public void testGetJmsReplToWithQueueTypeAnnotationNoConsumerDestination() throws Exception
{
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn("jms.queue");
-        JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
+        Mockito.when(message.getMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_TYPE);
 
-        JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+        JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);
         assertTrue(destination.isQueue());
         assertFalse(destination.isTemporary());
@@ -434,16 +480,15 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
-    public void testGetJmsReplyToWithoutTypeAnnotationWithTopicConsumerDest() throws Exception
{
+    public void testGetJmsReplToWithTopicTypeAnnotationNoConsumerDestination() throws Exception
{
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
-        JmsTopic consumerDestination = new JmsTopic("ConsumerDestination");
+        Mockito.when(message.getMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TOPIC_TYPE);
 
-        JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+        JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);
         assertTrue(destination.isTopic());
         assertFalse(destination.isTemporary());
@@ -451,41 +496,71 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
-    public void testGetJmsReplyToWithoutTypeAnnotationWithTempQueueConsumerDest() throws
Exception {
+    public void testGetJmsReplToWithTempQueueTypeAnnotationNoConsumerDestination() throws
Exception {
+        String testAddress = "testAddress";
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+        Mockito.when(message.getMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_QUEUE_TYPE);
+
+        JmsDestination destination = helper.getJmsReplyTo(message, null);
+        assertNotNull(destination);
+        assertTrue(destination.isQueue());
+        assertTrue(destination.isTemporary());
+        assertEquals(testAddress, destination.getName());
+    }
+
+    @Test
+    public void testGetJmsReplToWithTempTopicTypeAnnotationNoConsumerDestination() throws
Exception {
+        String testAddress = "testAddress";
+        AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+        Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+        Mockito.when(message.getMessageAnnotation(JMS_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_TOPIC_TYPE);
+
+        JmsDestination destination = helper.getJmsReplyTo(message, null);
+        assertNotNull(destination);
+        assertTrue(destination.isTopic());
+        assertTrue(destination.isTemporary());
+        assertEquals(testAddress, destination.getName());
+    }
+
+    // --- legacy string destination type annotations --- //
+
+    @Test
+    public void testGetJmsReplyToWithEmptyLegacyTypeAnnotationWithQueueConsumerDest() throws
Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
-        JmsTemporaryQueue consumerDestination = new JmsTemporaryQueue("ConsumerDestination");
+        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn("");
+        JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
         assertNotNull(destination);
         assertTrue(destination.isQueue());
-        assertTrue(destination.isTemporary());
+        assertFalse(destination.isTemporary());
         assertEquals(testAddress, destination.getName());
     }
 
     @Test
-    public void testGetJmsReplyToWithoutTypeAnnotationWithTempTopicConsumerDest() throws
Exception {
+    public void testGetJmsReplyToWithUnknownLegacyTypeAnnotationWithQueueConsumerDest() throws
Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
         Mockito.when(message.getConnection()).thenReturn(conn);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
-        JmsTemporaryTopic consumerDestination = new JmsTemporaryTopic("ConsumerDestination");
+        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn("jms.queue");
+        JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
 
         JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
         assertNotNull(destination);
-        assertTrue(destination.isTopic());
-        assertTrue(destination.isTemporary());
+        assertTrue(destination.isQueue());
+        assertFalse(destination.isTemporary());
         assertEquals(testAddress, destination.getName());
     }
 
     @Test
-    public void testGetJmsReplToWithQueueTypeAnnotationNoConsumerDestination() throws Exception
{
+    public void testGetJmsReplToWithLegacyQueueTypeAnnotationNoConsumerDestination() throws
Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
@@ -501,7 +576,7 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
-    public void testGetJmsReplToWithTopicTypeAnnotationNoConsumerDestination() throws Exception
{
+    public void testGetJmsReplToWithLegacyTopicTypeAnnotationNoConsumerDestination() throws
Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         AmqpConnection conn = Mockito.mock(AmqpConnection.class);
@@ -517,11 +592,11 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
-    public void testGetJmsReplToWithTempQueueTypeAnnotationNoConsumerDestination() throws
Exception {
+    public void testGetJmsReplToWithLegacyTempQueueTypeAnnotationNoConsumerDestination()
throws Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_QUEUE_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_TEMP_QUEUE_ATTRIBUTES);
 
         JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);
@@ -531,11 +606,11 @@ public class AmqpDestinationHelperTest {
     }
 
     @Test
-    public void testGetJmsReplToWithTempTopicTypeAnnotationNoConsumerDestination() throws
Exception {
+    public void testGetJmsReplToWithLegacyTempTopicTypeAnnotationNoConsumerDestination()
throws Exception {
         String testAddress = "testAddress";
         AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
         Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
-        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(TEMP_TOPIC_ATTRIBUTES_STRING);
+        Mockito.when(message.getMessageAnnotation(LEGACY_REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(LEGACY_TEMP_TOPIC_ATTRIBUTES);
 
         JmsDestination destination = helper.getJmsReplyTo(message, null);
         assertNotNull(destination);


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


Mime
View raw message