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:46:43 UTC
git commit: Adding in more tests for the destination helper
Repository: qpid-jms
Updated Branches:
refs/heads/master 2943002c3 -> 07ccbfebf
Adding in more tests for the destination helper
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/07ccbfeb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/07ccbfeb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/07ccbfeb
Branch: refs/heads/master
Commit: 07ccbfebfc12677acc39f65c903faa45de8da6fb
Parents: 2943002
Author: Timothy Bish <ta...@gmail.com>
Authored: Wed Sep 24 18:46:37 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Wed Sep 24 18:46:37 2014 -0400
----------------------------------------------------------------------
.../amqp/message/AmqpDestinationHelperTest.java | 154 ++++++++++++++++++-
1 file changed, 153 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/07ccbfeb/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 d03765e..373298c 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
@@ -19,8 +19,21 @@ 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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.qpid.jms.JmsDestination;
+import org.apache.qpid.jms.JmsQueue;
+import org.apache.qpid.jms.JmsTemporaryQueue;
+import org.apache.qpid.jms.JmsTemporaryTopic;
+import org.apache.qpid.jms.JmsTopic;
import org.junit.Test;
import org.mockito.Mockito;
@@ -28,6 +41,8 @@ public class AmqpDestinationHelperTest {
private final AmqpDestinationHelper helper = AmqpDestinationHelper.INSTANCE;
+ //--------------- Test getJmsDestination method --------------------------//
+
@Test
public void testGetJmsDestinationWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
@@ -39,12 +54,149 @@ public class AmqpDestinationHelperTest {
}
@Test
- public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+ public void testGetJmsDestinationWithNullAddressWithConsumerDestReturnsSameConsumerDestObject() 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);
+ JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
+
+ assertSame(consumerDestination, helper.getJmsDestination(message, consumerDestination));
+ }
+
+ @Test
+ public void testGetJmsDestinationWithoutTypeAnnotationWithQueueConsumerDest() throws Exception {
+ String testAddress = "testAddress";
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getToAddress()).thenReturn(testAddress);
+ Mockito.when(message.getAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
+ JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
+
+ JmsDestination destination = helper.getJmsDestination(message, consumerDestination);
+ assertNotNull(destination);
+ assertTrue(destination.isQueue());
+ assertFalse(destination.isTemporary());
+ assertEquals(testAddress, destination.getName());
+ }
+
+ //--------------- Test getJmsReplyTo method ------------------------------//
+
+ @Test
+ public void testGetJmsReplyToWithNullAddressAndNullConsumerDestReturnsNull() throws Exception {
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(null);
+ Mockito.when(message.getAnnotation(
REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
assertNull(helper.getJmsDestination(message, null));
}
+
+ @Test
+ public void testGetJmsReplyToWithNullAddressWithConsumerDestReturnsNull() throws Exception {
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(null);
+ Mockito.when(message.getAnnotation(
+ REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(QUEUE_ATTRIBUTES_STRING);
+ JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
+
+ assertNull(helper.getJmsReplyTo(message, consumerDestination));
+ }
+
+ @Test
+ public void testGetJmsReplyToWithoutTypeAnnotationWithQueueConsumerDest() throws Exception {
+ String testAddress = "testAddress";
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+ Mockito.when(message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
+ JmsQueue consumerDestination = new JmsQueue("ConsumerDestination");
+
+ JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+ assertNotNull(destination);
+ assertTrue(destination.isQueue());
+ assertFalse(destination.isTemporary());
+ assertEquals(testAddress, destination.getName());
+ }
+
+ @Test
+ public void testGetJmsReplyToWithoutTypeAnnotationWithTopicConsumerDest() throws Exception {
+ String testAddress = "testAddress";
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+ Mockito.when(message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
+ 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 testGetJmsReplyToWithoutTypeAnnotationWithTempQueueConsumerDest() throws Exception {
+ String testAddress = "testAddress";
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+ Mockito.when(message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
+ 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 testGetJmsReplyToWithoutTypeAnnotationWithTempTopicConsumerDest() throws Exception {
+ String testAddress = "testAddress";
+ AmqpJmsMessageFacade message = Mockito.mock(AmqpJmsMessageFacade.class);
+ Mockito.when(message.getReplyToAddress()).thenReturn(testAddress);
+ Mockito.when(message.getAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME)).thenReturn(null);
+ JmsTemporaryTopic consumerDestination = new JmsTemporaryTopic("ConsumerDestination");
+
+ JmsDestination destination = helper.getJmsReplyTo(message, consumerDestination);
+ assertNotNull(destination);
+ assertTrue(destination.isTopic());
+ assertTrue(destination.isTemporary());
+ assertEquals(testAddress, destination.getName());
+ }
+
+ //--------------- Test setToAddress method -------------------------------//
+
+ //--------------- Test setReplyToAddress method --------------------------//
+
+ //--------------- Test Support Methods -----------------------------------//
+
+ @Test
+ public void testSplitAttributeWithExtranerousCommas() throws Exception {
+
+ Set<String> set = new HashSet<String>();
+ set.add(AmqpDestinationHelper.QUEUE_ATTRIBUTE);
+ set.add(AmqpDestinationHelper.TEMPORARY_ATTRIBUTE);
+
+ // test a single comma separator produces expected set
+ assertEquals(set, helper.splitAttributes(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+ AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
+
+ // test trailing comma doesn't alter produced set
+ assertEquals(set, helper.splitAttributes(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+ AmqpDestinationHelper.TEMPORARY_ATTRIBUTE + ","));
+
+ // test leading comma doesn't alter produced set
+ assertEquals(set, helper.splitAttributes("," + AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ","
+ + AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
+
+ // test consecutive central commas don't alter produced set
+ assertEquals(set, helper.splitAttributes(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ",," +
+ AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
+
+ // test consecutive trailing commas don't alter produced set
+ assertEquals(set, helper.splitAttributes(AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + "," +
+ AmqpDestinationHelper.TEMPORARY_ATTRIBUTE + ",,"));
+
+ // test consecutive leading commas don't alter produced set
+ assertEquals(set, helper.splitAttributes("," + AmqpDestinationHelper.QUEUE_ATTRIBUTES_STRING + ","
+ + AmqpDestinationHelper.TEMPORARY_ATTRIBUTE));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org