activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r992652 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/
Date Sat, 04 Sep 2010 18:12:36 GMT
Author: tabish
Date: Sat Sep  4 18:12:35 2010
New Revision: 992652

URL: http://svn.apache.org/viewvc?rev=992652&view=rev
Log:
Makes several updates to the generic NMS Tests to ensure that each test run that uses a Client
Id uses an Id unique to that run to avoid getting InvalidClientIdExceptions on the broker
if the tests run to close together and don't give the broker enough time to clean up a subscription
of connection.  

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConnectionTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/DurableTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/AsyncConsumeTest.cs Sat Sep
 4 18:12:35 2010
@@ -25,8 +25,7 @@ namespace Apache.NMS.Test
 	public class AsyncConsumeTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "AsyncConsumeDestination";
-		protected static string TEST_CLIENT_ID = "AsyncConsumeClientId";
-		protected static string RESPONSE_CLIENT_ID = "AsyncConsumeResponseClientId";
+		protected string RESPONSE_CLIENT_ID;
 		protected AutoResetEvent semaphore;
 		protected bool received;
 		protected IMessage receivedMsg;
@@ -38,6 +37,8 @@ namespace Apache.NMS.Test
 			semaphore = new AutoResetEvent(false);
 			received = false;
 			receivedMsg = null;
+			
+			RESPONSE_CLIENT_ID = GetTestClientId() + ":RESPONSE";
 		}
 
 		[TearDown]
