You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/11/03 00:29:08 UTC

svn commit: r832191 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs

Author: tabish
Date: Mon Nov  2 23:29:07 2009
New Revision: 832191

URL: http://svn.apache.org/viewvc?rev=832191&view=rev
Log:
* NMSTestSupport.cs: 

Add function to get the configured URI string.

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=832191&r1=832190&r2=832191&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/NMSTestSupport.cs Mon Nov  2 23:29:07 2009
@@ -96,6 +96,47 @@
         }
 
         /// <summary>
+        /// Return the configured URI String.  This function loads the connection 
+        /// settings from the configuration file.
+        /// </summary>
+        /// <returns></returns>
+        protected string GetConfiguredConnectionURI()
+        {
+            Uri brokerUri = null;
+            string[] paths = GetConfigSearchPaths();
+            string connectionConfigFileName = GetConnectionConfigFileName();
+            bool configFound = false;
+
+            foreach(string path in paths)
+            {
+                string fullpath = Path.Combine(path, connectionConfigFileName);
+                Tracer.Debug("\tScanning folder: " + path);
+
+                if(File.Exists(fullpath))
+                {
+                    Tracer.Debug("\tAssembly found!");
+                    connectionConfigFileName = fullpath;
+                    configFound = true;
+                    break;
+                }
+            }
+
+            Assert.IsTrue(configFound, "Connection configuration file does not exist.");
+            XmlDocument configDoc = new XmlDocument();
+
+            configDoc.Load(connectionConfigFileName);
+            XmlElement uriNode = (XmlElement) configDoc.SelectSingleNode(String.Format("/configuration/{0}", GetNameTestURI()));
+
+            if(null != uriNode)
+            {
+                // Replace any environment variables embedded inside the string.
+                brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
+            }
+
+			return brokerUri.ToString();
+        }
+		
+        /// <summary>
         /// Create the NMS Factory that can create NMS Connections.  This function loads the
         /// connection settings from the configuration file.
         /// </summary>