activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r832156 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
Date Mon, 02 Nov 2009 22:26:24 GMT
Author: tabish
Date: Mon Nov  2 22:26:23 2009
New Revision: 832156

URL: http://svn.apache.org/viewvc?rev=832156&view=rev
Log:
* ConsumerTest.cs: 

New test for safety of changing a message after a send and reusing it.

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs?rev=832156&r1=832155&r2=832156&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs Mon Nov  2 22:26:23
2009
@@ -28,6 +28,8 @@
 	public class ConsumerTest : NMSTestSupport
 	{
 		protected static string TEST_CLIENT_ID = "TestConsumerClientId";
+		protected const int COUNT = 25;
+        protected const string VALUE_NAME = "value";
 
         private bool dontAck;
 
@@ -166,6 +168,59 @@
         [Row(AcknowledgementMode.ClientAcknowledge)]
         [Row(AcknowledgementMode.DupsOkAcknowledge)]
         [Row(AcknowledgementMode.Transactional)]
+        public void TestDoChangeSentMessage(AcknowledgementMode ackMode)
+        {
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession(ackMode))
+                {
+                    ITemporaryQueue queue = session.CreateTemporaryQueue();
+                    using(IMessageConsumer consumer = session.CreateConsumer(queue))
+                    {
+						IMessageProducer producer = session.CreateProducer(queue);
+						ITextMessage message = session.CreateTextMessage();
+						
+						string prefix = "ConsumerTest - TestDoChangeSentMessage: ";
+						
+				        for(int i = 0; i < COUNT; i++) 
+						{
+							message.Properties[VALUE_NAME] = i;
+							message.Text = prefix + Convert.ToString(i);
+				            
+							producer.Send(message);	
+							
+							message.ClearBody();
+							message.ClearProperties();
+				        }
+						
+						if(ackMode == AcknowledgementMode.Transactional)
+						{
+							session.Commit();
+						}
+						
+				        for(int i = 0; i < COUNT; i++)
+						{
+				            ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage;
+							Assert.AreEqual(msg.Text, prefix + Convert.ToString(i));
+							Assert.AreEqual(msg.Properties[VALUE_NAME], i);
+				        }
+						
+						if(ackMode == AcknowledgementMode.Transactional)
+						{
+							session.Commit();
+						}
+						
+                    }
+                }
+            }
+        }
+		
+        [RowTest]
+        [Row(AcknowledgementMode.AutoAcknowledge)]
+        [Row(AcknowledgementMode.ClientAcknowledge)]
+        [Row(AcknowledgementMode.DupsOkAcknowledge)]
+        [Row(AcknowledgementMode.Transactional)]
         public void TestConsumerReceiveBeforeMessageDispatched(AcknowledgementMode ackMode)
         {
             // Launch a thread to perform a delayed send.



Mime
View raw message