Author: tabish
Date: Tue Apr 30 22:15:09 2013
New Revision: 1477856

URL: http://svn.apache.org/r1477856
Log:
Finishing up
https://issues.apache.org/jira/browse/AMQNET-403

Modified:
    
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/Failover/FailoverTransport.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=1477856&r1=1477855&r2=1477856&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
 Tue Apr 30 22:15:09 2013
@@ -306,6 +306,12 @@ namespace Apache.NMS.ActiveMQ.Transport.
                        set { this.priorityBackup = value; }
                }
 
+           public String PriorityURIs
+               {
+                       get { return PrintableUriList(priorityList); }
+                       set { this.ProcessDelimitedUriList(value, 
priorityList); }
+           }
+
         public int BackupPoolSize
         {
             get { return backupPoolSize; }
@@ -1416,20 +1422,7 @@ namespace Apache.NMS.ActiveMQ.Transport.
                 if(newTransports.Length > 0 && IsUpdateURIsSupported)
                 {
                     List<Uri> list = new List<Uri>();
-                    String[] tokens = newTransports.Split(new Char[] { ',' });
-
-                    foreach(String str in tokens)
-                    {
-                        try
-                        {
-                            Uri uri = new Uri(str);
-                            list.Add(uri);
-                        }
-                        catch
-                        {
-                            Tracer.Error("Failed to parse broker address: " + 
str);
-                        }
-                    }
+                                       ProcessDelimitedUriList(newTransports, 
list);
 
                     if(list.Count != 0)
                     {
@@ -1443,8 +1436,32 @@ namespace Apache.NMS.ActiveMQ.Transport.
                         }
                     }
                 }
+            }        
+               }
+
+               private void ProcessDelimitedUriList(String priorityUris, 
List<Uri> target)
+               {
+            String[] tokens = priorityUris.Split(new Char[] { ',' });
+
+            foreach(String str in tokens)
+            {
+                try
+                {
+                    Uri uri = new Uri(str);
+                    target.Add(uri);
+
+                                       if (Tracer.IsDebugEnabled)
+                                       {
+                                               Tracer.DebugFormat("Adding new 
Uri[{0}] to list,", uri);
+                                       }
+                }
+                catch (Exception e)
+                {
+                                       Tracer.ErrorFormat("Failed to parse 
broker address: {0} because of: {1}",
+                                                          str, e.Message);
+                }
             }
-        }
+               }
 
         public void Dispose()
         {
@@ -1587,16 +1604,16 @@ namespace Apache.NMS.ActiveMQ.Transport.
                {
                        if (uriList.Count == 0)
                        {
-                               return "<no-Uris>";
+                               return "";
                        }
 
                        StringBuilder builder = new StringBuilder();
                        for (int i = 0; i < uriList.Count; ++i)
                        {
                                builder.Append(uriList[i]);
-                               if (i < uriList.Count + 1)
+                               if (i < (uriList.Count - 1))
                                {
-                                       builder.Append(":");
+                                       builder.Append(",");
                                }
                        }
 

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=1477856&r1=1477855&r2=1477856&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 Apr 30 22:15:09 2013
@@ -595,6 +595,49 @@ namespace Apache.NMS.ActiveMQ.Test
                }
 
                [Test]
+               public void TestPriorityBackupConfigPriorityURIsList() 
+               {
+                   Uri uri = new 
Uri("failover:(mock://localhost:61616,mock://localhost:61618)" +
+                                         
"?transport.randomize=false&transport.priorityBackup=true&" +
+                                         
"transport.priorityURIs=mock://localhost:61616,mock://localhost:61618");
+
+                       FailoverTransportFactory factory = new 
FailoverTransportFactory();
+
+                       using(ITransport transport = 
factory.CreateTransport(uri))
+                       {
+                               Assert.IsNotNull(transport);
+                               transport.Command = OnCommand;
+                               transport.Exception = OnException;
+                               transport.Resumed = OnResumed;
+                               transport.Interrupted = OnInterrupted;
+
+                               FailoverTransport failover = 
transport.Narrow(typeof(FailoverTransport)) as FailoverTransport;
+                               Assert.IsNotNull(failover);
+                               Assert.IsFalse(failover.Randomize, "Randomize 
should be false");
+                               Assert.IsTrue(failover.PriorityBackup, 
"Prioirity Backup not set.");
+
+                               String priorityURIs = failover.PriorityURIs;
+                   String[] tokens = priorityURIs.Split(new Char[] { ',' });
+                               Assert.AreEqual(2, tokens.Length, "Bad 
priorityURIs string: " + priorityURIs);
+
+                       transport.Start();
+
+                               for(int i = 0; i < MAX_ATTEMPTS; ++i)
+                               {
+                                       if(failover.IsConnected)
+                                       {
+                                               break;
+                                       }
+                                       
+                                       Thread.Sleep(100);
+                               }
+                               
+                               Assert.IsTrue(failover.IsConnected);
+                               Assert.IsTrue(failover.IsConnectedToPriority);
+                       }
+               }
+
+               [Test]
                public void OpenWireCommandsTest()
                {
                        Uri uri = new 
Uri("failover:(mock://localhost:61616)?transport.randomize=false");


Reply via email to