activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r513820 - /activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs
Date Fri, 02 Mar 2007 15:54:50 GMT
Author: jstrachan
Date: Fri Mar  2 07:54:49 2007
New Revision: 513820

URL: http://svn.apache.org/viewvc?view=rev&rev=513820
Log:
used a slightly more reliable unique destination mechanism

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

Modified: activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs?view=diff&rev=513820&r1=513819&r2=513820
==============================================================================
--- activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs (original)
+++ activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs Fri Mar  2 07:54:49
2007
@@ -27,9 +27,11 @@
     [ TestFixture ]
     public abstract class NMSTestSupport
     {
+		protected static object destinationLock = new object();
+		protected static int destinationCounter;
 
         // enable/disable logging of message flows
-        protected bool logging = false;
+        protected bool logging = true;
 
         private IConnectionFactory factory;
         private IConnection connection;
@@ -50,6 +52,7 @@
         [TearDown]
         virtual public void TearDown()
         {
+			destination = null;
             Disconnect();
         }
 
@@ -97,23 +100,27 @@
 
         virtual protected void Connect()
         {
-            Console.WriteLine("Connectting...");
+            WriteLine("Connectting...");
             connection = CreateConnection();
             Assert.IsNotNull(connection, "no connection created");
             connection.Start();
-            Console.WriteLine("Connected.");
+            WriteLine("Connected.");
             Assert.IsNotNull(connection, "no connection created");
         }
 
         virtual protected void Disconnect()
         {
+			if (session != null)
+			{
+				session.Dispose();
+				session = null;
+			}
             if (connection != null)
             {
-                Console.WriteLine("Disconnecting...");
+                WriteLine("Disconnecting...");
                 connection.Dispose();
                 connection = null;
-                session=null;
-                Console.WriteLine("Disconnected.");
+                WriteLine("Disconnected.");
             }
         }
         
@@ -198,8 +205,13 @@
 
         protected virtual string CreateDestinationName()
         {
-            return "Test.DotNet." + GetType().Name + "." + DateTime.Now.Ticks;
+            return "Test.DotNet." + GetType().Name + "." + NextNumber.ToString();
         }
+		
+		public static int NextNumber
+		{
+			get { lock(destinationLock) { return ++destinationCounter; } }
+		}
         
         protected virtual IMessage CreateMessage()
         {
@@ -219,7 +231,7 @@
                 {
                     destination = CreateDestination();
                     Assert.IsNotNull(destination, "No destination available!");
-                    Console.WriteLine("Using destination: " + destination);
+                    WriteLine("Using destination: " + destination);
                 }
                 return destination;
             }
@@ -228,6 +240,14 @@
             }
         }
 
+		protected virtual void WriteLine(string text)
+		{
+			if (logging)
+			{
+				Console.WriteLine();
+				Console.WriteLine("#### : " + text);
+			}
+		}
     }
 }
 



Mime
View raw message