some misc test code cleanup
This commit is contained in:
@@ -49,6 +49,7 @@ namespace Spring.Messaging.Listener
|
||||
{
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxqueue", true);
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxretryqueue", true);
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxresponsequeue", true);
|
||||
|
||||
|
||||
if (listener != null)
|
||||
@@ -105,7 +106,7 @@ namespace Spring.Messaging.Listener
|
||||
//must match the retry count in the object registration for test to pass!
|
||||
const int EXCEPTION_QUEUE_RETRY_COUNT = 2;
|
||||
|
||||
int expectedMessageCount = MESSAGE_COUNT + (MESSAGE_COUNT * EXCEPTION_QUEUE_RETRY_COUNT);
|
||||
int expectedMessageCount = MESSAGE_COUNT; // +(MESSAGE_COUNT * EXCEPTION_QUEUE_RETRY_COUNT);
|
||||
|
||||
MessageQueueTemplate q = applicationContext["queueTemplate"] as MessageQueueTemplate;
|
||||
Assert.IsNotNull(q);
|
||||
@@ -117,20 +118,27 @@ namespace Spring.Messaging.Listener
|
||||
|
||||
Assert.AreEqual(0, listener.MessageCount);
|
||||
|
||||
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
|
||||
timer.Start();
|
||||
|
||||
distributedTxMessageListenerContainer.Start();
|
||||
|
||||
Thread.Sleep(10000);
|
||||
/*
|
||||
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
|
||||
timer.Start();
|
||||
|
||||
while (listener.MessageCount < expectedMessageCount)
|
||||
{
|
||||
if (timer.ElapsedMilliseconds > 60000)
|
||||
Assert.Fail("Did not receive expected number of messages within the permitted time limit.");
|
||||
if (timer.ElapsedMilliseconds > 10000)
|
||||
{
|
||||
break;
|
||||
}
|
||||
//Assert.Fail("Did not receive expected number of messages within the permitted time limit.");
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
timer.Stop();
|
||||
|
||||
System.Diagnostics.Debug.WriteLine("elapsed time = " + timer.ElapsedMilliseconds);
|
||||
*/
|
||||
|
||||
Assert.AreEqual(expectedMessageCount, listener.MessageCount);
|
||||
|
||||
@@ -138,6 +146,15 @@ namespace Spring.Messaging.Listener
|
||||
distributedTxMessageListenerContainer.Shutdown();
|
||||
Thread.Sleep(2500);
|
||||
|
||||
MessageQueueTemplate responseQ = applicationContext["responseQueueTemplate"] as MessageQueueTemplate;
|
||||
responseQ.ReceiveTimeout = new System.TimeSpan(0, 0, 2);
|
||||
|
||||
Assert.IsNotNull(responseQ);
|
||||
for (int i = 0; i < MESSAGE_COUNT; i++)
|
||||
{
|
||||
Assert.IsNotNull(responseQ.ReceiveAndConvert());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override string[] ConfigLocations
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
<property name="DefaultMessageQueueObjectName" value="msmqtxretryqueue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
<object id="responseQueueTemplate" type="Spring.Messaging.Core.MessageQueueTemplate, Spring.Messaging">
|
||||
<property name="DefaultMessageQueueObjectName" value="msmqtxresponsequeue"/>
|
||||
<property name="MessageConverterObjectName" value="messageConverter"/>
|
||||
</object>
|
||||
|
||||
<object id="messageConverter" type="Spring.Messaging.Support.Converters.XmlMessageConverter, Spring.Messaging"
|
||||
singleton="false">
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:db="http://www.springframework.net/database">
|
||||
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="System.Data.SqlClient"
|
||||
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"/>
|
||||
|
||||
<object id="adoTransactionManager"
|
||||
type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
|
||||
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
|
||||
<property name="VariableSources">
|
||||
<list>
|
||||
<object type="Spring.Objects.Factory.Config.EnvironmentVariableSource, Spring.Core"/>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id='msmqTestQueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
@@ -34,7 +32,8 @@
|
||||
</object>
|
||||
|
||||
<object id='testremotequeue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=OS:RAVEN\Private$\testqueue'/>
|
||||
<!-- note that ${COMPUTERNAME} is replaced using Spring's VariablePlaceholderConfigurer defined above -->
|
||||
<property name='Path' value='FormatName:Direct=OS:${COMPUTERNAME}\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
</object>
|
||||
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:db="http://www.springframework.net/database">
|
||||
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="System.Data.SqlClient"
|
||||
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa"/>
|
||||
|
||||
<object id="adoTransactionManager"
|
||||
type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
|
||||
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<object type="Spring.Objects.Factory.Config.VariablePlaceholderConfigurer, Spring.Core">
|
||||
<property name="VariableSources">
|
||||
<list>
|
||||
<object type="Spring.Objects.Factory.Config.EnvironmentVariableSource, Spring.Core"/>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id='msmqTestQueue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
@@ -34,7 +31,8 @@
|
||||
</object>
|
||||
|
||||
<object id='testremotequeue' type='Spring.Messaging.Support.MessageQueueFactoryObject, Spring.Messaging'>
|
||||
<property name='Path' value='FormatName:Direct=OS:RAVEN\Private$\testqueue'/>
|
||||
<!-- note that ${COMPUTERNAME} is replaced using Spring's VariablePlaceholderConfigurer defined above -->
|
||||
<property name='Path' value='FormatName:Direct=OS:${COMPUTERNAME}\Private$\testqueue'/>
|
||||
<property name='RemoteQueue' value="true"/>
|
||||
</object>
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace Spring.Messaging.Listener
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxqueue", true);
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxretryqueue", true);
|
||||
MessageQueueUtils.RecreateMessageQueue(@".\Private$\testtxresponsequeue", true);
|
||||
if (listener != null)
|
||||
listener.MessageCount = 0; //reset the property between tests b/c the object lifecycle is singleton!
|
||||
base.SetUp();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<objects xmlns="http://www.springframework.net"
|
||||
xmlns:db="http://www.springframework.net/database">
|
||||
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="System.Data.SqlClient"
|
||||
connectionString="Data Source=.\SQLExpress;Initial Catalog=springqa;Persist Security Info=True;User ID=springqa;Password=springqa"/>
|
||||
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="System.Data.SqlClient"
|
||||
connectionString="Data Source=SPRINGQA;Database=Spring;Trusted_Connection=False;User ID=springqa;Password=springqa"/>
|
||||
|
||||
|
||||
<object id="adoTransactionManager"
|
||||
type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
|
||||
|
||||
Reference in New Issue
Block a user