Skip to content

Commit bf0682e

Browse files
Make sure to unblock in tear down
1 parent 31c7086 commit bf0682e

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

projects/client/Unit/src/unit/TestConnectionBlocked.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
namespace RabbitMQ.Client.Unit {
5656
[TestFixture]
57-
public class TestConnectionBlocked {
57+
public class TestConnectionBlocked : IntegrationFixture {
5858

5959
Object lockObject = new Object();
6060
UTF8Encoding enc = new UTF8Encoding();
@@ -63,19 +63,21 @@ public class TestConnectionBlocked {
6363
[Test]
6464
public void TestConnectionBlockedNotification()
6565
{
66-
ConnectionFactory cf = new ConnectionFactory();
67-
IConnection conn = cf.CreateConnection();
68-
69-
conn.ConnectionBlocked += new ConnectionBlockedEventHandler(HandleBlocked);
70-
conn.ConnectionUnblocked += new ConnectionUnblockedEventHandler(HandleUnblocked);
66+
Conn.ConnectionBlocked += new ConnectionBlockedEventHandler(HandleBlocked);
67+
Conn.ConnectionUnblocked += new ConnectionUnblockedEventHandler(HandleUnblocked);
7168

7269
Block();
73-
Publish(conn);
74-
Monitor.Wait(TimeSpan.FromSeconds(10));
75-
76-
Assert.IsTrue(notified);
70+
Publish(Conn);
71+
lock (lockObject) {
72+
if(!notified) {
73+
Monitor.Wait(lockObject, TimeSpan.FromSeconds(10));
74+
}
75+
Assert.IsTrue(notified);
76+
}
7777
}
7878

79+
80+
7981
public void HandleBlocked(IConnection sender, ConnectionBlockedEventArgs args)
8082
{
8183
Unblock();
@@ -104,7 +106,7 @@ protected void ExecRabbitMQCtl(string command)
104106
if(IsRunningOnMono()) {
105107
ExecCommand("../rabbitmq-server/scripts/rabbitmqctl " + command);
106108
} else {
107-
ExecCommand("..\\rabbitmq-server\\scripts\\rabbitmqctl " + command);
109+
ExecCommand("..\\rabbitmq-server\\scripts\\rabbitmqctl.bat " + command);
108110
}
109111
}
110112

@@ -143,5 +145,10 @@ protected void Publish(IConnection conn)
143145
IModel ch = conn.CreateModel();
144146
ch.BasicPublish("", "amq.fanout", null, enc.GetBytes("message"));
145147
}
148+
149+
protected override void ReleaseResources()
150+
{
151+
Unblock();
152+
}
146153
}
147154
}

0 commit comments

Comments
 (0)