public void SendReceiveForeignTextMessageTest(
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
using(IConnection connection = CreateConnection())
{
connection.Start();
using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
using(IMessageConsumer consumer = session.CreateConsumer(destination))
using(IMessageProducer producer = session.CreateProducer(destination))
{
try
{
producer.DeliveryMode = deliveryMode;
TextMessage request = new TextMessage();
request.Properties[propertyName] = propertyValue;
request.Text = textBody;
producer.Send(request);
ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage;
Assert.IsNotNull(message, "No message returned!");
Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// Check the body
Assert.AreEqual(textBody, message.Text, "TextMessage body was wrong.");
// use generic API to access entries
Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
// use type safe APIs
Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
}
catch(NotSupportedException)
{
}
}
}
}
}