activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r991307 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs
Date Tue, 31 Aug 2010 19:32:51 GMT
Author: tabish
Date: Tue Aug 31 19:32:51 2010
New Revision: 991307

URL: http://svn.apache.org/viewvc?rev=991307&view=rev
Log:
Attempt to make the test less error prone on slow systems without a lot of long sleep calls.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs?rev=991307&r1=991306&r2=991307&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs
Tue Aug 31 19:32:51 2010
@@ -435,8 +435,20 @@ namespace Apache.NMS.ActiveMQ.Test
 
 				failover.Resumed = OnResumed;
 
+				const int MAX_ATTEMPTS = 50;
+
 				transport.Start();
-				Thread.Sleep(2000);
+				
+				for(int i = 0; i < MAX_ATTEMPTS; ++i)
+				{
+					if(failover.IsConnected)
+					{
+						break;
+					}
+					
+					Thread.Sleep(100);
+				}
+				
 				Assert.IsTrue(failover.IsConnected);
 
 				// Ensure the current mock transport has the correct outgoing command handler
@@ -453,10 +465,24 @@ namespace Apache.NMS.ActiveMQ.Test
 					ConnectedBrokers = connectedBrokers
 				});
 
-				failover.Remove(true, "mock://localhost:61613");
+				// Give a bit of time for the Command to actually be processed.
 				Thread.Sleep(2000);
-
-				mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				
+				failover.Remove(true, "mock://localhost:61613");
+				
+				mock = null;
+				
+				for(int i = 0; i < MAX_ATTEMPTS; ++i)
+				{
+					mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+					if(mock != null)
+					{
+						break;
+					}
+					
+					Thread.Sleep(100);
+				}
+				
 				Assert.IsNotNull(mock, "Error reconnecting to failover broker.");
 				Assert.AreEqual(61616, mock.RemoteAddress.Port);
 				Assert.AreEqual("Reconnected", mock.Name);



Mime
View raw message