diff options
author | Martin Ritchie <ritchiem@apache.org> | 2010-07-22 14:21:47 +0000 |
---|---|---|
committer | Martin Ritchie <ritchiem@apache.org> | 2010-07-22 14:21:47 +0000 |
commit | 7a43da08f8cc070bb252ea62eadc59abde92995c (patch) | |
tree | 379dcc45f0e1903686ca26fbcf2006b52649153d /java/common | |
parent | 167570b1632574a9e81e8f2a62e58d537a88dd12 (diff) | |
download | qpid-python-7a43da08f8cc070bb252ea62eadc59abde92995c.tar.gz |
QPID-2744 : Add tests for correct exception when null object is set via setObjectProperty in Field Table and via JMS Properties
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@966680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/common')
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/framing/FieldTable.java | 2 | ||||
-rw-r--r-- | java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java index bd566adf8f..4237ab9bd6 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java +++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java @@ -675,7 +675,7 @@ public class FieldTable return setBytes(string, (byte[]) object); } - throw new AMQPInvalidClassException("Only Primatives objects allowed Object is:" + object.getClass()); + throw new AMQPInvalidClassException("Only Primitives objects allowed Object is:" + (object == null ? "null" : object.getClass())); } public boolean isNullStringValue(String name) diff --git a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java index 007da7423e..66ca43c145 100644 --- a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java +++ b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java @@ -25,6 +25,7 @@ import junit.framework.TestCase; import org.apache.mina.common.ByteBuffer; +import org.apache.qpid.AMQInvalidArgumentException; import org.apache.qpid.AMQPInvalidClassException; import org.slf4j.Logger; @@ -520,6 +521,18 @@ public class PropertyFieldTableTest extends TestCase table.setObject("object-short", Short.MAX_VALUE); table.setObject("object-string", "Hello"); + try + { + table.setObject("Null-object", null); + fail("null values are not allowed"); + } + catch (AMQPInvalidClassException aice) + { + assertEquals("Null values are not allowed to be set", + "Only Primitives objects allowed Object is:null", aice.getMessage()); + } + + Assert.assertEquals((Boolean) true, table.getBoolean("bool")); Assert.assertEquals((Byte) Byte.MAX_VALUE, table.getByte("byte")); assertBytesEqual(bytes, table.getBytes("bytes")); |