@@ -52,7 +53,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -81,7 +82,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -112,7 +113,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -142,7 +143,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -178,7 +179,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BadConsumeTest.cs Sat Sep  4
18:12:35 2010
@@ -22,14 +22,13 @@ namespace Apache.NMS.Test
 	[TestFixture]
 	public class BadConsumeTest : NMSTestSupport
 	{
-		protected static string TEST_CLIENT_ID = "BadConsumeTestClientId";
 		protected IConnection connection;
 		protected ISession session;
 
 		[SetUp]
 		public override void SetUp()
 		{
-			connection = CreateConnection(TEST_CLIENT_ID);
+			connection = CreateConnection(GetTestClientId());
 			connection.Start();
 			session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
 		}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/BytesMessageTest.cs Sat Sep
 4 18:12:35 2010
@@ -25,7 +25,6 @@ namespace Apache.NMS.Test
 	public class BytesMessageTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "BytesMessageDestination";
-		protected static string TEST_CLIENT_ID = "BytesMessageClientId";
 		protected byte[] msgContent = {1, 2, 3, 4, 5, 6, 7, 8};
 
 		[Test]
@@ -33,7 +32,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -61,7 +60,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConnectionTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConnectionTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConnectionTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConnectionTest.cs Sat Sep  4
18:12:35 2010
@@ -22,9 +22,7 @@ namespace Apache.NMS.Test
 {
 	[TestFixture]
 	public class ConnectionTest : NMSTestSupport
-	{
-        protected static string TEST_CLIENT_ID = "ConnectionTestClientId";
-        
+	{        
         IConnection startedConnection = null;
         IConnection stoppedConnection = null;
         
@@ -32,7 +30,7 @@ namespace Apache.NMS.Test
         public override void SetUp()
         {
             base.SetUp();
-
+			
             startedConnection = CreateConnection(null);
             startedConnection.Start();
             stoppedConnection = CreateConnection(null);
@@ -119,7 +117,7 @@ namespace Apache.NMS.Test
 			[Values(DestinationType.Queue, DestinationType.Topic)]
 			DestinationType destinationType)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {            
                 ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
                 IDestination destination = CreateDestination(session, destinationType);

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=992652&r1=992651&r2=992652&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 Sat Sep  4 18:12:35
2010
@@ -25,33 +25,43 @@ namespace Apache.NMS.Test
 	[TestFixture]
 	public class DurableTest : NMSTestSupport
 	{
-		protected static string TEST_CLIENT_ID = "TestDurableConsumerClientId";
-		protected static string SEND_CLIENT_ID = "TestDurableProducerClientId";
 		protected static string DURABLE_TOPIC = "TestDurableConsumerTopic";
-		protected static string CONSUMER_ID = "TestDurableConsumerConsumerId";
 		protected static string DURABLE_SELECTOR = "2 > 1";
 
+		protected string TEST_CLIENT_AND_CONSUMER_ID;
+		protected string SEND_CLIENT_ID;
+		
+		[SetUp]
+		public override void SetUp()
+		{
+			base.SetUp();
+			
+			TEST_CLIENT_AND_CONSUMER_ID = GetTestClientId();
+			SEND_CLIENT_ID = GetTestClientId();
+		}
+
 		[Test]
 		public void TestSendWhileClosed(
 			[Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
 				AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
 			AcknowledgementMode ackMode)
 		{
+			string TEST_DURABLE_TOPIC = DURABLE_TOPIC + ":TestSendWhileClosed";
 			try
 			{				
-		        using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+		        using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
 				{
 			        connection.Start();
 					
 					using(ISession session = connection.CreateSession(ackMode))
 					{
-						ITopic topic = session.GetTopic(DURABLE_TOPIC);
+						ITopic topic = session.GetTopic(TEST_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);
+				        IMessageConsumer consumer = consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID,
null, false);
 				        Thread.Sleep(1000);
 				        consumer.Dispose();
 						consumer = null;
@@ -65,7 +75,8 @@ namespace Apache.NMS.Test
 							session.Commit();
 						}
 										        
-						consumer = consumeSession.CreateDurableConsumer(topic, CONSUMER_ID, null, false);
+				        Thread.Sleep(1000);
+						consumer = consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID,
null, false);
 				        ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
 						msg.Acknowledge();
 						if(AcknowledgementMode.Transactional == ackMode)
@@ -86,7 +97,10 @@ namespace Apache.NMS.Test
 			}
 			finally
 			{
-				UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID);
+                // Pause to allow Stomp to unregister at the broker.
+                Thread.Sleep(500);
+
+				UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
 			}			
 	    }		
 		
@@ -96,16 +110,18 @@ namespace Apache.NMS.Test
 				AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
 			AcknowledgementMode ackMode)
 		{
+			string TEST_DURABLE_TOPIC = DURABLE_TOPIC + ":TestDurableConsumerSelectorChange";
+
 			try
 			{
-				using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+				using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
 				{
 					connection.Start();
 					using(ISession session = connection.CreateSession(ackMode))
 					{
-						ITopic topic = session.GetTopic(DURABLE_TOPIC);
+						ITopic topic = session.GetTopic(TEST_DURABLE_TOPIC);
 						IMessageProducer producer = session.CreateProducer(topic);
-						IMessageConsumer consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='red'",
false);
+						IMessageConsumer consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID,
"color='red'", false);
 
 						producer.DeliveryMode = MsgDeliveryMode.Persistent;
 
@@ -128,9 +144,12 @@ namespace Apache.NMS.Test
 							session.Commit();
 						}
 
-						// Change the subscription.
+						// Change the subscription, allowing some time for the Broker to purge the
+						// consumers resources.
 						consumer.Dispose();
-						consumer = session.CreateDurableConsumer(topic, CONSUMER_ID, "color='blue'", false);
+                        Thread.Sleep(1000);
+						
+						consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, "color='blue'",
false);
 
 						sendMessage = session.CreateTextMessage("2nd");
 						sendMessage.Properties["color"] = "red";
@@ -165,7 +184,10 @@ namespace Apache.NMS.Test
 			}
 			finally
 			{
-				UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID);
+                // Pause to allow Stomp to unregister at the broker.
+                Thread.Sleep(500);
+
+				UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
 			}
 		}
 
@@ -175,33 +197,38 @@ namespace Apache.NMS.Test
 				AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
 			AcknowledgementMode ackMode)
 		{
+			string TEST_DURABLE_TOPIC = DURABLE_TOPIC + ":TestDurableConsumer";
+
 			try
 			{
-				RegisterDurableConsumer(TEST_CLIENT_ID, DURABLE_TOPIC, CONSUMER_ID, null, false);
-				RunTestDurableConsumer(ackMode);
+				RegisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_DURABLE_TOPIC, TEST_CLIENT_AND_CONSUMER_ID,
null, false);
+				RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
 				if(AcknowledgementMode.Transactional == ackMode)
 				{
-					RunTestDurableConsumer(ackMode);
+					RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
 				}
 			}
 			finally
 			{
-				UnregisterDurableConsumer(TEST_CLIENT_ID, CONSUMER_ID);
+                // Pause to allow Stomp to unregister at the broker.
+                Thread.Sleep(500);
+				
+				UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
 			}
 		}
 
