activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1003083 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
Date Thu, 30 Sep 2010 14:40:11 GMT
Author: tabish
Date: Thu Sep 30 14:40:11 2010
New Revision: 1003083

URL: http://svn.apache.org/viewvc?rev=1003083&view=rev
Log:
Add a new test for ReceiveNoWait

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=1003083&r1=1003082&r2=1003083&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 Thu Sep 30 14:40:11
2010
@@ -503,6 +503,57 @@ namespace Apache.NMS.Test
             }
         }
 
+        [Test]
+        public void TestReceiveNoWait(
+            [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
+                AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
+            AcknowledgementMode ackMode,
+            [Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)]
+            MsgDeliveryMode deliveryMode)
+        {
+			const int RETRIES = 20;
+
+			using(IConnection connection = CreateConnection())
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession(ackMode))
+                {
+                    IDestination destination = session.CreateTemporaryQueue();
+
+                    using(IMessageProducer producer = session.CreateProducer(destination))
+                    {
+						producer.DeliveryMode = deliveryMode;
+						ITextMessage message = session.CreateTextMessage("TEST");
+						producer.Send(message);
+
+                        if(AcknowledgementMode.Transactional == ackMode)
+                        {
+                            session.Commit();
+                        }							
+					}
+										
+					using(IMessageConsumer consumer = session.CreateConsumer(destination))
+					{						
+						IMessage message = null;
+
+						for(int i = 0; i < RETRIES && message == null; ++i)
+						{
+							message = consumer.ReceiveNoWait();
+							Thread.Sleep(100);
+						}
+						
+						Assert.IsNotNull(message);
+						message.Acknowledge();
+						
+                        if(AcknowledgementMode.Transactional == ackMode)
+                        {
+                            session.Commit();
+                        }						
+					}
+				}
+        	}
+		}
+		
 #endif
 
     }



Mime
View raw message