activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r832105 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
Date Mon, 02 Nov 2009 20:59:56 GMT
Author: tabish
Date: Mon Nov  2 20:59:55 2009
New Revision: 832105

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

Add another test variation to the Durable Test

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

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs?rev=832105&r1=832104&r2=832105&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs Mon Nov  2 20:59:55
2009
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading;
 using NUnit.Framework;
 using NUnit.Framework.Extensions;
 using Apache.NMS.Util;
@@ -36,6 +37,66 @@
 		[Row(AcknowledgementMode.ClientAcknowledge)]
 		[Row(AcknowledgementMode.DupsOkAcknowledge)]
 		[Row(AcknowledgementMode.Transactional)]
+		public void TestSendWhileClosed(AcknowledgementMode ackMode)
+		{
+			try
+			{				
+		        using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+				{
+			        connection.Start();
+					
+					using(ISession session = connection.CreateSession(ackMode))
+					{
+						ITopic topic = session.GetTopic(DURABLE_TOPIC);
+						IMessageProducer producer = session.CreateProducer(topic);
+
+						producer.DeliveryMode = MsgDeliveryMode.Persistent;
+										
+				        ISession consumeSession = connection.CreateSession(ackMode);
+				        IMessageConsumer consumer = consumeSession.CreateDurableConsumer(topic, CONSUMER_ID,
null, false);
+				        Thread.Sleep(1000);
+				        consumer.Dispose();
+						consumer = null;
+				        
+						ITextMessage message = session.CreateTextMessage("DurableTest-TestSendWhileClosed");
+				        message.Properties.SetString("test", "test");
+				        message.NMSType = "test";
+				        producer.Send(message);
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							session.Commit();
+						}
+										        
+						consumer = consumeSession.CreateDurableConsumer(topic, CONSUMER_ID, null, false);
+				        ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+						msg.Acknowledge();
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							consumeSession.Commit();
+						}
+						
+						Assert.IsNotNull(msg);
+				        Assert.AreEqual(msg.Text, "DurableTest-TestSendWhileClosed");
+				        Assert.AreEqual(msg.NMSType, "test");
+				        Assert.AreEqual(msg.Properties.GetString("test"), "test");
+					}
+				}
+			}
+			catch(Exception ex)
+			{
+				Assert.Fail(ex.Message);
+			}
+			finally
+			{
+				UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID);
+			}			
+	    }		
+		
+		[RowTest]
+		[Row(AcknowledgementMode.AutoAcknowledge)]
+		[Row(AcknowledgementMode.ClientAcknowledge)]
+		[Row(AcknowledgementMode.DupsOkAcknowledge)]
+		[Row(AcknowledgementMode.Transactional)]
 		public void TestDurableConsumerSelectorChange(AcknowledgementMode ackMode)
 		{
 			try



Mime
View raw message