activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r987655 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/Transport/Failover/ main/csharp/Transport/Mock/ test/csharp/ test/csharp/Transport/Mock/ test/csharp/Transport/failover/
Date Fri, 20 Aug 2010 22:27:03 GMT
Author: jgomes
Date: Fri Aug 20 22:27:02 2010
New Revision: 987655

URL: http://svn.apache.org/viewvc?rev=987655&view=rev
Log:
Set failover properties from URI using the "transport." prefix designation.
Code clean-up to newer C# style of programming for consistency.
Unit test clean-up to verify the failover transport and mock transports.

Fixes [AMQNET-274]. (See https://issues.apache.org/activemq/browse/AMQNET-274)

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransport.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Mock/MockTransportTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/failover/FailoverTransportTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.cs Fri Aug 20 22:27:02 2010
@@ -352,8 +352,8 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			ITransport transport = connectedTransport.GetAndSet(null);
 			if(transport != null)
 			{
-				transport.Command = new CommandHandler(disposedOnCommand);
-				transport.Exception = new ExceptionHandler(disposedOnException);
+				transport.Command = disposedOnCommand;
+				transport.Exception = disposedOnException;
 				try
 				{
 					transport.Stop();
@@ -541,9 +541,7 @@ namespace Apache.NMS.ActiveMQ.Transport.
 					if(command is RemoveInfo)
 					{
 						// Simulate response to RemoveInfo command
-						Response response = new Response();
-						response.CorrelationId = command.CommandId;
-						OnCommand(this, response);
+						OnCommand(this, new Response() { CorrelationId = command.CommandId });
 						return;
 					}
 				}
@@ -689,6 +687,18 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			Reconnect(rebalance);
 		}
 
+		public void Add(bool rebalance, String u)
+		{
+			try
+			{
+				Add(rebalance, new Uri[] { new Uri(u) });
+			}
+			catch(Exception e)
+			{
+				Tracer.ErrorFormat("Failed to parse URI '{0}': {1}", u, e.Message);
+			}
+		}
+
 		public void Remove(bool rebalance, Uri[] u)
 		{
 			lock(uris)
@@ -702,19 +712,11 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			Reconnect(rebalance);
 		}
 
-		public void Add(bool rebalance, String u)
+		public void Remove(bool rebalance, String u)
 		{
 			try
 			{
-				Uri uri = new Uri(u);
-				lock(uris)
-				{
-					if(!uris.Contains(uri))
-					{
-						uris.Add(uri);
-						Reconnect(rebalance);
-					}
-				}
+				Remove(rebalance, new Uri[] { new Uri(u) });
 			}
 			catch(Exception e)
 			{
@@ -740,23 +742,23 @@ namespace Apache.NMS.ActiveMQ.Transport.
 											"ActiveMQ Failover Worker: " + this.GetHashCode().ToString());
 					}
 
-                    if(rebalance)
-                    {
-                        ITransport transport = connectedTransport.GetAndSet(null);
-                        if(transport != null)
-                        {
-                            transport.Command = new CommandHandler(disposedOnCommand);
-                            transport.Exception = new ExceptionHandler(disposedOnException);
-                            try
-                            {
-                                transport.Stop();
-                            }
-                            catch(Exception ex)
-                            {
-                                ex.GetType();   // Ignore errors but this lets us see the error during debugging
-                            }
-                        }
-                    }
+					if(rebalance)
+					{
+						ITransport transport = connectedTransport.GetAndSet(null);
+						if(transport != null)
+						{
+							transport.Command = disposedOnCommand;
+							transport.Exception = disposedOnException;
+							try
+							{
+								transport.Stop();
+							}
+							catch(Exception ex)
+							{
+								ex.GetType();   // Ignore errors but this lets us see the error during debugging
+							}
+						}
+					}
 
 					Tracer.Debug("Waking up reconnect task");
 					try
@@ -812,10 +814,8 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			Tracer.Info("Restoring previous transport connection.");
 			t.Start();
 
-			//send information to the broker - informing it we are an ft client
-			ConnectionControl cc = new ConnectionControl();
-			cc.FaultTolerant = true;
-			t.Oneway(cc);
+			// Send information to the broker - informing it we are a fault tolerant client
+			t.Oneway(new ConnectionControl() { FaultTolerant = true });
 			stateTracker.DoRestore(t);
 
 			Tracer.Info("Sending queued commands...");
@@ -888,8 +888,8 @@ namespace Apache.NMS.ActiveMQ.Transport.
 								backups.RemoveAt(0);
 								ITransport t = bt.Transport;
 								Uri uri = bt.Uri;
-								t.Command = new CommandHandler(OnCommand);
-								t.Exception = new ExceptionHandler(OnException);
+								t.Command = OnCommand;
+								t.Exception = OnException;
 								try
 								{
 									if(started)
@@ -989,8 +989,8 @@ namespace Apache.NMS.ActiveMQ.Transport.
 
 							if(transport != null)
 							{
-								transport.Command = new CommandHandler(OnCommand);
-								transport.Exception = new ExceptionHandler(OnException);
+								transport.Command = OnCommand;
+								transport.Exception = OnException;
 								transport.Start();
 
 								if(started)
@@ -1145,13 +1145,16 @@ namespace Apache.NMS.ActiveMQ.Transport.
 						{
 							try
 							{
-								BackupTransport bt = new BackupTransport(this);
-								bt.Uri = uri;
+								BackupTransport bt = new BackupTransport(this)
+								{
+									Uri = uri
+								};
+
 								if(!backups.Contains(bt))
 								{
 									ITransport t = TransportFactory.CompositeConnect(uri);
-									t.Command = new CommandHandler(bt.OnCommand);
-									t.Exception = new ExceptionHandler(bt.OnException);
+									t.Command = bt.OnCommand;
+									t.Exception = bt.OnException;
 									t.Start();
 									bt.Transport = t;
 									backups.Add(bt);

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransportFactory.cs Fri Aug 20 22:27:02 2010
@@ -61,7 +61,7 @@ namespace Apache.NMS.ActiveMQ.Transport.
 		public FailoverTransport CreateTransport(StringDictionary parameters)
 		{
 			FailoverTransport transport = new FailoverTransport();
-			URISupport.SetProperties(transport, parameters, "");
+			URISupport.SetProperties(transport, parameters, "transport.");
 			return transport;
 		}
 	}

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransport.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransport.cs Fri Aug 20 22:27:02 2010
@@ -26,270 +26,281 @@ using ThreadInterruptedException = Syste
 #endif
 
 namespace Apache.NMS.ActiveMQ.Transport.Mock
-{	
+{
 	/// <summary>
 	/// Transport used for testing, mimics the behaviour of a normal Transport and allows
 	/// messages to be sent and received 
 	/// </summary>
 	public class MockTransport : ITransport
 	{
-        #region Properties
+		#region Properties
 
-        private string name;
-        private bool failOnSendMessage = false;
-        private int numMessagesToRespondTo = -1;
-        private int numMessagesRespondedTo = 0;
-        private bool respondToMessages = true;
-        private int numSentMessagesBeforeFail = -1;
-        private int numSentMessages = 0;
-        private bool failOnReceiveMessage = false;
-        private int numReceivedMessagesBeforeFail = 0;
-        private int numReceivedMessages = 0;
-        private bool failOnKeepAliveInfoSends = false;
-        private int numSentKeepAliveInfosBeforeFail = 0;
-        private int numSentKeppAliveInfos = 0;
-        private int nextCommandId = 0;
-        private CommandHandler commandHandler;
+		private string name;
+		private bool failOnSendMessage = false;
+		private int numMessagesToRespondTo = -1;
+		private int numMessagesRespondedTo = 0;
+		private bool respondToMessages = true;
+		private int numSentMessagesBeforeFail = -1;
+		private int numSentMessages = 0;
+		private bool failOnReceiveMessage = false;
+		private int numReceivedMessagesBeforeFail = 0;
+		private int numReceivedMessages = 0;
+		private bool failOnKeepAliveInfoSends = false;
+		private int numSentKeepAliveInfosBeforeFail = 0;
+		private int numSentKeppAliveInfos = 0;
+		private int nextCommandId = 0;
+		private Uri connectedUri;
+		private CommandHandler commandHandler;
         private CommandHandler outgoingCommandHandler;
-        private ExceptionHandler exceptionHandler;
-        private InterruptedHandler interruptedHandler;
-        private ResumedHandler resumedHandler;
-        private bool disposed = false;
-        private bool started = false;
-        private TaskRunner asyncResponseTask;
-        private Queue<Command> receiveQueue = new Queue<Command>();
-        private IResponseBuilder responseBuilder = new OpenWireResponseBuilder();
+		private ExceptionHandler exceptionHandler;
+		private InterruptedHandler interruptedHandler;
+		private ResumedHandler resumedHandler;
+		private bool disposed = false;
+		private bool started = false;
+		private TaskRunner asyncResponseTask;
+		private Queue<Command> receiveQueue = new Queue<Command>();
+		private IResponseBuilder responseBuilder = new OpenWireResponseBuilder();
 
-        #endregion   
-        
-        #region Async Response Task
-        
-        private class AsyncResponseTask : Task
-        {
-            private MockTransport parent;
-            
-            public AsyncResponseTask( MockTransport parent )
-            {
-                this.parent = parent;
-            }
-            
-            public bool Iterate()
-            {   
-                Command command = null;
-                
-                lock(this.parent.receiveQueue)
-                {
-                    if( this.parent.receiveQueue.Count == 0 )
-                    {
-                        return false;
-                    }
-                    
-                    // Grab everything that's currently in the Queue, 
-                    command = this.parent.receiveQueue.Dequeue();
-                }
-                
-                if( command.IsMessage ) {
-                    this.parent.NumReceivedMessages++;
-
-                    if( this.parent.FailOnReceiveMessage && 
-                        this.parent.NumReceivedMessages > this.parent.NumReceivedMessagesBeforeFail ) {
-                        
-                        Tracer.Debug("MockTransport Async Task: Performing configured receive failure." );
-                        this.parent.Exception(this.parent, new IOException( "Failed to Receive Message."));
-                    }
-                }                
-                             
-                // Send all the responses.
-                Tracer.Debug("MockTransport Async Task: Simulate receive of Command: " + command.ToString() );
-                this.parent.Command(this.parent, command);
-                
-                return parent.receiveQueue.Count != 0;
-            }
-        }
-        
-        #endregion        
+		#endregion
 
-        public MockTransport()
-        {
-            Tracer.Debug("Creating Async Response task");
-            asyncResponseTask = DefaultThreadPools.DefaultTaskRunnerFactory.CreateTaskRunner(new AsyncResponseTask(this),
-                                "ActiveMQ MockTransport Worker: " + this.GetHashCode().ToString());            
-        }
-        
-        ~MockTransport()
-        {
-            Dispose(false);
-        }
-        
-        public Response Request(Command command)
-        {
-            return this.Request(command, TimeSpan.FromMilliseconds(Timeout.Infinite));
-        }
+		#region Async Response Task
 
-        public Response Request(Command command, TimeSpan timeout)
-        {
-            Tracer.Debug("MockTransport sending Request Command: " + command.ToString() );
-            
-            if( command.IsMessage ) {
-                this.numSentMessages++;
-    
-                if( this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail ) {
-                    throw new IOException( "Failed to Send Message.");
-                }
-            }
-
-            // Notify external Client of command that we "sent"
-            if( this.OutgoingCommand != null )
-            {
-                this.OutgoingCommand(this, command);
-            }
-
-            command.CommandId = Interlocked.Increment(ref this.nextCommandId);
-            command.ResponseRequired = true;
-            
-            return this.responseBuilder.BuildResponse(command);
-        }
-        
-        public void Oneway(Command command)
-        {
-            Tracer.Debug("MockTransport sending oneway Command: " + command.ToString() );
+		private class AsyncResponseTask : Task
+		{
+			private MockTransport parent;
 
-            if( command.IsMessage ) {
-                this.numSentMessages++;
+			public AsyncResponseTask(MockTransport parent)
+			{
+				this.parent = parent;
+			}
+
+			public bool Iterate()
+			{
+				Command command = null;
+
+				lock(this.parent.receiveQueue)
+				{
+					if(this.parent.receiveQueue.Count == 0)
+					{
+						return false;
+					}
+
+					// Grab everything that's currently in the Queue, 
+					command = this.parent.receiveQueue.Dequeue();
+				}
+
+				if(command.IsMessage)
+				{
+					this.parent.NumReceivedMessages++;
+
+					if(this.parent.FailOnReceiveMessage &&
+						this.parent.NumReceivedMessages > this.parent.NumReceivedMessagesBeforeFail)
+					{
+
+						Tracer.Debug("MockTransport Async Task: Performing configured receive failure.");
+						this.parent.Exception(this.parent, new IOException("Failed to Receive Message."));
+					}
+				}
+
+				// Send all the responses.
+				Tracer.Debug("MockTransport Async Task: Simulate receive of Command: " + command.ToString());
+				this.parent.Command(this.parent, command);
 
-                if( this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail ) {
-                    Tracer.Debug("MockTransport Oneway send, failing as per configuration." );
-                    throw new IOException( "Failed to Send Message.");
-                }
-            }
-
-            if( command.IsKeepAliveInfo ) {
-                this.numSentKeppAliveInfos++;
-
-                if( this.failOnKeepAliveInfoSends && this.numSentKeppAliveInfos > this.numSentKeepAliveInfosBeforeFail ) {
-                    Tracer.Debug("MockTransport Oneway send, failing as per configuration." );
-                    throw new IOException( "Failed to Send Message.");
-                }
-            }
-            
-            // Process and send any new Commands back.
-            List<Command> results = new List<Command>();
-
-            // Let the Response Builder give us the Commands to send to the Client App.
-            if( command.IsMessage )
-            {
-                if( this.respondToMessages && this.NumMessagesToRespondTo < this.numMessagesRespondedTo )
-                {
-                    results = this.responseBuilder.BuildIncomingCommands(command);
-                    this.numMessagesRespondedTo++;
-                }
-            }
-            else
-            {
-                results = this.responseBuilder.BuildIncomingCommands(command);
-            }
-            
-            lock(this.receiveQueue)
-            {
-                foreach( Command result in results )
-                {
-                    this.receiveQueue.Enqueue(result);
-                }
-            }
-            
-            this.asyncResponseTask.Wakeup();
-            
-            // Send the Command to the Outgoing Command Snoop Hook.
-            if( this.OutgoingCommand != null ) {
-                Tracer.Debug("MockTransport Oneway, Notifying Outgoing linstener." );
-                this.OutgoingCommand(this, command);
-            }
-        }
-        
-        public FutureResponse AsyncRequest(Command command)
-        {
-            FutureResponse response = new FutureResponse();
-            
-            // Delegate to the Request method, it doesn't block.
-            response.Response = this.Request(command);
-            
-            return response;
-        }
-        
-        public void Start()
-        {
-            if(commandHandler == null)
-            {
-                throw new InvalidOperationException("command cannot be null when Start is called.");
-            }
-
-            if(exceptionHandler == null)
-            {
-                throw new InvalidOperationException("exception cannot be null when Start is called.");
-            }
+				return parent.receiveQueue.Count != 0;
+			}
+		}
 
-            this.started = true;
-        }
-                
-        public void Stop()
-        {
-            this.started = false;
-        }
-        
-        public void Dispose()
-        {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
+		#endregion
 
-        protected virtual void Dispose(bool disposing)
-        {
-            this.started = false;
-            this.disposed = true;
-        }
-        
-        /// <summary>
-        /// Injects a Command into the Transports inbound message queue, the Commands in the
-        /// inbound Queue are dispatched to the registered CommnadHandler instance for 
-        /// processing, this simulates receiving a message from an external source, e.g.
-        /// receiving a new message from the Broker.
-        /// </summary>
-        /// <param name="command">
-        /// A <see cref="Command"/>
-        /// </param>
-        public void InjectCommand(Command command)
-        {
-            lock(this.receiveQueue)
-            {
-                this.receiveQueue.Enqueue(command);
-            }
-            
-            this.asyncResponseTask.Wakeup();
-        }
+		public MockTransport(Uri uri)
+		{
+			this.connectedUri = uri;
+			Tracer.Debug("Creating Async Response task");
+			asyncResponseTask = DefaultThreadPools.DefaultTaskRunnerFactory.CreateTaskRunner(new AsyncResponseTask(this),
+								"ActiveMQ MockTransport Worker: " + this.GetHashCode().ToString());
+		}
 
-        public Object Narrow(Type type)
-        {
-            if( this.GetType().Equals(type) )
-            {
-                return this;
-            }
+		~MockTransport()
+		{
+			Dispose(false);
+		}
+
+		public Response Request(Command command)
+		{
+			return this.Request(command, TimeSpan.FromMilliseconds(Timeout.Infinite));
+		}
+
+		public Response Request(Command command, TimeSpan timeout)
+		{
+			Tracer.Debug("MockTransport sending Request Command: " + command.ToString());
+
+			if(command.IsMessage)
+			{
+				this.numSentMessages++;
+
+				if(this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail)
+				{
+					throw new IOException("Failed to Send Message.");
+				}
+			}
+
+			// Notify external Client of command that we "sent"
+			if(this.OutgoingCommand != null)
+			{
+				this.OutgoingCommand(this, command);
+			}
+
+			command.CommandId = Interlocked.Increment(ref this.nextCommandId);
+			command.ResponseRequired = true;
+
+			return this.responseBuilder.BuildResponse(command);
+		}
+
+		public void Oneway(Command command)
+		{
+			Tracer.Debug("MockTransport sending oneway Command: " + command.ToString());
+
+			if(command.IsMessage)
+			{
+				this.numSentMessages++;
+
+				if(this.failOnSendMessage && this.numSentMessages > this.numSentMessagesBeforeFail)
+				{
+					Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
+					throw new IOException("Failed to Send Message.");
+				}
+			}
+
+			if(command.IsKeepAliveInfo)
+			{
+				this.numSentKeppAliveInfos++;
+
+				if(this.failOnKeepAliveInfoSends && this.numSentKeppAliveInfos > this.numSentKeepAliveInfosBeforeFail)
+				{
+					Tracer.Debug("MockTransport Oneway send, failing as per configuration.");
+					throw new IOException("Failed to Send Message.");
+				}
+			}
+
+			// Process and send any new Commands back.
+			List<Command> results = new List<Command>();
+
+			// Let the Response Builder give us the Commands to send to the Client App.
+			if(command.IsMessage)
+			{
+				if(this.respondToMessages && this.NumMessagesToRespondTo < this.numMessagesRespondedTo)
+				{
+					results = this.responseBuilder.BuildIncomingCommands(command);
+					this.numMessagesRespondedTo++;
+				}
+			}
+			else
+			{
+				results = this.responseBuilder.BuildIncomingCommands(command);
+			}
+
+			lock(this.receiveQueue)
+			{
+				foreach(Command result in results)
+				{
+					this.receiveQueue.Enqueue(result);
+				}
+			}
+
+			this.asyncResponseTask.Wakeup();
+
+			// Send the Command to the Outgoing Command Snoop Hook.
+			if(this.OutgoingCommand != null)
+			{
+				Tracer.Debug("MockTransport Oneway, Notifying Outgoing linstener.");
+				this.OutgoingCommand(this, command);
+			}
+		}
+
+		public FutureResponse AsyncRequest(Command command)
+		{
+			FutureResponse response = new FutureResponse();
+
+			// Delegate to the Request method, it doesn't block.
+			response.Response = this.Request(command);
+
+			return response;
+		}
+
+		public void Start()
+		{
+			if(commandHandler == null)
+			{
+				throw new InvalidOperationException("command cannot be null when Start is called.");
+			}
+
+			if(exceptionHandler == null)
+			{
+				throw new InvalidOperationException("exception cannot be null when Start is called.");
+			}
+
+			this.started = true;
+		}
+
+		public void Stop()
+		{
+			this.started = false;
+		}
+
+		public void Dispose()
+		{
+			Dispose(true);
+			GC.SuppressFinalize(this);
+		}
+
+		protected virtual void Dispose(bool disposing)
+		{
+			this.started = false;
+			this.disposed = true;
+		}
+
+		/// <summary>
+		/// Injects a Command into the Transports inbound message queue, the Commands in the
+		/// inbound Queue are dispatched to the registered CommnadHandler instance for 
+		/// processing, this simulates receiving a message from an external source, e.g.
+		/// receiving a new message from the Broker.
+		/// </summary>
+		/// <param name="command">
+		/// A <see cref="Command"/>
+		/// </param>
+		public void InjectCommand(Command command)
+		{
+			lock(this.receiveQueue)
+			{
+				this.receiveQueue.Enqueue(command);
+			}
+
+			this.asyncResponseTask.Wakeup();
+		}
+
+		public Object Narrow(Type type)
+		{
+			if(this.GetType().Equals(type))
+			{
+				return this;
+			}
+
+			return null;
+		}
 
-            return null;
-        }
-        
 		#region Property Accessors
 
-        public string Name
-        {
-            get { return this.name; }
-            set { this.name = value; }
-        }
+		public string Name
+		{
+			get { return this.name; }
+			set { this.name = value; }
+		}
 
-        public CommandHandler Command
-        {
-            get { return commandHandler; }
-            set { this.commandHandler = value; }
-        }
+		public CommandHandler Command
+		{
+			get { return commandHandler; }
+			set { this.commandHandler = value; }
+		}
 
         public CommandHandler OutgoingCommand
         {
@@ -297,52 +308,52 @@ namespace Apache.NMS.ActiveMQ.Transport.
             set { this.outgoingCommandHandler = value; }
         }
         
-        public ExceptionHandler Exception
-        {
-            get { return exceptionHandler; }
-            set { this.exceptionHandler = value; }
-        }
+		public ExceptionHandler Exception
+		{
+			get { return exceptionHandler; }
+			set { this.exceptionHandler = value; }
+		}
+
+		public InterruptedHandler Interrupted
+		{
+			get { return interruptedHandler; }
+			set { this.interruptedHandler = value; }
+		}
+
+		public ResumedHandler Resumed
+		{
+			get { return resumedHandler; }
+			set { this.resumedHandler = value; }
+		}
+
+		public bool IsDisposed
+		{
+			get { return this.disposed; }
+		}
+
+		public bool IsStarted
+		{
+			get { return this.started; }
+		}
 
-        public InterruptedHandler Interrupted
-        {
-            get { return interruptedHandler; }
-            set { this.interruptedHandler = value; }
-        }
-        
-        public ResumedHandler Resumed
-        {
-            get { return resumedHandler; }
-            set { this.resumedHandler = value; }
-        }
-        
-        public bool IsDisposed
-        {
-            get{ return this.disposed; }
-        }
-        
-        public bool IsStarted
-        {
-            get{ return this.started; }
-        }
-                
 		public bool FailOnSendMessage
 		{
-			get{ return failOnSendMessage; }
-			set{ this.failOnSendMessage = value; }			
+			get { return failOnSendMessage; }
+			set { this.failOnSendMessage = value; }
 		}
-		
+
 		public int NumSentMessagesBeforeFail
 		{
-			get { return numSentMessagesBeforeFail ; }
+			get { return numSentMessagesBeforeFail; }
 			set { numSentMessagesBeforeFail = value; }
 		}
-		
+
 		public int NumSentMessages
 		{
 			get { return numSentMessages; }
 			set { numSentMessages = value; }
 		}
-		
+
 		public bool FailOnReceiveMessage
 		{
 			get { return failOnReceiveMessage; }
@@ -361,72 +372,72 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			set { numReceivedMessages = value; }
 		}
 
-        public bool FailOnKeepAliveInfoSends
-        {
-            get { return failOnKeepAliveInfoSends; }
-            set { failOnKeepAliveInfoSends = value; }
-        }
+		public bool FailOnKeepAliveInfoSends
+		{
+			get { return failOnKeepAliveInfoSends; }
+			set { failOnKeepAliveInfoSends = value; }
+		}
 
-        public int NumSentKeepAliveInfosBeforeFail
-        {
-            get { return numSentKeepAliveInfosBeforeFail; }
-            set { numSentKeepAliveInfosBeforeFail = value; }
-        }
+		public int NumSentKeepAliveInfosBeforeFail
+		{
+			get { return numSentKeepAliveInfosBeforeFail; }
+			set { numSentKeepAliveInfosBeforeFail = value; }
+		}
 
-        public int NumSentKeppAliveInfos
-        {
-            get { return numSentKeppAliveInfos; }
-            set { numSentKeppAliveInfos = value; }
-        }
+		public int NumSentKeppAliveInfos
+		{
+			get { return numSentKeppAliveInfos; }
+			set { numSentKeppAliveInfos = value; }
+		}
 
-        public int NumMessagesToRespondTo
-        {
-            get { return numMessagesToRespondTo; }
-            set { numMessagesToRespondTo = value; }
-        }
+		public int NumMessagesToRespondTo
+		{
+			get { return numMessagesToRespondTo; }
+			set { numMessagesToRespondTo = value; }
+		}
 
-        public int NumMessagesRespondedTo
-        {
-            get { return numMessagesRespondedTo; }
-            set { numMessagesRespondedTo = value; }
-        }
+		public int NumMessagesRespondedTo
+		{
+			get { return numMessagesRespondedTo; }
+			set { numMessagesRespondedTo = value; }
+		}
 
-        public bool RespondToMessages
-        {
-            get { return respondToMessages; }
-            set { respondToMessages = value; }
-        }
+		public bool RespondToMessages
+		{
+			get { return respondToMessages; }
+			set { respondToMessages = value; }
+		}
 
-        public bool IsFaultTolerant
-        {
-            get{ return false; }
-        }
+		public bool IsFaultTolerant
+		{
+			get { return false; }
+		}
 
-        public bool IsConnected
-        {
-            get{ return true; }
-        }
+		public bool IsConnected
+		{
+			get { return true; }
+		}
 
-        public Uri RemoteAddress
-        {
-            get{ return new Uri("mock://mock"); }
-        }
-        
-	    public bool IsReconnectSupported
+		public Uri RemoteAddress
+		{
+			get { return connectedUri; }
+		}
+
+		public bool IsReconnectSupported
 		{
-			get{ return false; }
+			get { return false; }
 		}
-	    
-	    public bool IsUpdateURIsSupported
+
+		public bool IsUpdateURIsSupported
 		{
-			get{ return false; }
+			get { return false; }
 		}
-		
+
 		public void UpdateURIs(bool rebalance, Uri[] updatedURIs)
 		{
 			throw new IOException();
 		}
-		
-        #endregion
+
+		#endregion
 	}
 }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Mock/MockTransportFactory.cs Fri Aug 20 22:27:02 2010
@@ -123,7 +123,7 @@ namespace Apache.NMS.ActiveMQ.Transport.
 			}
 
 			// Create the Mock Transport
-			MockTransport transport = new MockTransport();
+			MockTransport transport = new MockTransport(location);
 
 			transport.FailOnReceiveMessage = this.FailOnReceiveMessage;
 			transport.NumReceivedMessagesBeforeFail = this.NumReceivedMessagesBeforeFail;

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/NMSConnectionFactoryTest.cs Fri Aug 20 22:27:02 2010
@@ -40,9 +40,9 @@ namespace Apache.NMS.ActiveMQ.Test
 		[TestCase("activemq:failover:tcp://${activemqhost}:61616")]
 		[TestCase("activemq:failover:(tcp://${activemqhost}:61616)")]
 		[TestCase("activemq:failover:(tcp://${activemqhost}:61616,tcp://${activemqhost}:61616)")]
-		[TestCase("activemq:failover://(tcp://${activemqhost}:61616)?initialReconnectDelay=100")]
+		[TestCase("activemq:failover://(tcp://${activemqhost}:61616)?transport.initialReconnectDelay=100")]
 		[TestCase("activemq:failover:(tcp://${activemqhost}:61616)?connection.asyncSend=true")]
-		[TestCase("activemq:failover:(tcp://${activemqhost}:61616)?timeout=100&connection.asyncSend=true")]
+		[TestCase("activemq:failover:(tcp://${activemqhost}:61616)?transport.timeout=100&connection.asyncSend=true")]
 
 #if false
 		[TestCase("activemq:discovery:multicast://default")]
@@ -94,7 +94,7 @@ namespace Apache.NMS.ActiveMQ.Test
             {
                 Assert.IsNotNull(connection);
 
-                MockTransport transport = (MockTransport) connection.ITransport.Narrow(typeof(MockTransport));
+				MockTransport transport = (MockTransport) connection.ITransport.Narrow(typeof(MockTransport));
 
                 transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand);
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Mock/MockTransportTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Mock/MockTransportTest.cs?rev=987655&r1=987654&r2=987655&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Mock/MockTransportTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/Transport/Mock/MockTransportTest.cs Fri Aug 20 22:27:02 2010
@@ -25,196 +25,206 @@ using NUnit.Framework;
 
 namespace Apache.NMS.ActiveMQ.Test
 {
-    [TestFixture]
-    public class MockTransportTest
-    {
-        private List<Command> sent;
-        private List<Command> received;
-        private List<Exception> exceptions;
-
-        private MockTransport transport;
-
-        public void OnException(ITransport transport, Exception exception)
-        {
-            Tracer.DebugFormat("MockTransportTest::onException - " + exception );
-            exceptions.Add( exception );
-        }
-
-        public void OnCommand(ITransport transport, Command command)
-        {
-            Tracer.DebugFormat("MockTransportTest::OnCommand - " + command );
-            received.Add( command );
-        }
-
-        public void OnOutgoingCommand(ITransport transport, Command command)
-        {
-            Tracer.DebugFormat("MockTransportTest::OnOutgoingCommand - " + command );
-            sent.Add( command );
-        }
-
-        [SetUp]
-        public void Init()
-        {
-            this.transport = new MockTransport();
-
-            sent = new List<Command>();
-            received = new List<Command>();
-            exceptions = new List<Exception>();
-
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-            transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand);
-        }
-
-        [Test]
-        public void CreateMockTransportTest()
-        {
-            MockTransport transport = new MockTransport();
-
-            Assert.IsNotNull(transport);
-            Assert.IsFalse(transport.IsStarted);
-            Assert.IsFalse(transport.IsDisposed);
-        }
-
-        [Test]
-        public void StartItializedTransportTest()
-        {
-            MockTransport transport = new MockTransport();
-
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            transport.Start();
-        }
-
-        [Test]
-        [ExpectedException( "System.InvalidOperationException" )]
-        public void StartUnitializedTransportTest()
-        {
-            MockTransport transport = new MockTransport();
-            transport.Start();
-        }
-
-        [Test]
-        public void OneWaySendMessageTest()
-        {
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            message.Text = "Hellow World";
-            transport.Oneway( message );
-            Assert.IsTrue(transport.NumSentMessages == 1);
-            Assert.IsTrue(sent.Count == 1);
-            Assert.AreEqual(message.Text, (sent[0] as ActiveMQTextMessage).Text);
-        }
-
-        [Test]
-        public void RequestMessageTest()
-        {
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            message.Text = "Hellow World";
-            transport.Request( message );
-            Assert.IsTrue(transport.NumSentMessages == 1);
-            Assert.IsTrue(sent.Count == 1);
-            Assert.AreEqual(message.Text, (sent[0] as ActiveMQTextMessage).Text);
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void OneWayFailOnSendMessageTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            transport.Oneway( message );
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void RequestFailOnSendMessageTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            Assert.IsNotNull( transport.Request( message ) );
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void AsyncRequestFailOnSendMessageTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            Assert.IsNotNull( transport.AsyncRequest( message ) );
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void OnewayFailOnSendTwoMessagesTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.NumSentMessagesBeforeFail = 2;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            transport.Oneway( message );
-            transport.Oneway( message );
-            transport.Oneway( message );
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void RequestFailOnSendTwoMessagesTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.NumSentMessagesBeforeFail = 2;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            transport.Request( message );
-            transport.Request( message );
-            transport.Request( message );
-        }
-
-        [Test]
-        [ExpectedException( "Apache.NMS.ActiveMQ.IOException" )]
-        public void AsyncRequestFailOnSendTwoMessagesTest()
-        {
-            transport.FailOnSendMessage = true;
-            transport.NumSentMessagesBeforeFail = 2;
-            transport.Start();
-            ActiveMQTextMessage message = new ActiveMQTextMessage();
-            transport.AsyncRequest( message );
-            transport.AsyncRequest( message );
-            transport.AsyncRequest( message );
-        }
-
-        [Test]
-        public void InjectCommandTest()
-        {
-            ActiveMQMessage message = new ActiveMQMessage();
-
-            transport.Start();
-            transport.InjectCommand(message);
-
-            Thread.Sleep( 1000 );
-
-            Assert.IsTrue(this.received.Count > 0 );
-            Assert.IsTrue(transport.NumReceivedMessages == 1);
-        }
-
-        [Test]
-        public void FailOnReceiveMessageTest()
-        {
-            ActiveMQMessage message = new ActiveMQMessage();
-
-            transport.FailOnReceiveMessage = true;
-            transport.Start();
-            transport.InjectCommand(message);
-
-            Thread.Sleep( 1000 );
-
-            Assert.IsTrue(this.exceptions.Count > 0 );
-            Assert.IsTrue(transport.NumReceivedMessages == 1);
-        }
-    }
+	[TestFixture]
+	public class BasicMockTransportTest
+	{
+		private Uri mockUri = new Uri("mock://mock");
+
+		[Test]
+		public void CreateMockTransportTest()
+		{
+			MockTransport transport = new MockTransport(mockUri);
+
+			Assert.IsNotNull(transport);
+			Assert.IsFalse(transport.IsStarted);
+			Assert.IsFalse(transport.IsDisposed);
+		}
+
+		[Test]
+		public void StartInitializedTransportTest()
+		{
+			MockTransport transport = new MockTransport(mockUri);
+
+			transport.Command = new CommandHandler(OnCommand);
+			transport.Exception = new ExceptionHandler(OnException);
+
+			transport.Start();
+		}
+
+		[Test]
+		[ExpectedException("System.InvalidOperationException")]
+		public void StartUnitializedTransportTest()
+		{
+			MockTransport transport = new MockTransport(mockUri);
+			transport.Start();
+		}
+
+		public void OnException(ITransport transport, Exception exception)
+		{
+			Tracer.DebugFormat("MockTransportTest::onException - " + exception);
+		}
+
+		public void OnCommand(ITransport transport, Command command)
+		{
+			Tracer.DebugFormat("MockTransportTest::OnCommand - " + command);
+		}
+	}
+
+	[TestFixture]
+	public class MockTransportTest
+	{
+		private Uri mockUri = new Uri("mock://mock");
+		private List<Command> sent;
+		private List<Command> received;
+		private List<Exception> exceptions;
+
+		private MockTransport transport;
+
+		public void OnException(ITransport transport, Exception exception)
+		{
+			Tracer.DebugFormat("MockTransportTest::onException - " + exception);
+			exceptions.Add(exception);
+		}
+
+		public void OnCommand(ITransport transport, Command command)
+		{
+			Tracer.DebugFormat("MockTransportTest::OnCommand - " + command);
+			received.Add(command);
+		}
+
+		public void OnOutgoingCommand(ITransport transport, Command command)
+		{
+			Tracer.DebugFormat("MockTransportTest::OnOutgoingCommand - " + command);
+			sent.Add(command);
+		}
+
+		[SetUp]
+		public void Init()
+		{
+			transport = new MockTransport(mockUri);
+			sent = new List<Command>();
+			received = new List<Command>();
+			exceptions = new List<Exception>();
+
+			transport.Command = new CommandHandler(OnCommand);
+			transport.Exception = new ExceptionHandler(OnException);
+			transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand);
+		}
+
+		[Test]
+		public void OneWaySendMessageTest()
+		{
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			message.Text = "Hello, World";
+			transport.Oneway(message);
+			Assert.IsTrue(transport.NumSentMessages == 1);
+			Assert.IsTrue(sent.Count == 1);
+			Assert.AreEqual(message.Text, (sent[0] as ActiveMQTextMessage).Text);
+		}
+
+		[Test]
+		public void RequestMessageTest()
+		{
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			message.Text = "Hello, World";
+			transport.Request(message);
+			Assert.IsTrue(transport.NumSentMessages == 1);
+			Assert.IsTrue(sent.Count == 1);
+			Assert.AreEqual(message.Text, (sent[0] as ActiveMQTextMessage).Text);
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void OneWayFailOnSendMessageTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			transport.Oneway(message);
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void RequestFailOnSendMessageTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			Assert.IsNotNull(transport.Request(message));
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void AsyncRequestFailOnSendMessageTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			Assert.IsNotNull(transport.AsyncRequest(message));
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void OnewayFailOnSendTwoMessagesTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.NumSentMessagesBeforeFail = 2;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			transport.Oneway(message);
+			transport.Oneway(message);
+			transport.Oneway(message);
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void RequestFailOnSendTwoMessagesTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.NumSentMessagesBeforeFail = 2;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			transport.Request(message);
+			transport.Request(message);
+			transport.Request(message);
+		}
+
+		[Test, ExpectedException(typeof(IOException))]
+		public void AsyncRequestFailOnSendTwoMessagesTest()
+		{
+			transport.FailOnSendMessage = true;
+			transport.NumSentMessagesBeforeFail = 2;
+			transport.Start();
+			ActiveMQTextMessage message = new ActiveMQTextMessage();
+			transport.AsyncRequest(message);
+			transport.AsyncRequest(message);
+			transport.AsyncRequest(message);
+		}
+
+		[Test]
+		public void InjectCommandTest()
+		{
+			ActiveMQMessage message = new ActiveMQMessage();
+
+			transport.Start();
+			transport.InjectCommand(message);
+
+			Thread.Sleep(1000);
+
+			Assert.IsTrue(this.received.Count > 0);
+			Assert.IsTrue(transport.NumReceivedMessages == 1);
+		}
+
+		[Test]
+		public void FailOnReceiveMessageTest()
+		{
+			ActiveMQMessage message = new ActiveMQMessage();
+
+			transport.FailOnReceiveMessage = true;
+			transport.Start();
+			transport.InjectCommand(message);
+
+			Thread.Sleep(1000);
+
+			Assert.IsTrue(this.exceptions.Count > 0);
+			Assert.IsTrue(transport.NumReceivedMessages == 1);
+		}
+	}
 }

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=987655&r1=987654&r2=987655&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 Fri Aug 20 22:27:02 2010
@@ -29,572 +29,557 @@ namespace Apache.NMS.ActiveMQ.Test
 	[TestFixture]
 	public class FailoverTransportTest
 	{
-        private List<Command> received;
-        private List<Exception> exceptions;
+		private List<Command> sent;
+		private List<Command> received;
+		private List<Exception> exceptions;
+
+		int sessionIdx = 1;
+		int consumerIdx = 1;
+		int producerIdx = 1;
 
-        int sessionIdx = 1;
-        int consumerIdx = 1;
-        int producerIdx = 1;
-        
-        public void OnException(ITransport transport, Exception exception)
-        {
-            Tracer.Debug("Test: Received Exception from Transport: " + exception );
-            exceptions.Add( exception );
-        }
-        
-        public void OnCommand(ITransport transport, Command command)
-        {
-            Tracer.Debug("Test: Received Command from Transport: " + command );
-            received.Add( command );
-        }
-
-        [SetUp]
-        public void init()
-        {
-            this.received = new List<Command>();
-            this.exceptions = new List<Exception>();
-            this.sessionIdx = 1;
-            this.consumerIdx = 1;
-            this.producerIdx = 1;
-        }
-
-        [Test]
-        public void FailoverTransportCreateTest()
-        {
-            Uri uri = new Uri("failover:(mock://localhost:61616)?randomize=false");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport(uri);
-            Assert.IsNotNull(transport);
-
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-          
-            transport.Start();
-
-            Thread.Sleep(1000);
-            Assert.IsTrue(failover.IsConnected);
-            
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportWithBackupsTest()
-        {
-            Uri uri = new Uri("failover:(mock://localhost:61616,mock://localhost:61618)?randomize=false&backup=true");
-        
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-            Assert.IsTrue(failover.Backup);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-            Assert.IsTrue(failover.IsConnected);
-            
-            transport.Stop();      
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportCreateFailOnCreateTest()
-        {
-            Uri uri = new Uri("failover:(mock://localhost:61616?transport.failOnCreate=true)?" +
-                              "useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsTrue(failover.MaxReconnectAttempts == 3);
-
-            transport.Start();
-
-            Thread.Sleep(2000);
-            Assert.IsNotEmpty(this.exceptions);
-            Assert.IsFalse(failover.IsConnected);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportFailOnSendMessageTest()
-        {
-            Uri uri = new Uri("failover:(mock://localhost:61616?transport.failOnCreate=true)?" +
-                              "useExponentialBackOff=false&maxReconnectAttempts=3&initialReconnectDelay=100");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsTrue(failover.MaxReconnectAttempts == 3);
-
-            transport.Start();
-
-            try{
-                ActiveMQMessage message = new ActiveMQMessage();
-                transport.Oneway(message);
-
-                Assert.Fail("Oneway call should block and then throw.");
-            }
-            catch(Exception)
-            {
-            }
-
-            Assert.IsNotEmpty(this.exceptions);
-            Assert.IsFalse(failover.IsConnected);
-            
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportFailingBackupsTest()
-        {
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616," +
-                          "mock://localhost:61618?transport.failOnCreate=true)?randomize=false&backup=true");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsTrue(failover.Backup = true);
-
-            transport.Start();
-
-            Thread.Sleep(2000);
-            
-            Assert.IsTrue(failover.IsConnected);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportSendOnewayMessageTest()
-        {
-            int numMessages = 1000;
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616)?randomize=false");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(failover.IsConnected);
-
-            MockTransport mock = null;
-            while(mock == null ) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
-			}
-            mock.OutgoingCommand = new CommandHandler(OnCommand);
-
-            ActiveMQMessage message = new ActiveMQMessage();
-            for(int i = 0; i < numMessages; ++i) {
-                transport.Oneway(message);
-            }
-
-            Thread.Sleep(2000);
-
-            Assert.IsTrue(this.received.Count == numMessages);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportSendRequestTest()
-        {
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616)?randomize=false");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(failover.IsConnected);
-
-            MockTransport mock = null;
-            while(mock == null ) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
-			}
-            mock.OutgoingCommand = new CommandHandler(OnCommand);
-
-            ActiveMQMessage message = new ActiveMQMessage();
-            
-            transport.Request(message);
-            transport.Request(message);
-            transport.Request(message);
-            transport.Request(message);
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(this.received.Count == 4);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportSendOnewayFailTest()
-        {
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616?failOnSendMessage=true," +
-                          "mock://localhost:61618)?randomize=false");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(failover.IsConnected);
-
-            MockTransport mock = null;
-            while(mock == null ) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
-			}
-            mock.OutgoingCommand = new CommandHandler(OnCommand);
-
-            ActiveMQMessage message = new ActiveMQMessage();
-            
-            transport.Oneway(message);
-            transport.Oneway(message);
-            transport.Oneway(message);
-            transport.Oneway(message);
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(this.received.Count == 4);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void FailoverTransportSendOnewayTimeoutTest()
-        {
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616?failOnCreate=true)?timeout=1000");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.AreEqual(1000, failover.Timeout);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            ActiveMQMessage message = new ActiveMQMessage();
-            
-            try
-            {
-                transport.Oneway(message);
-                Assert.Fail("Should have thrown an IOException after timeout.");
-            }
-            catch
-            {
-            }
-
-            transport.Stop();
-            transport.Dispose();
-        }
-        
-        [Test]
-        public void FailoverTransportSendRequestFailTest()
-        {
-            Uri uri = new Uri(
-                "failover:(mock://localhost:61616?failOnSendMessage=true," +
-                          "mock://localhost:61618)?randomize=false");
-
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(failover.IsConnected);
-
-            MockTransport mock = null;
-            while(mock == null ) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
-			}
-            mock.OutgoingCommand = new CommandHandler(OnCommand);
-
-            ActiveMQMessage message = new ActiveMQMessage();
-            
-            transport.Request(message);
-            transport.Request(message);
-            transport.Request(message);
-            transport.Request(message);
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(this.received.Count == 4);
-
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        [Test]
-        public void OpenWireCommandsTest() {
-        
-            Uri uri = new Uri("failover:(mock://localhost:61616)?randomize=false");
-        
-            FailoverTransportFactory factory = new FailoverTransportFactory();
-
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
-
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-        
-            transport.Start();
-
-            Thread.Sleep(1000);
-
-            Assert.IsTrue(failover.IsConnected);
-        
-            ConnectionInfo connection = createConnection();
-            transport.Request( connection );
-            SessionInfo session1 = createSession( connection );
-            transport.Request( session1 );
-            SessionInfo session2 = createSession( connection );
-            transport.Request( session2 );
-            ConsumerInfo consumer1 = createConsumer( session1 );
-            transport.Request( consumer1 );
-            ConsumerInfo consumer2 = createConsumer( session1 );
-            transport.Request( consumer2 );
-            ConsumerInfo consumer3 = createConsumer( session2 );
-            transport.Request( consumer3 );
-        
-            ProducerInfo producer1 = createProducer( session2 );
-            transport.Request( producer1 );
-        
-            // Remove the Producers
-            disposeOf( producer1, transport );
-        
-            // Remove the Consumers
-            disposeOf( consumer1, transport );
-            disposeOf( consumer2, transport );
-            disposeOf( consumer3, transport );
-        
-            // Remove the Session instances.
-            disposeOf( session1, transport );
-            disposeOf( session2, transport );
-        
-            // Indicate that we are done.
-            ShutdownInfo shutdown = new ShutdownInfo();
-            transport.Oneway(shutdown);
-        
-            transport.Stop();
-            transport.Dispose();
-        }
-
-        protected ConnectionInfo createConnection() {
-        
-            ConnectionId id = new ConnectionId();
-            id.Value = Guid.NewGuid().ToString();
-        
-            ConnectionInfo info = new ConnectionInfo();
-            info.ClientId = Guid.NewGuid().ToString();
-            info.ConnectionId = id;
-        
-            return info;
-        }
-
-        SessionInfo createSession( ConnectionInfo parent ) {
-        
-            SessionId id = new SessionId();
-            id.ConnectionId = parent.ConnectionId.Value;
-            id.Value = sessionIdx++;
-        
-            SessionInfo info = new SessionInfo();
-            info.SessionId = id;
-        
-            return info;
-        }
-        
-        ConsumerInfo createConsumer( SessionInfo parent ) {
-                
-            ConsumerId id = new ConsumerId();
-            id.ConnectionId = parent.SessionId.ConnectionId;
-            id.SessionId = parent.SessionId.Value;
-            id.Value = consumerIdx++;
-        
-            ConsumerInfo info = new ConsumerInfo();
-            info.ConsumerId = id;
-        
-            return info;
-        }
-        
-        ProducerInfo createProducer( SessionInfo parent ) {
-                
-            ProducerId id = new ProducerId();
-            id.ConnectionId = parent.SessionId.ConnectionId;
-            id.SessionId = parent.SessionId.Value;
-            id.Value = producerIdx++;
-        
-            ProducerInfo info = new ProducerInfo();
-            info.ProducerId = id;
-        
-            return info;
-        }
-        
-        void disposeOf( SessionInfo session, ITransport transport ) {
-        
-            RemoveInfo command = new RemoveInfo();
-            command.ObjectId = session.SessionId;
-            transport.Oneway( command );
-        }
-        
-        void disposeOf( ConsumerInfo consumer, ITransport transport ) {
-        
-            RemoveInfo command = new RemoveInfo();
-            command.ObjectId = consumer.ConsumerId;
-            transport.Oneway( command );
-        }
-        
-        void disposeOf( ProducerInfo producer, ITransport transport ) {
-        
-            RemoveInfo command = new RemoveInfo();
-            command.ObjectId = producer.ProducerId;
-            transport.Oneway( command );
-        }
+		private void OnException(ITransport transport, Exception exception)
+		{
+			Tracer.Debug("Test: Received Exception from Transport: " + exception);
+			exceptions.Add(exception);
+		}
+
+		private void OnCommand(ITransport transport, Command command)
+		{
+			Tracer.DebugFormat("Test: Received Command from Transport: {0}", command);
+			received.Add(command);
+		}
+
+		private void OnOutgoingCommand(ITransport transport, Command command)
+		{
+			Tracer.DebugFormat("FailoverTransportTest::OnOutgoingCommand - {0}", command);
+			sent.Add(command);
+		}
+
+		private void OnResumed(ITransport sender)
+		{
+			Tracer.DebugFormat("FailoverTransportTest::OnResumed - {0}", sender.RemoteAddress);
+			// Ensure the current mock transport has the correct outgoing command handler
+			MockTransport mock = sender as MockTransport;
+			Assert.IsNotNull(mock);
+			mock.OutgoingCommand = OnOutgoingCommand;
+		}
+
+		private void VerifyCommandHandlerSetting(ITransport transport, MockTransport mock)
+		{
+			// Walk the stack of wrapper transports.
+			ITransport failoverTransportTarget = mock.Command.Target as ITransport;
+			Assert.IsNotNull(failoverTransportTarget);
+			ITransport mutexTransportTarget = failoverTransportTarget.Command.Target as ITransport;
+			Assert.IsNotNull(mutexTransportTarget);
+			ITransport responseCorrelatorTransportTarget = mutexTransportTarget.Command.Target as ITransport;
+			Assert.IsNotNull(responseCorrelatorTransportTarget);
+			Assert.AreEqual(transport.Command.Target, responseCorrelatorTransportTarget.Command.Target);
+		}
+
+		[SetUp]
+		public void init()
+		{
+			sent = new List<Command>();
+			received = new List<Command>();
+			exceptions = new List<Exception>();
+			sessionIdx = 1;
+			consumerIdx = 1;
+			producerIdx = 1;
+		}
 
 		[Test]
-		public void TestFailoverTransportConnectionControlHandling()
+		public void FailoverTransportCreateTest()
 		{
-            Uri uri = new Uri("failover:(mock://localhost:61613)?randomize=false");
+			Uri uri = new Uri("failover:(mock://localhost:61616)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
 
-			string reconnectTo = "mock://localhost:61616?transport.name=Reconnected";
-			string connectedBrokers = "mock://localhost:61616?transport.name=Broker1," +
-                                      "mock://localhost:61617?transport.name=Broker2";
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
 
-			ConnectionControl cmd = new ConnectionControl();
-			cmd.FaultTolerant = true;
-			cmd.ReconnectTo = reconnectTo;
-			cmd.ConnectedBrokers = connectedBrokers;
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
 
-            FailoverTransportFactory factory = new FailoverTransportFactory();
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
 
-            ITransport transport = factory.CreateTransport( uri );
-            Assert.IsNotNull( transport );
-            transport.Command = new CommandHandler(OnCommand);
-            transport.Exception = new ExceptionHandler(OnException);
+				transport.Start();
 
-            FailoverTransport failover = (FailoverTransport) transport.Narrow(typeof(FailoverTransport));
-            Assert.IsNotNull(failover);
-            Assert.IsFalse(failover.Randomize);
-        
-            transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+			}
+		}
+
+		[Test]
+		public void FailoverTransportWithBackupsTest()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61616,mock://localhost:61618)?transport.randomize=false&transport.backup=true");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
 
-            MockTransport mock = null;
-            while(mock == null ) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+				Assert.IsTrue(failover.Backup);
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
 			}
+		}
 
-            mock.InjectCommand(cmd);
+		[Test]
+		public void FailoverTransportCreateFailOnCreateTest()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61616?transport.failOnCreate=true)?" +
+							  "transport.useExponentialBackOff=false&transport.maxReconnectAttempts=3&transport.initialReconnectDelay=100");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.UseExponentialBackOff);
+				Assert.AreEqual(3, failover.MaxReconnectAttempts);
+				Assert.AreEqual(100, failover.InitialReconnectDelay);
+
+				transport.Start();
+				Thread.Sleep(2000);
+				Assert.IsNotEmpty(this.exceptions);
+				Assert.IsFalse(failover.IsConnected);
+			}
+		}
 
