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/systests | |
| 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/systests')
| -rw-r--r-- | java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java index c582a049a2..15d1ff63cf 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java +++ b/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java @@ -20,6 +20,7 @@ */ package org.apache.qpid.test.unit.message; +import org.apache.qpid.AMQPInvalidClassException; import org.apache.qpid.client.AMQConnection; import org.apache.qpid.client.AMQQueue; import org.apache.qpid.client.AMQSession; @@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory; import javax.jms.Destination; import javax.jms.Message; import javax.jms.MessageConsumer; +import javax.jms.MessageFormatException; import javax.jms.MessageProducer; import javax.jms.ObjectMessage; import javax.jms.Queue; @@ -52,6 +54,7 @@ public class JMSPropertiesTest extends QpidBrokerTestCase public static final String JMS_CORR_ID = "QPIDID_01"; public static final int JMS_DELIV_MODE = 1; public static final String JMS_TYPE = "test.jms.type"; + protected static final String NULL_OBJECT_PROPERTY = "NullObject"; protected void setUp() throws Exception { @@ -89,6 +92,28 @@ public class JMSPropertiesTest extends QpidBrokerTestCase int JMSXGroupSeq_VALUE = 1; sentMsg.setIntProperty("JMSXGroupSeq", JMSXGroupSeq_VALUE); + try + { + sentMsg.setObjectProperty(NULL_OBJECT_PROPERTY, null); + fail("Null Object Property value set"); + } + catch (MessageFormatException mfe) + { + // Check the cause + Throwable cause = mfe.getCause(); + assertNotNull(cause); + assertEquals("Incorrect cause ", AMQPInvalidClassException.class, cause.getClass()); + assertEquals("Null values are not allowed to be set", + "Only Primitives objects allowed Object is:null", cause.getMessage()); + + // Also check the linked exception + cause = mfe.getLinkedException(); + assertNotNull(cause); + assertEquals("Incorrect cause ", AMQPInvalidClassException.class, cause.getClass()); + assertEquals("Null values are not allowed to be set", + "Only Primitives objects allowed Object is:null", cause.getMessage()); + } + // send it producer.send(sentMsg); @@ -131,6 +156,9 @@ public class JMSPropertiesTest extends QpidBrokerTestCase assertTrue("JMSXGroupID not available.",JMSXGroupID_Available); assertTrue("JMSXGroupSeq not available.",JMSXGroupSeq_Available); + // Check that the NULL_OBJECT_PROPERTY was not set or transmitted. + assertFalse(NULL_OBJECT_PROPERTY + " was not set.", rm.propertyExists(NULL_OBJECT_PROPERTY)); + con.close(); } |
