activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r780880 - in /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp: DurableTest.cs NMSTestSupport.cs
Date Mon, 01 Jun 2009 23:28:03 GMT
Author: jgomes
Date: Mon Jun  1 23:28:03 2009
New Revision: 780880

URL: http://svn.apache.org/viewvc?rev=780880&view=rev
Log:
Remove tests for non-persistent durable messages.  All durable consumer message tests must
use persistent messages.  (c.f., http://activemq.apache.org/why-do-i-not-receive-messages-on-my-durable-topic-subscription.html)
Added macro expansion for TIBCOHost, TIBCOBackupHost, MSMQHost, and MSMQBackupHost.

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.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=780880&r1=780879&r2=780880&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 Jun  1 23:28:03
2009
@@ -33,34 +33,44 @@
 
 #if !NET_1_1
 		[RowTest]
-		[Row(MsgDeliveryMode.Persistent)]
-		[Row(MsgDeliveryMode.NonPersistent)]
+		[Row(AcknowledgementMode.AutoAcknowledge)]
+		[Row(AcknowledgementMode.ClientAcknowledge)]
+		[Row(AcknowledgementMode.DupsOkAcknowledge)]
+		[Row(AcknowledgementMode.Transactional)]
 #endif
-		public void TestDurableConsumerSelectorChange(MsgDeliveryMode deliveryMode)
+		public void TestDurableConsumerSelectorChange(AcknowledgementMode ackMode)
 		{
 			try
 			{
 				using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
 				{
 					connection.Start();
-					using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+					using(ISession session = connection.CreateSession(ackMode))
 					{
-						ITopic topic = SessionUtil.GetTopic(session, DURABLE_TOPIC);
+						ITopic topic = session.GetTopic(DURABLE_TOPIC);
 						IMessageProducer producer = session.CreateProducer(topic);
 						IMessageConsumer consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='red'",
false);
 
-						producer.DeliveryMode = deliveryMode;
+						producer.DeliveryMode = MsgDeliveryMode.Persistent;
 
 						// Send the messages
 						ITextMessage sendMessage = session.CreateTextMessage("1st");
 						sendMessage.Properties["color"] = "red";
 						producer.Send(sendMessage);
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							session.Commit();
+						}
 
 						ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
 						Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message.");
 						Assert.AreEqual("1st", receiveMsg.Text);
-						Assert.AreEqual(deliveryMode, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not
match");
+						Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode
does not match");
 						receiveMsg.Acknowledge();
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							session.Commit();
+						}
 
 						// Change the subscription.
 						consumer.Dispose();
@@ -72,13 +82,21 @@
 						sendMessage = session.CreateTextMessage("3rd");
 						sendMessage.Properties["color"] = "blue";
 						producer.Send(sendMessage);
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							session.Commit();
+						}
 
 						// Selector should skip the 2nd message.
 						receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
 						Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message.");
 						Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message.");
-						Assert.AreEqual(deliveryMode, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not
match");
+						Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode
does not match");
 						receiveMsg.Acknowledge();
+						if(AcknowledgementMode.Transactional == ackMode)
+						{
+							session.Commit();
+						}
 
 						// Make sure there are no pending messages.
 						Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription.");
@@ -97,25 +115,20 @@
 
 #if !NET_1_1
 		[RowTest]
-		[Row(MsgDeliveryMode.Persistent, AcknowledgementMode.AutoAcknowledge)]
-		[Row(MsgDeliveryMode.Persistent, AcknowledgementMode.ClientAcknowledge)]
-		[Row(MsgDeliveryMode.Persistent, AcknowledgementMode.DupsOkAcknowledge)]
-		[Row(MsgDeliveryMode.Persistent, AcknowledgementMode.Transactional)]
-
-		[Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.AutoAcknowledge)]
-		[Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.ClientAcknowledge)]
-		[Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.DupsOkAcknowledge)]
-		[Row(MsgDeliveryMode.NonPersistent, AcknowledgementMode.Transactional)]
+		[Row(AcknowledgementMode.AutoAcknowledge)]
+		[Row(AcknowledgementMode.ClientAcknowledge)]
+		[Row(AcknowledgementMode.DupsOkAcknowledge)]
+		[Row(AcknowledgementMode.Transactional)]
 #endif