-            failover.Remove(true, new Uri[] {new Uri("mock://localhost:61613")});
+		[Test]
+		public void FailoverTransportFailOnSendMessageTest()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61616?transport.failOnCreate=true)?" +
+							  "transport.useExponentialBackOff=false&transport.maxReconnectAttempts=3&transport.initialReconnectDelay=100");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.UseExponentialBackOff);
+				Assert.AreEqual(3, failover.MaxReconnectAttempts);
+				Assert.AreEqual(100, failover.InitialReconnectDelay);
 
-            Thread.Sleep(1000);
+				transport.Start();
 
-            mock = null;
+				ActiveMQMessage message = new ActiveMQMessage();
+				Assert.Throws<IOException>(delegate() { transport.Oneway(message); }, "Oneway call should block and then throw.");
 
-            while(mock == null) {
-                mock = (MockTransport) transport.Narrow(typeof(MockTransport));
-				Thread.Sleep(50);
-            }
+				Assert.IsNotEmpty(this.exceptions);
+				Assert.IsFalse(failover.IsConnected);
+			}
+		}
 
-            Assert.AreEqual("Reconnected", mock.Name);
+		[Test]
+		public void FailoverTransportFailingBackupsTest()
+		{
+			Uri uri = new Uri(
+				"failover:(mock://localhost:61616," +
+						  "mock://localhost:61618?transport.failOnCreate=true)?transport.randomize=false&transport.backup=true");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+				Assert.IsTrue(failover.Backup);
+
+				transport.Start();
+				Thread.Sleep(2000);
+				Assert.IsTrue(failover.IsConnected);
+			}
+		}
 
