activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1482972 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/ test/csharp/
Date Wed, 15 May 2013 17:32:26 GMT
Author: tabish
Date: Wed May 15 17:32:26 2013
New Revision: 1482972

URL: http://svn.apache.org/r1482972
Log:
fix and test updates for: https://issues.apache.org/jira/browse/AMQNET-416

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnectionFactory.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcBasicTransactionsTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcConsumerTransactionsTest.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcProducerTransactionsTest.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs?rev=1482972&r1=1482971&r2=1482972&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnection.cs
Wed May 15 17:32:26 2013
@@ -32,6 +32,7 @@ namespace Apache.NMS.ActiveMQ
     public class NetTxConnection : Connection, INetTxConnection
     {
         private NetTxRecoveryPolicy recoveryPolicy = new NetTxRecoveryPolicy();
+        private Guid configuredResourceManagerId = Guid.Empty;
 
         public NetTxConnection(Uri connectionUri, ITransport transport, IdGenerator clientIdGenerator)
             : base(connectionUri, transport, clientIdGenerator)
@@ -62,9 +63,19 @@ namespace Apache.NMS.ActiveMQ
             set { this.recoveryPolicy = value; }
         }
 
+        public Guid ConfiguredResourceManagerId
+        {
+            get { return this.configuredResourceManagerId; }
+            set { this.configuredResourceManagerId = value; }
+        }
+
         internal Guid ResourceManagerGuid
         {
-            get { return GuidFromId(this.ResourceManagerId); }
+            get
+            {
+                return ConfiguredResourceManagerId != Guid.Empty ? 
+                    ConfiguredResourceManagerId : GuidFromId(ResourceManagerId);
+            }
         }
 
         private static Guid GuidFromId(string id)

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnectionFactory.cs?rev=1482972&r1=1482971&r2=1482972&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnectionFactory.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/NetTxConnectionFactory.cs
Wed May 15 17:32:26 2013
@@ -26,6 +26,7 @@ namespace Apache.NMS.ActiveMQ
     public class NetTxConnectionFactory : ConnectionFactory, INetTxConnectionFactory
     {
         private NetTxRecoveryPolicy recoveryPolicy = new NetTxRecoveryPolicy();
+        private Guid configuredResourceManagerId = Guid.Empty;
 
         public NetTxConnectionFactory() : base(GetDefaultBrokerUrl())
         {
@@ -50,6 +51,12 @@ namespace Apache.NMS.ActiveMQ
         {
         }
 
+        public String ConfiguredResourceManagerId
+        {
+            get { return this.configuredResourceManagerId.ToString(); }
+            set { this.configuredResourceManagerId = new Guid(value); }
+        }
+
         public INetTxConnection CreateNetTxConnection()
         {
             return (INetTxConnection) base.CreateActiveMQConnection();
@@ -65,6 +72,7 @@ namespace Apache.NMS.ActiveMQ
             NetTxConnection connection = new NetTxConnection(this.BrokerUri, transport, this.ClientIdGenerator);
 
             connection.RecoveryPolicy = this.recoveryPolicy.Clone() as NetTxRecoveryPolicy;
+            connection.ConfiguredResourceManagerId = this.configuredResourceManagerId;
 
             return connection;
         }

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcBasicTransactionsTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcBasicTransactionsTest.cs?rev=1482972&r1=1482971&r2=1482972&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcBasicTransactionsTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcBasicTransactionsTest.cs
Wed May 15 17:32:26 2013
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+using System;
 using System.Threading;
 using Apache.NMS.ActiveMQ.Transactions;
 using NUnit.Framework;
@@ -25,12 +26,21 @@ namespace Apache.NMS.ActiveMQ.Test
     [Category("Manual")]
     class DtcBasicTransactionsTest : DtcTransactionsTestSupport
     {
+        private NetTxConnectionFactory factory = null;
+
+        [SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+
+            this.factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
+            this.factory.ConfiguredResourceManagerId = Guid.NewGuid().ToString();
+        }
+
         [Test]
         [ExpectedException("Apache.NMS.NMSException")]
         public void TestSessionCreateFailsWithInvalidLogLocation()
         {
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -49,8 +59,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -75,8 +83,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcConsumerTransactionsTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcConsumerTransactionsTest.cs?rev=1482972&r1=1482971&r2=1482972&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcConsumerTransactionsTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcConsumerTransactionsTest.cs
Wed May 15 17:32:26 2013
@@ -31,6 +31,17 @@ namespace Apache.NMS.ActiveMQ.Test
     [Category("Manual")]
     class DtcConsumerTransactionsTest : DtcTransactionsTestSupport
     {
+        private NetTxConnectionFactory factory = null;
+
+        [SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+
+            this.factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
+            this.factory.ConfiguredResourceManagerId = Guid.NewGuid().ToString();
+        }
+
         [Test]
         public void TestRedelivered()
         {
@@ -39,7 +50,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeAndFillQueue();
 
             // receive just one
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.Start();
@@ -103,7 +113,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue(messageCount);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.Start();
@@ -175,7 +184,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue(messageCount);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.Start();
@@ -246,7 +254,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue(messageCount);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 // allow no redelivery so that message immediatly goes to the DLQ if first
read fails
@@ -314,8 +321,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -348,8 +353,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -382,8 +385,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue(5 * MSG_COUNT);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -409,8 +410,10 @@ namespace Apache.NMS.ActiveMQ.Test
         public void TestConsumeWithDBInsertLogLocation()
         {
             const string logLocation = @".\RecoveryDir";
-            const string newConnectionUri =
-                connectionURI + "?nms.RecoveryPolicy.RecoveryLogger.Location=" + logLocation;
+            string newConnectionUri =
+                connectionURI + "?nms.RecoveryPolicy.RecoveryLogger.Location=" + logLocation
+
+                                "&nms.configuredResourceManagerId=" + 
+                                factory.ConfiguredResourceManagerId;
 
             // Test initialize - Fills in queue with data to send and clears the DB.
             PurgeDatabase();
@@ -423,7 +426,7 @@ namespace Apache.NMS.ActiveMQ.Test
 
             Directory.CreateDirectory(logLocation);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(newConnectionUri));
+            factory = new NetTxConnectionFactory(ReplaceEnvVar(newConnectionUri));
 
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
@@ -458,8 +461,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -484,8 +485,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -515,8 +514,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 ITransport transport = (connection as Connection).ITransport;
@@ -549,8 +546,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 ITransport transport = (connection as Connection).ITransport;
@@ -589,8 +584,6 @@ namespace Apache.NMS.ActiveMQ.Test
             PurgeDatabase();
             PurgeAndFillQueue(MSG_COUNT * BATCH_COUNT);
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             using (NetTxSession session = connection.CreateNetTxSession() as NetTxSession)
             {

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcProducerTransactionsTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcProducerTransactionsTest.cs?rev=1482972&r1=1482971&r2=1482972&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcProducerTransactionsTest.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/DtcProducerTransactionsTest.cs
Wed May 15 17:32:26 2013
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+using System;
 using System.IO;
 using System.Threading;
 using Apache.NMS.ActiveMQ.Transactions;
@@ -28,14 +29,23 @@ namespace Apache.NMS.ActiveMQ.Test
     [Category("Manual")]
     class DtcProducerTransactionsTest : DtcTransactionsTestSupport
     {
+        private NetTxConnectionFactory factory = null;
+
+        [SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+
+            this.factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
+            this.factory.ConfiguredResourceManagerId = Guid.NewGuid().ToString();
+        }
+
         [Test]
         public void TestRecoverAfterFailOnTransactionCommit()
         {
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -67,8 +77,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -100,8 +108,7 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-            NetTxConnectionFactory netTxFactory = factory as NetTxConnectionFactory;
+            NetTxConnectionFactory netTxFactory = factory;
             RecoveryFileLogger logger = netTxFactory.RecoveryPolicy.RecoveryLogger as RecoveryFileLogger;
             string logDirectory = logger.Location;
 
@@ -142,10 +149,12 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            const string newConnectionUri = 
-                connectionURI + "?nms.RecoveryPolicy.RecoveryLoggerType=harness";
+            string newConnectionUri = 
+                connectionURI + "?nms.RecoveryPolicy.RecoveryLoggerType=harness" +
+                                "&nms.configuredResourceManagerId=" +
+                                factory.ConfiguredResourceManagerId;
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(newConnectionUri));
+            factory = new NetTxConnectionFactory(ReplaceEnvVar(newConnectionUri));
 
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
@@ -177,8 +186,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -207,8 +214,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -237,8 +242,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -262,8 +265,6 @@ namespace Apache.NMS.ActiveMQ.Test
             // Test initialize - Fills in DB with data to send.
             PrepareDatabase();
 
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -292,8 +293,6 @@ namespace Apache.NMS.ActiveMQ.Test
         [Test]
         public void TestIterativeTransactedProduceWithDBDelete()
         {
-            INetTxConnectionFactory factory = new NetTxConnectionFactory(ReplaceEnvVar(connectionURI));
-
             using (INetTxConnection connection = factory.CreateNetTxConnection())
             {
                 connection.ExceptionListener += this.OnException;
@@ -321,6 +320,5 @@ namespace Apache.NMS.ActiveMQ.Test
             // check messages are present in the queue
             VerifyBrokerQueueCount(MSG_COUNT * 5);
         }
-
     }
 }



Mime
View raw message