Skip to content
Permalink
Browse files
Minor reformat.
  • Loading branch information
Jim Gomes committed May 5, 2009
1 parent 67faf3a commit c7f9d78f629982def1f8b40c4194f9a3c6e70914
Showing 1 changed file with 36 additions and 36 deletions.
@@ -147,42 +147,42 @@ protected void TimeoutConsumerThreadProc()
}
}

[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.");
}
}
}
}
}
}
[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

}
}
}

0 comments on commit c7f9d78

Please sign in to comment.