+		[Test]
+		public void FailoverTransportSendOnewayMessageTest()
+		{
+			int numMessages = 1000;
+			Uri uri = new Uri("failover:(mock://localhost:61616)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				failover.Resumed = OnResumed;
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				// Ensure the current mock transport has the correct outgoing command handler
+				MockTransport mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				Assert.AreEqual(61616, mock.RemoteAddress.Port);
+
+				VerifyCommandHandlerSetting(transport, mock);
+				mock.OutgoingCommand = OnOutgoingCommand;
+
+				ActiveMQMessage message = new ActiveMQMessage();
+				for(int i = 0; i < numMessages; ++i)
+				{
+					transport.Oneway(message);
+				}
+
+				Thread.Sleep(1000);
+				Assert.AreEqual(numMessages, this.sent.Count);
+			}
+		}
+
+		[Test]
+		public void FailoverTransportSendRequestTest()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61616)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				failover.Resumed = OnResumed;
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				// Ensure the current mock transport has the correct outgoing command handler
+				MockTransport mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				Assert.AreEqual(61616, mock.RemoteAddress.Port);
+				VerifyCommandHandlerSetting(transport, mock);
+				mock.OutgoingCommand = OnOutgoingCommand;
+
+				ActiveMQMessage message = new ActiveMQMessage();
+				int numMessages = 4;
+
+				for(int i = 0; i < numMessages; ++i)
+				{
+					transport.Request(message);
+				}
+
+				Thread.Sleep(1000);
+				Assert.AreEqual(numMessages, this.sent.Count);
+			}
+		}
+
+		[Test]
+		public void FailoverTransportSendOnewayFailTest()
+		{
+			Uri uri = new Uri(
+				"failover:(mock://localhost:61616?transport.failOnSendMessage=true," +
+						  "mock://localhost:61618)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				failover.Resumed = OnResumed;
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				// Ensure the current mock transport has the correct outgoing command handler
+				MockTransport mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				Assert.AreEqual(61616, mock.RemoteAddress.Port);
+				VerifyCommandHandlerSetting(transport, mock);
+				mock.OutgoingCommand = OnOutgoingCommand;
+
+				ActiveMQMessage message = new ActiveMQMessage();
+				int numMessages = 4;
+
+				for(int i = 0; i < numMessages; ++i)
+				{
+					transport.Oneway(message);
+					// Make sure we switched to second failover
+					mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+					Assert.IsNotNull(mock);
+					Assert.AreEqual(61618, mock.RemoteAddress.Port);
+				}
+
+				Thread.Sleep(1000);
+				Assert.AreEqual(numMessages, this.sent.Count);
+			}
+		}
+
+		[Test]
+		public void FailoverTransportSendOnewayTimeoutTest()
+		{
+			Uri uri = new Uri(
+				"failover:(mock://localhost:61616?transport.failOnCreate=true)?transport.timeout=1000");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.AreEqual(1000, failover.Timeout);
+
+				transport.Start();
+				Thread.Sleep(1000);
+
+				ActiveMQMessage message = new ActiveMQMessage();
+				Assert.Throws<IOException>(delegate() { transport.Oneway(message); });
+			}
+		}
+
+		[Test]
+		public void FailoverTransportSendRequestFailTest()
+		{
+			Uri uri = new Uri(
+				"failover:(mock://localhost:61616?transport.failOnSendMessage=true," +
+						  "mock://localhost:61618)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				failover.Resumed = OnResumed;
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				// Ensure the current mock transport has the correct outgoing command handler
+				MockTransport mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				VerifyCommandHandlerSetting(transport, mock);
+				mock.OutgoingCommand = OnOutgoingCommand;
+
+				ActiveMQMessage message = new ActiveMQMessage();
+				int numMessages = 4;
+
+				for(int i = 0; i < numMessages; ++i)
+				{
+					transport.Request(message);
+				}
+
+				Thread.Sleep(1000);
+				Assert.AreEqual(numMessages, this.sent.Count);
+			}
+		}
+
+		[Test]
+		public void TestFailoverTransportConnectionControlHandling()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61613)?transport.randomize=false");
+			string reconnectTo = "mock://localhost:61616?transport.name=Reconnected";
+			string connectedBrokers = "mock://localhost:61617?transport.name=Broker1," +
+									  "mock://localhost:61618?transport.name=Broker2";
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover = transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				failover.Resumed = OnResumed;
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				// Ensure the current mock transport has the correct outgoing command handler
+				MockTransport mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				Assert.AreEqual(61613, mock.RemoteAddress.Port);
+				VerifyCommandHandlerSetting(transport, mock);
+				mock.OutgoingCommand = OnOutgoingCommand;
+
+				mock.InjectCommand(new ConnectionControl()
+				{
+					FaultTolerant = true,
+					ReconnectTo = reconnectTo,
+					ConnectedBrokers = connectedBrokers
+				});
+
+				failover.Remove(true, "mock://localhost:61613");
+				Thread.Sleep(1000);
+
+				mock = transport.Narrow(typeof(MockTransport)) as MockTransport;
+				Assert.IsNotNull(mock);
+				Assert.AreEqual(61616, mock.RemoteAddress.Port);
+				Assert.AreEqual("Reconnected", mock.Name);
+			}
+		}
+
+		[Test]
+		public void OpenWireCommandsTest()
+		{
+			Uri uri = new Uri("failover:(mock://localhost:61616)?transport.randomize=false");
+			FailoverTransportFactory factory = new FailoverTransportFactory();
+
+			using(ITransport transport = factory.CreateTransport(uri))
+			{
+				Assert.IsNotNull(transport);
+				transport.Command = OnCommand;
+				transport.Exception = OnException;
+
+				FailoverTransport failover =  transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+				Assert.IsNotNull(failover);
+				Assert.IsFalse(failover.Randomize);
+
+				transport.Start();
+				Thread.Sleep(1000);
+				Assert.IsTrue(failover.IsConnected);
+
+				ConnectionInfo connection = createConnection();
+				transport.Request(connection);
+				SessionInfo session1 = createSession(connection);
+				transport.Request(session1);
+				SessionInfo session2 = createSession(connection);
+				transport.Request(session2);
+				ConsumerInfo consumer1 = createConsumer(session1);
+				transport.Request(consumer1);
+				ConsumerInfo consumer2 = createConsumer(session1);
+				transport.Request(consumer2);
+				ConsumerInfo consumer3 = createConsumer(session2);
+				transport.Request(consumer3);
+
+				ProducerInfo producer1 = createProducer(session2);
+				transport.Request(producer1);
+
+				// Remove the Producers
+				disposeOf(transport, producer1);
+
+				// Remove the Consumers
+				disposeOf(transport, consumer1);
+				disposeOf(transport, consumer2);
+				disposeOf(transport, consumer3);
+
+				// Remove the Session instances.
+				disposeOf(transport, session1);
+				disposeOf(transport, session2);
+
+				// Indicate that we are done.
+				ShutdownInfo shutdown = new ShutdownInfo();
+				transport.Oneway(shutdown);
+			}
+		}
+
+		protected ConnectionInfo createConnection()
+		{
+			return new ConnectionInfo()
+			{
+				ClientId = Guid.NewGuid().ToString(),
+				ConnectionId = new ConnectionId()
+				{
+					Value = Guid.NewGuid().ToString()
+				}
+			};
+		}
+
+		protected SessionInfo createSession(ConnectionInfo parent)
+		{
+			return new SessionInfo()
+			{
+				SessionId = new SessionId()
+				{
+					ConnectionId = parent.ConnectionId.Value,
+					Value = sessionIdx++
+				}
+			};
+		}
+
+		protected ConsumerInfo createConsumer(SessionInfo parent)
+		{
+			return new ConsumerInfo()
+			{
+				ConsumerId = new ConsumerId()
+				{
+					ConnectionId = parent.SessionId.ConnectionId,
+					SessionId = parent.SessionId.Value,
+					Value = consumerIdx++
+				}
+			};
+		}
+
+		protected ProducerInfo createProducer(SessionInfo parent)
+		{
+			return new ProducerInfo()
+			{
+				ProducerId = new ProducerId()
+				{
+					ConnectionId = parent.SessionId.ConnectionId,
+					SessionId = parent.SessionId.Value,
+					Value = producerIdx++
+				}
+			};
+		}
+
+		protected void disposeOf(ITransport transport, SessionInfo session)
+		{
+			transport.Oneway(new RemoveInfo() { ObjectId = session.SessionId });
+		}
+
+		protected void disposeOf(ITransport transport, ConsumerInfo consumer)
+		{
+			transport.Oneway(new RemoveInfo() { ObjectId = consumer.ConsumerId });
+		}
+
+		protected void disposeOf(ITransport transport, ProducerInfo producer)
+		{
+			transport.Oneway(new RemoveInfo() { ObjectId = producer.ProducerId });
 		}
 	}
 }



Mime
View raw message