You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/10/27 21:08:22 UTC

svn commit: r830323 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs

Author: tabish
Date: Tue Oct 27 20:08:22 2009
New Revision: 830323

URL: http://svn.apache.org/viewvc?rev=830323&view=rev
Log:
Add a new test for message send / receive in transacted sessions.

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=830323&r1=830322&r2=830323&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 Tue Oct 27 20:08:22 2009
@@ -208,7 +208,57 @@
                 Assert.IsNull(consumer.Receive(TimeSpan.FromMilliseconds(1000)));
             }
         }
+
+        [RowTest]
+        [Row(MsgDeliveryMode.NonPersistent, DestinationType.Queue)]        
+        [Row(MsgDeliveryMode.Persistent, DestinationType.Queue)]        
+        [Row(MsgDeliveryMode.NonPersistent, DestinationType.Topic)]            
+        [Row(MsgDeliveryMode.Persistent, DestinationType.Topic)]            
+        [Row(MsgDeliveryMode.NonPersistent, DestinationType.TemporaryQueue)]        
+        [Row(MsgDeliveryMode.Persistent, DestinationType.TemporaryQueue)]        
+        [Row(MsgDeliveryMode.NonPersistent, DestinationType.TemporaryTopic)]            
+        [Row(MsgDeliveryMode.Persistent, DestinationType.TemporaryTopic)]            
+        public void TestSendReceiveTransacted(MsgDeliveryMode deliveryMode, DestinationType destinationType) 
+        {
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                // Send a message to the broker.
+                connection.Start();
+                ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
+                IDestination destination = CreateDestination(session, destinationType);
+                IMessageConsumer consumer = session.CreateConsumer(destination);
+                IMessageProducer producer = session.CreateProducer(destination);
+
+                producer.DeliveryMode = deliveryMode;
+                producer.Send(session.CreateTextMessage("Test"));
+        
+                // Message should not be delivered until commit.
+                Thread.Sleep(1000);
+                Assert.IsNull(consumer.ReceiveNoWait());
+                session.Commit();
+        
+                // Make sure only 1 message was delivered.
+                IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(1000));
+                Assert.IsNotNull(message);
+                Assert.IsFalse(message.NMSRedelivered);
+                Assert.IsNull(consumer.ReceiveNoWait());
         
+                // Message should be redelivered is rollback is used.
+                session.Rollback();
+        
+                // Make sure only 1 message was delivered.
+                message = consumer.Receive(TimeSpan.FromMilliseconds(2000));
+                Assert.IsNotNull(message);
+                Assert.IsTrue(message.NMSRedelivered);
+                Assert.IsNull(consumer.ReceiveNoWait());
+        
+                // If we commit now, the message should not be redelivered.
+                session.Commit();
+                Thread.Sleep(1000);
+                Assert.IsNull(consumer.ReceiveNoWait());
+            }
+        }
+            
 #endif
 
 	}