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/10/08 19:02:33 UTC

[2/3] git commit: fill some gaps in correlation-id and message-id tests

fill some gaps in correlation-id and message-id tests


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

Branch: refs/heads/master
Commit: 89e8e8fae661946c8e760d6887d4e1b2623efa89
Parents: fa00783
Author: Robert Gemmell <ro...@apache.org>
Authored: Wed Oct 8 17:47:15 2014 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Wed Oct 8 18:01:56 2014 +0100

----------------------------------------------------------------------
 .../amqp/message/AmqpJmsMessageFacadeTest.java  | 77 ++++++++++++++++++++
 1 file changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/89e8e8fa/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index 079c94a..7fece13 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -796,6 +796,22 @@ public class AmqpJmsMessageFacadeTest {
     }
 
     /**
+     * Test that setting the correlationId null, clears an existing value in the
+     * underlying AMQP message correlation-id field
+     * @throws Exception if unexpected error
+     */
+    @Test
+    public void testSetCorrelationIdNullClearsExistingValue() throws Exception {
+        AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+        amqpMessageFacade.setCorrelationId("cid");
+        amqpMessageFacade.setCorrelationId(null);
+
+        assertNull("Unexpected correlationId value on underlying AMQP message", amqpMessageFacade.getAmqpMessage().getCorrelationId());
+        assertNull("Expected correlationId bytes to be null", amqpMessageFacade.getCorrelationId());
+    }
+
+    /**
      * Test that getting the correlationId when using an underlying received message with
      * an application-specific (no 'ID:' prefix) String correlation id returns the expected value.
      */
@@ -897,6 +913,31 @@ public class AmqpJmsMessageFacadeTest {
         assertArrayEquals("Expected correlationId bytes not returned", bytes, amqpMessageFacade.getCorrelationIdBytes());
     }
 
+    /**
+     * Test that setting the correlationId null, clears an existing value in the
+     * underlying AMQP message correlation-id field
+     * @throws Exception if unexpected error
+     */
+    @Test
+    public void testSetCorrelationIdBytesNullClearsExistingValue() throws Exception {
+        Binary testCorrelationId = createBinaryId();
+        byte[] bytes = testCorrelationId.getArray();
+
+        AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+        amqpMessageFacade.setCorrelationIdBytes(bytes);
+        amqpMessageFacade.setCorrelationIdBytes(null);
+
+        assertNull("Unexpected correlationId value on underlying AMQP message", amqpMessageFacade.getAmqpMessage().getCorrelationId());
+        assertNull("Expected correlationId bytes to be null", amqpMessageFacade.getCorrelationIdBytes());
+    }
+
+    @Test
+    public void testGetCorrelationIdBytesOnNewMessage() throws Exception {
+        AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+        assertNull("Expected correlationId bytes to be null", amqpMessageFacade.getCorrelationIdBytes());
+    }
+
     @Test
     public void testGetCorrelationIdBytesOnReceievedMessageWithBinaryId() throws Exception {
         Binary testCorrelationId = createBinaryId();
@@ -984,6 +1025,42 @@ public class AmqpJmsMessageFacadeTest {
     }
 
     /**
+     * Test that setting an ID: prefixed JMSMessageId results in the underlying AMQP
+     * message holding the value withint the ID: prefix.
+     */
+    @Test
+    public void testSetMessageIdRemovesIdPrefixFromUnderlyingMessage() {
+        String suffix = "myStringMessageIdSuffix";
+        String testMessageId = "ID:" + suffix;
+
+        AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+        amqpMessageFacade.setMessageId(testMessageId);
+
+        assertEquals("Expected underlying messageId value not returned", suffix, amqpMessageFacade.getAmqpMessage().getMessageId());
+    }
+
+    /**
+     * Test that setting the messageId null clears a previous value in the
+     * underlying amqp message-id field
+     */
+    @Test
+    public void testSetMessageIdNullClearsExistingValue() {
+        String testMessageId = "ID:myStringMessageId";
+
+        AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
+
+        amqpMessageFacade.setMessageId(testMessageId);
+
+        assertNotNull("messageId should not be null", amqpMessageFacade.getAmqpMessage().getMessageId());
+
+        amqpMessageFacade.setMessageId(null);
+
+        assertNull("Expected messageId to be null", amqpMessageFacade.getAmqpMessage().getMessageId());
+        assertNull("ID was not null", amqpMessageFacade.getMessageId());
+    }
+
+    /**
      * Test that getting the messageId when using an underlying received message with a
      * String message id returns the expected value.
      */


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