Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 76683 invoked from network); 30 Mar 2009 20:10:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Mar 2009 20:10:08 -0000 Received: (qmail 41539 invoked by uid 500); 30 Mar 2009 20:10:05 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 41515 invoked by uid 500); 30 Mar 2009 20:10:05 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 41487 invoked by uid 99); 30 Mar 2009 20:10:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Mar 2009 20:10:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Mar 2009 20:10:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7E00423889F5; Mon, 30 Mar 2009 20:09:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r760141 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ConsumerTest.cs Date: Mon, 30 Mar 2009 20:09:44 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090330200944.7E00423889F5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 - } + + } }