diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueTemplateTests.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueTemplateTests.cs
index c5ae3066..1ec00831 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueTemplateTests.cs
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueTemplateTests.cs
@@ -46,33 +46,12 @@ namespace Spring.Messaging.Core
[SetUp]
public override void SetUp()
{
- RecreateMessageQueue(@".\Private$\testqueue", false);
- RecreateMessageQueue(@".\Private$\testtxqueue", true);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testqueue", false);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxqueue", true);
base.SetUp();
}
- private void RecreateMessageQueue(string path, bool transactional)
- {
- bool defaultCacheEnabled = MessageQueue.EnableConnectionCache;
- MessageQueue.ClearConnectionCache();
- MessageQueue.EnableConnectionCache = false;
- if (MessageQueue.Exists(path))
- {
- MessageQueue queue;
-// TODO (EE): delete/create doesn't work for some reason
-// MessageQueue.Delete(path);
-// queue = MessageQueue.Create(path, transactional);
- queue = new MessageQueue(path);
- queue.Purge();
- queue.Dispose();
- }
- else
- {
- MessageQueue.Create(path, transactional).Dispose();
- }
- MessageQueue.ClearConnectionCache();
- MessageQueue.EnableConnectionCache = defaultCacheEnabled; // set to default
- }
+
#if NET_2_0 || NET_3_0
[Test]
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueUtils.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueUtils.cs
new file mode 100644
index 00000000..dd8d187c
--- /dev/null
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Core/MessageQueueUtils.cs
@@ -0,0 +1,55 @@
+#region License
+
+/*
+ * Copyright 2002-2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+using System.Messaging;
+
+namespace Spring.Messaging.Core
+{
+ ///
+ /// Utility class to recreate message queues if they do not exist.
+ ///
+ /// Mark Pollack
+ public class MessageQueueUtils
+ {
+ public static void RecreateMessageQueue(string path, bool transactional)
+ {
+ bool defaultCacheEnabled = MessageQueue.EnableConnectionCache;
+ MessageQueue.ClearConnectionCache();
+ MessageQueue.EnableConnectionCache = false;
+ if (MessageQueue.Exists(path))
+ {
+ MessageQueue queue;
+ // TODO (EE): delete/create doesn't work for some reason
+ // MessageQueue.Delete(path);
+ // queue = MessageQueue.Create(path, transactional);
+ queue = new MessageQueue(path);
+ queue.Purge();
+ queue.Dispose();
+ }
+ else
+ {
+ MessageQueue.Create(path, transactional).Dispose();
+ }
+ MessageQueue.ClearConnectionCache();
+ MessageQueue.EnableConnectionCache = defaultCacheEnabled; // set to default
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.cs
index c4b8e5b8..7e2e9821 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.cs
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.cs
@@ -20,6 +20,7 @@
#region Imports
+using System.Messaging;
using System.Threading;
using NUnit.Framework;
using Spring.Messaging.Core;
@@ -36,10 +37,20 @@ namespace Spring.Messaging.Listener
[TestFixture]
public class DistributedTxMessageListenerContainerTests : AbstractDependencyInjectionSpringContextTests
{
+
+
private int waitInMillis = 20000;
private DistributedTxMessageListenerContainer distributedTxMessageListenerContainer;
private SimpleHandler listener;
+ [SetUp]
+ public override void SetUp()
+ {
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxqueue", true);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxretryqueue", true);
+ base.SetUp();
+ }
+
public DistributedTxMessageListenerContainer DistributedTxMessageListenerContainer
{
@@ -80,7 +91,6 @@ namespace Spring.Messaging.Listener
Assert.AreEqual("Goodbye World 1", textMsg);
}
-
[Test]
public void SendAndAsyncReceive()
{
@@ -100,7 +110,7 @@ namespace Spring.Messaging.Listener
distributedTxMessageListenerContainer.Start();
Thread.Sleep(waitInMillis);
- Assert.AreEqual(5, listener.MessageCount);
+ Assert.AreEqual(15, listener.MessageCount);
distributedTxMessageListenerContainer.Stop();
distributedTxMessageListenerContainer.Shutdown();
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.xml b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.xml
index 5de74533..ada18976 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.xml
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/DistributedTxMessageListenerContainerTests.xml
@@ -13,12 +13,12 @@
@@ -33,7 +33,7 @@
-
+
@@ -57,10 +57,10 @@
-
+
-
+
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.cs
index 1db7ce59..a0c0ac8b 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.cs
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.cs
@@ -43,9 +43,12 @@ namespace Spring.Messaging.Listener
private SimpleHandler listener;
private SimpleExceptionHandler exceptionHandler;
- [Test]
- public void Test()
+ [SetUp]
+ public override void SetUp()
{
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testqueue", false);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testresponsequeue", false);
+ base.SetUp();
}
public SimpleExceptionHandler ExceptionHandler
@@ -68,6 +71,10 @@ namespace Spring.Messaging.Listener
[Test]
public void SendAndAsyncReceiveWithExceptionHandling()
{
+ //Reset the state so that running all tests together will succeed.
+ exceptionHandler.MessageCount = 0;
+
+
MessageQueueTemplate q = applicationContext["testQueueTemplate"] as MessageQueueTemplate;
Assert.IsNotNull(q);
q.ConvertAndSend("Goodbye World 1");
@@ -95,8 +102,9 @@ namespace Spring.Messaging.Listener
q.ConvertAndSend("Hello World 3");
q.ConvertAndSend("Hello World 4");
q.ConvertAndSend("Hello World 5");
-
-
+
+ //Reset the state so that running all tests together will succeed.
+ exceptionHandler.MessageCount = 0;
Assert.AreEqual(0, listener.MessageCount);
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.xml b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.xml
index b6b88940..ad8eb5ec 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.xml
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/NonTransactionalMessageListenerContainerTests.xml
@@ -34,7 +34,7 @@
-
+
diff --git a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/TransactionalMessageListenerContainerTests.cs b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/TransactionalMessageListenerContainerTests.cs
index e68625a5..1d0e9ba2 100644
--- a/test/Spring/Spring.Messaging.Tests/Messaging/Listener/TransactionalMessageListenerContainerTests.cs
+++ b/test/Spring/Spring.Messaging.Tests/Messaging/Listener/TransactionalMessageListenerContainerTests.cs
@@ -41,6 +41,16 @@ namespace Spring.Messaging.Listener
private TransactionalMessageListenerContainer transactionalMessageListenerContainer;
private SimpleHandler listener;
+
+ [SetUp]
+ public override void SetUp()
+ {
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxqueue", true);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxretryqueue", true);
+ MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxresponsequeue", true);
+ base.SetUp();
+ }
+
public TransactionalMessageListenerContainer TransactionalMessageListenerContainer
{
set { transactionalMessageListenerContainer = value; }
@@ -52,7 +62,7 @@ namespace Spring.Messaging.Listener
set { listener = value; }
}
- [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Property 'DefaultMessageQueue' is required")]
+ [Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Property 'MessageQueueObjectName' is required")]
public void EnsureMessageQueuePropertyIsSet()
{
TransactionalMessageListenerContainer container = new TransactionalMessageListenerContainer();
diff --git a/test/Spring/Spring.Messaging.Tests/Spring.Messaging.Tests.2008.csproj b/test/Spring/Spring.Messaging.Tests/Spring.Messaging.Tests.2008.csproj
index 7d51cc81..fc0bcbe0 100644
--- a/test/Spring/Spring.Messaging.Tests/Spring.Messaging.Tests.2008.csproj
+++ b/test/Spring/Spring.Messaging.Tests/Spring.Messaging.Tests.2008.csproj
@@ -89,6 +89,7 @@
+