summaryrefslogtreecommitdiff
path: root/qpid/java/common
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2010-07-22 14:21:47 +0000
committerMartin Ritchie <ritchiem@apache.org>2010-07-22 14:21:47 +0000
commit7cecf190a22f70317bc8f79b2770c04565d3ee84 (patch)
tree3eb6f687c0744435a88f05ead28588352db80a4b /qpid/java/common
parent21844710b4e6726220e0d9150551566dd7fa13b6 (diff)
downloadqpid-python-7cecf190a22f70317bc8f79b2770c04565d3ee84.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@966680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/common')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java2
-rw-r--r--qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index bd566adf8f..4237ab9bd6 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/qpid/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/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index 007da7423e..66ca43c145 100644
--- a/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/qpid/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"));