-		public void TestDurableConsumer(MsgDeliveryMode deliveryMode, AcknowledgementMode ackMode)
+		public void TestDurableConsumer(AcknowledgementMode ackMode)
 		{
 			try
 			{
 				RegisterDurableConsumer(TEST_CLIENT_ID, DURABLE_TOPIC, CONSUMER_ID, DURABLE_SELECTOR,
false);
-				RunTestDurableConsumer(deliveryMode, ackMode);
+				RunTestDurableConsumer(ackMode);
 				if(AcknowledgementMode.Transactional == ackMode)
 				{
-					RunTestDurableConsumer(deliveryMode, ackMode);
+					RunTestDurableConsumer(ackMode);
 				}
 			}
 			finally
@@ -124,9 +137,9 @@
 			}
 		}
 
-		protected void RunTestDurableConsumer(MsgDeliveryMode deliveryMode, AcknowledgementMode
ackMode)
+		protected void RunTestDurableConsumer(AcknowledgementMode ackMode)
 		{
-			SendDurableMessage(deliveryMode);
+			SendDurableMessage();
 
 			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
 			{
@@ -139,7 +152,7 @@
 						IMessage msg = consumer.Receive(receiveTimeout);
 						Assert.IsNotNull(msg, "Did not receive first durable message.");
 						msg.Acknowledge();
-						SendDurableMessage(deliveryMode);
+						SendDurableMessage();
 
 						msg = consumer.Receive(receiveTimeout);
 						Assert.IsNotNull(msg, "Did not receive second durable message.");
@@ -154,7 +167,7 @@
 			}
 		}
 
-		protected void SendDurableMessage(MsgDeliveryMode deliveryMode)
+		protected void SendDurableMessage()
 		{
 			using(IConnection connection = CreateConnection(SEND_CLIENT_ID))
 			{
@@ -166,7 +179,7 @@
 					{
 						ITextMessage message = session.CreateTextMessage("Durable Hello");
 
-						producer.DeliveryMode = deliveryMode;
+						producer.DeliveryMode = MsgDeliveryMode.Persistent;
 						producer.RequestTimeout = receiveTimeout;
 						producer.Send(message);
 					}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=780880&r1=780879&r2=780880&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Mon Jun  1
23:28:03 2009
@@ -212,31 +212,55 @@
 		/// <returns></returns>
 		public static string ReplaceEnvVar(string srcText)
 		{
-			// TODO: This should be refactored to be more generic and support full variable
+			// NOTE: Might be able to refactor to be more generic and support full variable
 			// names that can be pulled from the environment.  Currently, we only support limited
-			// hard-coded variable names:
-			//
-			// "${activemqhost}"		- defaults to "localhost".
-			// "${activemqbackuphost}"	- defaults to "localhost".
+			// hard-coded variable names.
 
-			srcText = ReplaceEnvVar(srcText, "ActiveMQHost", "localhost");
-			srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", "localhost");
+			string defaultBroker = GetEnvVar("NMSTestBroker", "localhost");
+
+			srcText = ReplaceEnvVar(srcText, "ActiveMQHost", defaultBroker);
+			srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", defaultBroker);
+
+			srcText = ReplaceEnvVar(srcText, "TIBCOHost", defaultBroker);
+			srcText = ReplaceEnvVar(srcText, "TIBCOBackupHost", defaultBroker);
+
+			srcText = ReplaceEnvVar(srcText, "MSMQHost", defaultBroker);
+			srcText = ReplaceEnvVar(srcText, "MSMQBackupHost", defaultBroker);
 			return srcText;
 		}
 
+		/// <summary>
+		/// Replace the variable with environment variable.
+		/// </summary>
+		/// <param name="srcText"></param>
+		/// <param name="varName"></param>
+		/// <param name="defaultValue"></param>
+		/// <returns></returns>
 		public static string ReplaceEnvVar(string srcText, string varName, string defaultValue)
 		{
+			string replacementValue = GetEnvVar(varName, defaultValue);
+			return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase);
+		}
+
+		/// <summary>
+		/// Get environment variable value.
+		/// </summary>
+		/// <param name="varName"></param>
+		/// <param name="defaultValue"></param>
+		/// <returns></returns>
+		public static string GetEnvVar(string varName, string defaultValue)
+		{
 #if (PocketPC||NETCF||NETCF_2_0)
-			string replacementValue = null;
+			string varValue = null;
 #else
-			string replacementValue = Environment.GetEnvironmentVariable(varName);
+			string varValue = Environment.GetEnvironmentVariable(varName);
 #endif
-			if(null == replacementValue)
+			if(null == varValue)
 			{
-				replacementValue = defaultValue;
+				varValue = defaultValue;
 			}
 
-			return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase);
+			return varValue;
 		}
 
 		/// <summary>



Mime
View raw message