qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [3/3] qpid-jms git commit: QPIDJMS-189: some test cleanup
Date Thu, 01 Sep 2016 15:02:22 GMT
QPIDJMS-189: some test cleanup


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

Branch: refs/heads/master
Commit: 443a54d6c9fa919253316f01bbeed83bb27e7aef
Parents: 7b34f4f
Author: Robert Gemmell <robbie@apache.org>
Authored: Thu Sep 1 15:57:01 2016 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Thu Sep 1 15:57:01 2016 +0100

----------------------------------------------------------------------
 .../amqp/message/AmqpJmsMessageFacadeTest.java  | 33 +++++---------------
 .../amqp/message/AmqpMessageIdHelperTest.java   | 12 +++----
 2 files changed, 14 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/443a54d6/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 e7956e8..8bbbb4b 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
@@ -939,7 +939,7 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
     @Test
     public void testSetGetCorrelationIdOnNewMessageWithUUID() throws Exception {
         UUID testCorrelationId = UUID.randomUUID();
-        String converted = appendIdAndTypePrefix(testCorrelationId);
+        String converted = "ID:AMQP_UUID:" + testCorrelationId;
 
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
         amqpMessageFacade.setCorrelationId(converted);
@@ -967,7 +967,7 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
     @Test
     public void testSetGetCorrelationIdOnNewMessageWithUnsignedLong() throws Exception {
         Object testCorrelationId = UnsignedLong.valueOf(123456789L);
-        String converted = appendIdAndTypePrefix(testCorrelationId);
+        String converted = "ID:AMQP_ULONG:" + testCorrelationId;
 
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
         amqpMessageFacade.setCorrelationId(converted);
@@ -995,7 +995,11 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
     @Test
     public void testSetGetCorrelationIdOnNewMessageWithBinary() throws Exception {
         Binary testCorrelationId = createBinaryId();
-        String converted = appendIdAndTypePrefix(testCorrelationId);
+        ByteBuffer buf = testCorrelationId.asByteBuffer();
+        byte[] bytes = new byte[buf.remaining()];
+        buf.get(bytes);
+
+        String converted = "ID:AMQP_BINARY:" + new AmqpMessageIdHelper().convertBinaryToHexString(bytes);
 
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
         amqpMessageFacade.setCorrelationId(converted);
@@ -1125,7 +1129,7 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
      * message holding the value with the ID: prefix retained.
      */
     @Test
-    public void testSetMessageIdRemovesIdPrefixFromUnderlyingMessage() throws Exception {
+    public void testSetMessageIdRetainsIdPrefixInUnderlyingMessage() throws Exception {
         String testMessageId = "ID:myStringMessageId";
 
         AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
@@ -1230,27 +1234,6 @@ public class AmqpJmsMessageFacadeTest extends AmqpJmsMessageTypesTestCase
 {
         assertEquals("Incorrect messageId value received", expected, amqpMessageFacade.getMessageId());
     }
 
-    private String appendIdAndTypePrefix(Object testMessageId) {
-        if (testMessageId instanceof Binary) {
-            ByteBuffer buf = ((Binary) testMessageId).asByteBuffer();
-
-            byte[] bytes = new byte[buf.remaining()];
-            buf.get(bytes);
-
-            return "ID:AMQP_BINARY:" + new AmqpMessageIdHelper().convertBinaryToHexString(bytes);
-        } else if (testMessageId instanceof UnsignedLong) {
-            return ("ID:AMQP_ULONG:" + testMessageId);
-        } else if (testMessageId instanceof UUID) {
-            return ("ID:AMQP_UUID:" + testMessageId);
-        } else if (testMessageId instanceof String) {
-            return "ID:" + testMessageId;
-        } else if (testMessageId == null) {
-            return null;
-        }
-
-        throw new IllegalArgumentException();
-    }
-
     private Binary createBinaryId() {
         byte length = 10;
         byte[] idBytes = new byte[length];

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/443a54d6/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageIdHelperTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageIdHelperTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageIdHelperTest.java
index c786ba3..ac246e3 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageIdHelperTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpMessageIdHelperTest.java
@@ -310,10 +310,10 @@ public class AmqpMessageIdHelperTest extends QpidJmsTestCase {
      */
     @Test
     public void testToMessageIdStringWithStringBeginningWithIdAndEncodingPrefixForNoIDPrefix()
{
-        String unescapedBinaryPrefixMessageId =  AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_NO_PREFIX
+ "id-content";
-        String expected = AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_STRING_PREFIX
+ unescapedBinaryPrefixMessageId;
+        String unescapedNoPrefixPrefixedMessageId =  AmqpMessageIdHelper.JMS_ID_PREFIX +
AmqpMessageIdHelper.AMQP_NO_PREFIX + "id-content";
+        String expected = AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_STRING_PREFIX
+ unescapedNoPrefixPrefixedMessageId;
 
-        doToMessageIdTestImpl(unescapedBinaryPrefixMessageId, expected);
+        doToMessageIdTestImpl(unescapedNoPrefixPrefixedMessageId, expected);
     }
 
     /**
@@ -527,10 +527,10 @@ public class AmqpMessageIdHelperTest extends QpidJmsTestCase {
      */
     @Test
     public void testToCorrelationIdStringWithStringBeginningWithIdAndEncodingPrefixForNoIDPrefix()
{
-        String unescapedBinaryPrefixCorrelationId =  AmqpMessageIdHelper.JMS_ID_PREFIX +
AmqpMessageIdHelper.AMQP_NO_PREFIX + "id-content";
-        String expected = AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_STRING_PREFIX
+ unescapedBinaryPrefixCorrelationId;
+        String unescapedNoPrefixCorrelationId =  AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_NO_PREFIX
+ "id-content";
+        String expected = AmqpMessageIdHelper.JMS_ID_PREFIX + AmqpMessageIdHelper.AMQP_STRING_PREFIX
+ unescapedNoPrefixCorrelationId;
 
-        doToCorrelationIDTestImpl(unescapedBinaryPrefixCorrelationId, expected);
+        doToCorrelationIDTestImpl(unescapedNoPrefixCorrelationId, expected);
     }
 
     private void doToIdObjectTestImpl(String idString, Object expected) throws IdConversionException
{


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


Mime
View raw message