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/03/30 22:09:44 UTC
svn commit: r760141 -
/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
Author: tabish
Date: Mon Mar 30 20:09:43 2009
New Revision: 760141
URL: http://svn.apache.org/viewvc?rev=760141&view=rev
Log:
Test for:
https://issues.apache.org/activemq/browse/AMQNET-154
Modified:
activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs?rev=760141&r1=760140&r2=760141&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs Mon Mar 30 20:09:43 2009
@@ -146,6 +146,43 @@
Assert.Fail("Test failed with exception: " + e.Message);
}
}
+
+ [Test]
+ public void TestSyncReceiveConsumerClose()
+ {
+ // Launch a thread to perform IMessageConsumer.Receive().
+ // If it doesn't fail in less than three seconds, no exception was thrown.
+ Thread receiveThread = new Thread(new ThreadStart(TimeoutConsumerThreadProc));
+ using (IConnection connection = CreateConnection(TEST_CLIENT_ID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ ITemporaryQueue queue = session.CreateTemporaryQueue();
+ using (this.timeoutConsumer = session.CreateConsumer(queue))
+ {
+ receiveThread.Start();
+ if (receiveThread.Join(3000))
+ {
+ Assert.Fail("IMessageConsumer.Receive() returned without blocking. Test failed.");
+ }
+ else
+ {
+ // Kill the thread - otherwise it'll sit in Receive() until a message arrives.
+ this.timeoutConsumer.Close();
+ receiveThread.Join(10000);
+ if (receiveThread.IsAlive)
+ {
+ // Kill the thread - otherwise it'll sit in Receive() until a message arrives.
+ receiveThread.Interrupt();
+ Assert.Fail("IMessageConsumer.Receive() thread is still alive, close should have killed it.");
+ }
+ }
+ }
+ }
+ }
+ }
#endif
- }
+
+ }
}