Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 49268 invoked from network); 12 Aug 2008 00:28:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Aug 2008 00:28:51 -0000 Received: (qmail 62653 invoked by uid 500); 12 Aug 2008 00:28:50 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 62629 invoked by uid 500); 12 Aug 2008 00:28:50 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 62620 invoked by uid 99); 12 Aug 2008 00:28:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Aug 2008 17:28:50 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Aug 2008 00:28:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 669202388882; Mon, 11 Aug 2008 17:28:00 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r685000 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs Date: Tue, 12 Aug 2008 00:28:00 -0000 To: commits@activemq.apache.org From: jgomes@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080812002800.669202388882@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"); + } + } + } + } } }