-		protected void RunTestDurableConsumer(AcknowledgementMode ackMode)
+		protected void RunTestDurableConsumer(string topicName, AcknowledgementMode ackMode)
 		{
-			SendDurableMessage();
-			SendDurableMessage();
+			SendDurableMessage(topicName);
+			SendDurableMessage(topicName);
 
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(ackMode))
 				{
-					ITopic topic = SessionUtil.GetTopic(session, DURABLE_TOPIC);
-					using(IMessageConsumer consumer = session.CreateDurableConsumer(topic, CONSUMER_ID,
null, false))
+					ITopic topic = SessionUtil.GetTopic(session, topicName);
+					using(IMessageConsumer consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID,
null, false))
 					{
 						IMessage msg = consumer.Receive(receiveTimeout);
 						Assert.IsNotNull(msg, "Did not receive first durable message.");
@@ -220,14 +247,14 @@ namespace Apache.NMS.Test
 			}
 		}
 
-		protected void SendDurableMessage()
+		protected void SendDurableMessage(string topicName)
 		{
 			using(IConnection connection = CreateConnection(SEND_CLIENT_ID))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession())
 				{
-					ITopic topic = SessionUtil.GetTopic(session, DURABLE_TOPIC);
+					ITopic topic = SessionUtil.GetTopic(session, topicName);
 					using(IMessageProducer producer = session.CreateProducer(topic))
 					{
 						ITextMessage message = session.CreateTextMessage("Durable Hello");

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MapMessageTest.cs Sat Sep  4
18:12:35 2010
@@ -26,7 +26,6 @@ namespace Apache.NMS.Test
     public class MapMessageTest : NMSTestSupport
     {
         protected static string DESTINATION_NAME = "MessagePropsDestination";
-        protected static string TEST_CLIENT_ID = "MessagePropsClientId";
 
         protected bool a = true;
         protected byte b = 123;
@@ -43,13 +42,13 @@ namespace Apache.NMS.Test
         protected float m = 2.1F;
         protected double n = 2.3;
         protected byte[] o = {1, 2, 3, 4, 5};
-
+		
         [Test]
         public void SendReceiveMapMessage(
             [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
             MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -126,7 +125,7 @@ namespace Apache.NMS.Test
             [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
             MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageSelectorTest.cs Sat Sep
 4 18:12:35 2010
@@ -28,9 +28,6 @@ namespace Apache.NMS.Test
 	{
 		protected const string QUEUE_DESTINATION_NAME = "queue://MessageSelectorQueue";
 		protected const string TOPIC_DESTINATION_NAME = "topic://MessageSelectorTopic";
-		protected const string TEST_CLIENT_ID = "MessageSelectorClientId";
-		protected const string TEST_CLIENT_ID2 = "MessageSelectorClientId2";
-		protected const string TEST_CLIENT_ID3 = "MessageSelectorClientId3";
 
 		private int receivedNonIgnoredMsgCount = 0;
 		private int receivedIgnoredMsgCount = 0;
@@ -68,9 +65,9 @@ namespace Apache.NMS.Test
 			TimeSpan ttl = TimeSpan.FromMinutes(30);
 			const int MaxNumRequests = 100000;
 
-			using(IConnection connection1 = CreateConnection(TEST_CLIENT_ID))
-			using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2))
-			using(IConnection connection3 = CreateConnection(TEST_CLIENT_ID3))
+			using(IConnection connection1 = CreateConnection(GetTestClientId()))
+			using(IConnection connection2 = CreateConnection(GetTestClientId()))
+			using(IConnection connection3 = CreateConnection(GetTestClientId()))
 			{
 				connection1.Start();
 				connection2.Start();

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/MessageTest.cs Sat Sep  4 18:12:35
2010
@@ -27,7 +27,6 @@ namespace Apache.NMS.Test
 	public class MessageTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "MessagePropsDestination";
-		protected static string TEST_CLIENT_ID = "MessagePropsClientId";
 
 		protected bool		a = true;
 		protected byte		b = 123;
@@ -50,7 +49,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSPropertyTest.cs Sat Sep 
4 18:12:35 2010
@@ -25,7 +25,6 @@ namespace Apache.NMS.Test
 	public class NMSPropertyTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "NMSPropsDestination";
-		protected static string TEST_CLIENT_ID = "NMSPropsClientId";
 
 		// standard NMS properties
 		protected string expectedText = "Hey this works!";
@@ -40,7 +39,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

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=992652&r1=992651&r2=992652&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 Sat Sep  4
18:12:35 2010
@@ -35,6 +35,8 @@ namespace Apache.NMS.Test
         protected string clientId;
         protected string passWord;
         protected string userName;
+        protected int testRun;
+        protected int idCounter;
 
         static NMSTestSupport()
         {
@@ -48,6 +50,7 @@ namespace Apache.NMS.Test
         [SetUp]
         public virtual void SetUp()
         {
+            this.testRun++;
         }
 
         [TearDown]
@@ -95,7 +98,7 @@ namespace Apache.NMS.Test
         }
 
         /// <summary>
-        /// Return the configured URI String.  This function loads the connection 
+        /// Return the configured URI String.  This function loads the connection
         /// settings from the configuration file.
         /// </summary>
         /// <returns></returns>
@@ -132,9 +135,9 @@ namespace Apache.NMS.Test
                 brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
             }
 
-			return brokerUri.ToString();
+            return brokerUri.ToString();
         }
-		
+
         /// <summary>
         /// Create the NMS Factory that can create NMS Connections.  This function loads
the
         /// connection settings from the configuration file.
@@ -345,6 +348,21 @@ namespace Apache.NMS.Test
             return varValue;
         }
 
+        public virtual string GetTestClientId()
+        {
+
+            System.Text.StringBuilder id = new System.Text.StringBuilder();
+
+            id.Append("ID:");
+            id.Append(this.GetType().Name);
+            id.Append(":");
+            id.Append(this.testRun);
+            id.Append(":");
+            id.Append(++idCounter);
+
+            return id.ToString();
+        }
+
         /// <summary>
         /// Create a new connection to the broker.
         /// </summary>
@@ -379,24 +397,24 @@ namespace Apache.NMS.Test
         /// <returns></returns>
         public virtual IDestination CreateDestination(ISession session, string destinationName)
         {
-			try
-			{
-            	SessionUtil.DeleteDestination(session, destinationName);
-			}
-			catch(Exception)
-			{
-				// Can't delete it, so lets try and purse it.
-				IDestination destination = SessionUtil.GetDestination(session, destinationName);
-				
-				using(IMessageConsumer consumer = session.CreateConsumer(destination))
-				{
-					while(consumer.Receive(TimeSpan.FromMilliseconds(2000)) != null)
-					{
-					}	
-				}
-			}
+            try
+            {
+                SessionUtil.DeleteDestination(session, destinationName);
+            }
+            catch(Exception)
+            {
+                // Can't delete it, so lets try and purse it.
+                IDestination destination = SessionUtil.GetDestination(session, destinationName);
+
+                using(IMessageConsumer consumer = session.CreateConsumer(destination))
+                {
+                    while(consumer.Receive(TimeSpan.FromMilliseconds(750)) != null)
+                    {
+                    }
+                }
+            }
 
-			return SessionUtil.GetDestination(session, destinationName);
+            return SessionUtil.GetDestination(session, destinationName);
         }
 
         /// <summary>
@@ -476,7 +494,7 @@ namespace Apache.NMS.Test
         {
             return CreateDestination(session, type, "");
         }
-        
+
         public IDestination CreateDestination(ISession session, DestinationType type, string
name)
         {
             if(name == "")
@@ -499,61 +517,61 @@ namespace Apache.NMS.Test
             }
         }
 
-        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet)

+        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet)
         {
             AssertTextMessagesEqual(firstSet, secondSet, "");
         }
