You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2008/08/12 02:28:00 UTC
svn commit: r685000 -
/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs
Author: jgomes
Date: Mon Aug 11 17:27:59 2008
New Revision: 685000
URL: http://svn.apache.org/viewvc?rev=685000&view=rev
Log:
Fixes [AMQNET-103]. (See https://issues.apache.org/activemq/browse/AMQNET-103)
Modified:
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs
Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs?rev=685000&r1=684999&r2=685000&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs Mon Aug 11 17:27:59 2008
@@ -18,6 +18,7 @@
using System;
using NUnit.Framework;
using Apache.NMS.Util;
+using System.Collections;
namespace Apache.NMS.Test
{
@@ -125,5 +126,88 @@
}
}
}
+
+ [Test]
+ public void SendReceiveNestedMapMessage()
+ {
+ doSendReceiveNestedMapMessage(false);
+ }
+
+ [Test]
+ public void SendReceiveNestedMapMessagePersistent()
+ {
+ doSendReceiveNestedMapMessage(true);
+ }
+
+ protected void doSendReceiveNestedMapMessage(bool persistent)
+ {
+ using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+ {
+ connection.Start();
+ using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME);
+ using(IMessageConsumer consumer = session.CreateConsumer(destination, receiveTimeout))
+ using(IMessageProducer producer = session.CreateProducer(destination, receiveTimeout))
+ {
+ producer.Persistent = persistent;
+ producer.RequestTimeout = receiveTimeout;
+ IMapMessage request = session.CreateMapMessage();
+ const string textFieldValue = "Nested Map Messages Rule!";
+
+ request.Body.SetString("textField", textFieldValue);
+
+ IDictionary grandChildMap = new Hashtable();
+ grandChildMap["x"] = "abc";
+ grandChildMap["y"] = new ArrayList(new object[] {"a", "b", "c"});
+
+ IDictionary nestedMap = new Hashtable();
+ nestedMap["a"] = "foo";
+ nestedMap["b"] = (int) 23;
+ nestedMap["c"] = (long) 45;
+ nestedMap["d"] = grandChildMap;
+
+ request.Body.SetDictionary("mapField", nestedMap);
+ request.Body.SetList("listField", new ArrayList(new Object[] {"a", "b", "c"}));
+
+ producer.Send(request);
+
+ IMapMessage message = consumer.Receive(receiveTimeout) as IMapMessage;
+ Assert.IsNotNull(message, "No message returned!");
+ Assert.AreEqual(request.Body.Count, message.Body.Count, "Invalid number of message maps.");
+ Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent does not match");
+
+ string textFieldResponse = message.Body.GetString("textField");
+ Assert.AreEqual(textFieldValue, textFieldResponse, "textField does not match.");
+
+ IDictionary nestedMapResponse = message.Body.GetDictionary("mapField");
+ Assert.IsNotNull(nestedMapResponse, "Nested map not returned.");
+ Assert.AreEqual(nestedMap.Count, nestedMapResponse.Count, "nestedMap: Wrong number of elements");
+ Assert.AreEqual("foo", nestedMapResponse["a"], "nestedMap: a");
+ Assert.AreEqual(23, nestedMapResponse["b"], "nestedMap: b");
+ Assert.AreEqual(45, nestedMapResponse["c"], "nestedMap: c");
+
+ IDictionary grandChildMapResponse = nestedMapResponse["d"] as IDictionary;
+ Assert.IsNotNull(grandChildMapResponse, "Grand child map not returned.");
+ Assert.AreEqual(grandChildMap.Count, grandChildMapResponse.Count, "grandChildMap: Wrong number of elements");
+ Assert.AreEqual(grandChildMapResponse["x"], "abc", "grandChildMap: x");
+
+ IList grandChildList = grandChildMapResponse["y"] as IList;
+ Assert.IsNotNull(grandChildList, "Grand child list not returned.");
+ Assert.AreEqual(3, grandChildList.Count, "grandChildList: Wrong number of list elements.");
+ Assert.AreEqual("a", grandChildList[0], "grandChildList: a");
+ Assert.AreEqual("b", grandChildList[1], "grandChildList: b");
+ Assert.AreEqual("c", grandChildList[2], "grandChildList: c");
+
+ IList listFieldResponse = message.Body.GetList("listField");
+ Assert.IsNotNull(listFieldResponse, "Nested list not returned.");
+ Assert.AreEqual(3, listFieldResponse.Count, "listFieldResponse: Wrong number of list elements.");
+ Assert.AreEqual("a", listFieldResponse[0], "listFieldResponse: a");
+ Assert.AreEqual("b", listFieldResponse[1], "listFieldResponse: b");
+ Assert.AreEqual("c", listFieldResponse[2], "listFieldResponse: c");
+ }
+ }
+ }
+ }
}
}