From 1d30de9905c3d66174429cd0ab5109e3e8961301 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 7 May 2007 09:28:15 +0000 Subject: QPID-466 Updated FieldTable to ensure no Decimal value is set that is larger than can be transmitted over AMQP. That is a max scale value of Byte.MAX_VALUE and value of up to Integer.MAX_VALUE. Additional tests to ensure this is the case. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@535809 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/test/unit/basic/PropertyValueTest.java | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'java/client') diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java index 4a3a49215e..90784b0772 100644 --- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java +++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java @@ -194,6 +194,30 @@ public class PropertyValueTest extends TestCase implements MessageListener BigDecimal bd = new BigDecimal(Integer.MAX_VALUE); ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal"), bd.setScale(Byte.MAX_VALUE)); + + bd = new BigDecimal((long) Integer.MAX_VALUE + 1L); + + try + { + ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal-bad-value"), bd.setScale(Byte.MAX_VALUE)); + fail("UnsupportedOperationException should be thrown as value can't be correctly transmitted"); + } + catch (UnsupportedOperationException uoe) + { + // normal path. + } + + + try + { + ((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal-bad-scale"), bd.setScale(Byte.MAX_VALUE + 1)); + fail("UnsupportedOperationException should be thrown as scale can't be correctly transmitted"); + } + catch (UnsupportedOperationException uoe) + { + // normal path. + } + //Void ((AMQMessage) m).setVoidProperty(new AMQShortString("void")); @@ -254,7 +278,7 @@ public class PropertyValueTest extends TestCase implements MessageListener "Test", m.getStringProperty("String")); // AMQP Tests Specific values - + Assert.assertEquals("Check Timestamp properties are correctly transported", m.getStringProperty("time-str"), ((AMQMessage) m).getTimestampProperty(new AMQShortString("time")).toString()); -- cgit v1.2.1