-    
-        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet,
string messsage) 
+
+        protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet,
string messsage)
         {
             Assert.AreEqual(firstSet.Length, secondSet.Length, "Message count does not match:
" + messsage);
-    
+
             for(int i = 0; i < secondSet.Length; i++)
             {
                 ITextMessage m1 = firstSet[i] as ITextMessage;
                 ITextMessage m2 = secondSet[i] as ITextMessage;
-                
+
                 AssertTextMessageEqual(m1, m2, "Message " + (i + 1) + " did not match : ");
             }
         }
-    
-        protected void AssertEquals(ITextMessage m1, ITextMessage m2) 
+
+        protected void AssertEquals(ITextMessage m1, ITextMessage m2)
         {
             AssertEquals(m1, m2, "");
         }
-    
-        protected void AssertTextMessageEqual(ITextMessage m1, ITextMessage m2, string message)

+
+        protected void AssertTextMessageEqual(ITextMessage m1, ITextMessage m2, string message)
         {
             Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but
was {" + m2 + "}");
-    
-            if(m1 == null) 
+
+            if(m1 == null)
             {
                 return;
             }
-    
+
             Assert.AreEqual(m1.Text, m2.Text, message);
         }
-    
+
         protected void AssertEquals(IMessage m1, IMessage m2)
         {
             AssertEquals(m1, m2, "");
         }
-    
+
         protected void AssertEquals(IMessage m1, IMessage m2, string message)
         {
             Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but
was {" + m2 + "}");
-    
+
             if(m1 == null)
             {
                 return;
             }
-    
+
             Assert.IsTrue(m1.GetType() == m2.GetType(), message + ": expected {" + m1 + "},
but was {" + m2 + "}");
-    
-            if(m1 is ITextMessage) 
+
+            if(m1 is ITextMessage)
             {
                 AssertTextMessageEqual((ITextMessage)m1, (ITextMessage)m2, message);
-            } 
+            }
             else
             {
                 Assert.AreEqual(m1, m2, message);

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs Sat Sep  4 18:12:35
2010
@@ -23,12 +23,10 @@ namespace Apache.NMS.Test
 	[TestFixture]
 	public class ProducerTest : NMSTestSupport
 	{
-		protected static string TEST_CLIENT_ID = "TestProducerClientId";
-
         [Test]
         public void TestProducerSendToNullDestinationWithoutDefault()
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession())
@@ -54,7 +52,7 @@ namespace Apache.NMS.Test
         [Test]
         public void TestProducerSendToNullDestinationWithDefault()
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession())
@@ -82,7 +80,7 @@ namespace Apache.NMS.Test
 		[Test]
 		public void TestProducerSendToNonDefaultDestination()
 		{
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession())

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/StreamMessageTest.cs Sat Sep
 4 18:12:35 2010
@@ -24,7 +24,6 @@ namespace Apache.NMS.Test
     public class StreamMessageTest : NMSTestSupport
     {
         protected static string DESTINATION_NAME = "StreamMessageDestination";
-        protected static string TEST_CLIENT_ID = "StreamMessageClientId";
 
         protected bool a = true;
         protected byte b = 123;
@@ -46,7 +45,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
Sat Sep  4 18:12:35 2010
@@ -28,7 +28,6 @@ namespace Apache.NMS.Test
 		protected const string TOPIC_DESTINATION_NAME = "topic://AutoDeleteTopic";
 		protected const string TEMP_QUEUE_DESTINATION_NAME = "temp-queue://AutoDeleteTempQueue";
 		protected const string TEMP_TOPIC_DESTINATION_NAME = "temp-topic://AutoDeleteTempTopic";
-		protected const string TEST_CLIENT_ID = "TempDestinationClientId";
 
 		[Test]
 		public void TempDestinationDeletionTest(
@@ -37,7 +36,7 @@ namespace Apache.NMS.Test
 			[Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME, TEMP_QUEUE_DESTINATION_NAME, TEMP_TOPIC_DESTINATION_NAME)]
 			string destinationName)
 		{
-			using(IConnection connection1 = CreateConnection(TEST_CLIENT_ID + new System.Random().Next()))
+			using(IConnection connection1 = CreateConnection(GetTestClientId()))
 			{
 				connection1.Start();
 				using(ISession session = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TextMessage.cs Sat Sep  4 18:12:35
2010
@@ -24,14 +24,13 @@ namespace Apache.NMS.Test
 	public class TextMessageTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "TextMessageDestination";
-		protected static string TEST_CLIENT_ID = "TextMessageClientId";
 
 		[Test]
 		public void SendReceiveTextMessage(
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/TransactionTest.cs Sat Sep 
4 18:12:35 2010
@@ -25,15 +25,13 @@ namespace Apache.NMS.Test
     public class TransactionTest : NMSTestSupport
     {
         protected static string DESTINATION_NAME = "TransactionTestDestination";
-        protected static string TEST_CLIENT_ID = "TransactionTestClientId";
-        protected static string TEST_CLIENT_ID2 = "TransactionTestClientId2";
 
         [Test]
         public void TestSendRollback(
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
@@ -78,7 +76,7 @@ namespace Apache.NMS.Test
             ITextMessage firstMsgSend;
             ITextMessage secondMsgSend;
 
-            using(IConnection connection1 = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection1 = CreateConnection(GetTestClientId()))
             {
                 connection1.Start();
                 using(ISession session1 = connection1.CreateSession(AcknowledgementMode.Transactional))
@@ -89,7 +87,7 @@ namespace Apache.NMS.Test
                         // First connection session that sends one message, and the
                         // second message is implicitly rolled back as the session is
                         // disposed before Commit() can be called.
-                        using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2))
+                        using(IConnection connection2 = CreateConnection(GetTestClientId()))
                         {
                             connection2.Start();
                             using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
@@ -109,7 +107,7 @@ namespace Apache.NMS.Test
                         }
 
                         // Second connection session that will send one message.
-                        using(IConnection connection2 = CreateConnection(TEST_CLIENT_ID2))
+                        using(IConnection connection2 = CreateConnection(GetTestClientId()))
                         {
                             connection2.Start();
                             using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
@@ -144,7 +142,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
@@ -186,7 +184,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
@@ -231,7 +229,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(ackMode))
@@ -263,7 +261,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(ackMode))
@@ -305,7 +303,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
 		{
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 using(ISession session = connection.CreateSession(ackMode))
@@ -360,7 +358,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
@@ -399,7 +397,7 @@ namespace Apache.NMS.Test
 			[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
 			MsgDeliveryMode deliveryMode)
         {
-            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            using(IConnection connection = CreateConnection(GetTestClientId()))
             {
                 connection.Start();
                 ISession session = connection.CreateSession(AcknowledgementMode.Transactional);

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs?rev=992652&r1=992651&r2=992652&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs Sat Sep  4
18:12:35 2010
@@ -69,13 +69,12 @@ namespace Apache.NMS.Test
 	public class XmlMessageTest : NMSTestSupport
 	{
 		protected static string DESTINATION_NAME = "XmlMessageDestination";
-		protected static string TEST_CLIENT_ID = "XmlMessageClientId";
 
 #if NET_3_5 || MONO
 		[Test]
 		public void SendReceiveXmlMessage_Net35()
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
@@ -130,7 +129,7 @@ namespace Apache.NMS.Test
 		[Test]
 		public void SendReceiveXmlMessage()
 		{
-			using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+			using(IConnection connection = CreateConnection(GetTestClientId()))
 			{
 				connection.Start();
 				using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))



Mime
View raw message