AMQConnection con2 = (AMQConnection) getConnection("guest", "guest");
Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageProducer producer = producerSession.createProducer(queue);
Destination JMS_REPLY_TO = new AMQQueue(con2, "my.replyto");
// create a test message to send
ObjectMessage sentMsg = new NonQpidObjectMessage(producerSession);
sentMsg.setJMSCorrelationID(JMS_CORR_ID);
sentMsg.setJMSDeliveryMode(JMS_DELIV_MODE);
sentMsg.setJMSType(JMS_TYPE);
sentMsg.setJMSReplyTo(JMS_REPLY_TO);
String JMSXGroupID_VALUE = "group";
sentMsg.setStringProperty("JMSXGroupID", JMSXGroupID_VALUE);
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 error message
assertEquals("Incorrect error message", AMQPInvalidClassException.INVALID_OBJECT_MSG + "null", mfe.getMessage());
}
try
{
sentMsg.setObjectProperty(INVALID_OBJECT_PROPERTY, new Exception());
fail("Non primitive Object Property value set");
}
catch (MessageFormatException mfe)
{
// Check the error message
assertEquals("Incorrect error message: " + mfe.getMessage(), AMQPInvalidClassException.INVALID_OBJECT_MSG + Exception.class, mfe.getMessage());
}
// send it
producer.send(sentMsg);
con2.close();
con.start();
// get message and check JMS properties
ObjectMessage rm = (ObjectMessage) consumer.receive(2000);
assertNotNull(rm);
assertEquals("JMS Correlation ID mismatch", sentMsg.getJMSCorrelationID(), rm.getJMSCorrelationID());
// TODO: Commented out as always overwritten by send delivery mode value - prob should not set in conversion
// assertEquals("JMS Delivery Mode mismatch",sentMsg.getJMSDeliveryMode(),rm.getJMSDeliveryMode());
assertEquals("JMS Type mismatch", sentMsg.getJMSType(), rm.getJMSType());
assertEquals("JMS Reply To mismatch", sentMsg.getJMSReplyTo(), rm.getJMSReplyTo());
assertTrue("JMSMessageID Does not start ID:", rm.getJMSMessageID().startsWith("ID:"));
assertEquals("JMS Default priority should be 4",Message.DEFAULT_PRIORITY,rm.getJMSPriority());
//Validate that the JMSX values are correct
assertEquals("JMSXGroupID is not as expected:", JMSXGroupID_VALUE, rm.getStringProperty("JMSXGroupID"));