diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2012-02-20 13:57:45 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2012-02-20 13:57:45 +0000 |
| commit | 377fcb66deaba1871aecf6056ff94daa765d7508 (patch) | |
| tree | 48b8479f8f53a52e054c81d0286fdf5c27a8dea4 /qpid/java/client/src/test | |
| parent | 6ce4028b1ae846729eedd903f8c903e2a887266f (diff) | |
| download | qpid-python-377fcb66deaba1871aecf6056ff94daa765d7508.tar.gz | |
QPID-2660 : AMQMessageDelegate_0_10 uses Byte.valueOf() when converting String properties to short, int, and long values
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1291260 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/test')
| -rw-r--r-- | qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java index 4636851c79..8c66a75764 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java +++ b/qpid/java/client/src/test/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10Test.java @@ -27,8 +27,19 @@ import org.apache.qpid.transport.DeliveryProperties; 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 extends QpidTestCase 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 extends QpidTestCase 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)); + } + } |
