You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2012/02/20 14:57:45 UTC

svn commit: r1291260 - in /qpid/trunk/qpid/java/client/src: main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java

Author: rgodfrey
Date: Mon Feb 20 13:57:45 2012
New Revision: 1291260

URL: http://svn.apache.org/viewvc?rev=1291260&view=rev
Log:
QPID-2660 : AMQMessageDelegate_0_10 uses Byte.valueOf() when converting String properties to short, int, and long values

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
    qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java?rev=1291260&r1=1291259&r2=1291260&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java Mon Feb 20 13:57:45 2012
@@ -582,6 +582,10 @@ public class AMQMessageDelegate_0_10 ext
         {
             return ((Short)o).shortValue();
         }
+        else if(o instanceof String)
+        {
+            return Short.valueOf((String) o);
+        }
         else
         {
             try
@@ -609,6 +613,10 @@ public class AMQMessageDelegate_0_10 ext
         {
             return ((Integer)o).intValue();
         }
+        else if(o instanceof String)
+        {
+            return Integer.valueOf((String) o);
+        }
         else
         {
             try
@@ -635,6 +643,10 @@ public class AMQMessageDelegate_0_10 ext
         {
             return ((Long)o).longValue();
         }
+        else if(o instanceof String)
+        {
+            return Long.valueOf((String) o);
+        }
         else
         {
             try

Modified: qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java?rev=1291260&r1=1291259&r2=1291260&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java (original)
+++ qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java Mon Feb 20 13:57:45 2012
@@ -27,8 +27,19 @@ import org.apache.qpid.transport.Deliver
 import org.apache.qpid.transport.MessageProperties;
 import org.apache.qpid.transport.ReplyTo;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class AMQMessageDelegate_0_10Test extends QpidTestCase
 {
+
+    private static final String MAX_SHORT = "maxShort";
+    private static final String MIN_SHORT = "minShort";
+    private static final String MAX_INT = "maxInt";
+    private static final String MIN_INT = "minInt";
+    private static final String MAX_LONG = "maxLong";
+    private static final String MIN_LONG = "minLong";
+
     /**
      * Tests that when two messages arrive with the same ReplyTo exchange and routingKey values,
      * the cache returns the same Destination object from getJMSReplyTo instead of a new one.
@@ -47,6 +58,7 @@ public class AMQMessageDelegate_0_10Test
         assertSame("Should have received the same Destination objects", dest1, dest2);
     }
 
+
     private AMQMessageDelegate_0_10 generateMessageDelegateWithReplyTo()
     {
         MessageProperties mesProps = new MessageProperties();
@@ -60,4 +72,37 @@ public class AMQMessageDelegate_0_10Test
         AMQMessageDelegate_0_10 delegate = new AMQMessageDelegate_0_10(mesProps,delProps,1L);
         return delegate;
     }
+
+    public void testMessageProperties() throws Exception
+    {
+        MessageProperties msgProps = new MessageProperties();
+
+        Map<String, Object> appHeaders = new HashMap<String, Object>();
+        appHeaders.put(MAX_SHORT, String.valueOf(Short.MAX_VALUE));
+        appHeaders.put(MIN_SHORT, String.valueOf(Short.MIN_VALUE));
+        appHeaders.put(MAX_INT, String.valueOf(Integer.MAX_VALUE));
+        appHeaders.put(MIN_INT, String.valueOf(Integer.MIN_VALUE));
+        appHeaders.put(MAX_LONG, String.valueOf(Long.MAX_VALUE));
+        appHeaders.put(MIN_LONG, String.valueOf(Long.MIN_VALUE));
+
+        msgProps.setApplicationHeaders(appHeaders);
+
+        AMQMessageDelegate_0_10 delegate = new AMQMessageDelegate_0_10(msgProps,new DeliveryProperties(),1L);
+
+        assertEquals("Max long value not retrieved successfully", Long.MAX_VALUE, delegate.getLongProperty(MAX_LONG));
+        assertEquals("Min long value not retrieved successfully", Long.MIN_VALUE, delegate.getLongProperty(MIN_LONG));
+        assertEquals("Max int value not retrieved successfully as long", (long) Integer.MAX_VALUE, delegate.getLongProperty(MAX_INT));
+        assertEquals("Min int value not retrieved successfully as long", (long) Integer.MIN_VALUE, delegate.getLongProperty(MIN_INT));
+        assertEquals("Max short value not retrieved successfully as long", (long) Short.MAX_VALUE, delegate.getLongProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully as long", (long) Short.MIN_VALUE, delegate.getLongProperty(MIN_SHORT));
+
+        assertEquals("Max int value not retrieved successfully", Integer.MAX_VALUE, delegate.getIntProperty(MAX_INT));
+        assertEquals("Min int value not retrieved successfully", Integer.MIN_VALUE, delegate.getIntProperty(MIN_INT));
+        assertEquals("Max short value not retrieved successfully as int", (int) Short.MAX_VALUE, delegate.getIntProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully as int", (int) Short.MIN_VALUE, delegate.getIntProperty(MIN_SHORT));
+
+        assertEquals("Max short value not retrieved successfully", Short.MAX_VALUE, delegate.getShortProperty(MAX_SHORT));
+        assertEquals("Min short value not retrieved successfully", Short.MIN_VALUE, delegate.getShortProperty(MIN_SHORT));
+    }
+
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org