54
54
55
55
namespace RabbitMQ . Client . Unit {
56
56
[ TestFixture ]
57
- public class TestConnectionBlocked {
57
+ public class TestConnectionBlocked : IntegrationFixture {
58
58
59
59
Object lockObject = new Object ( ) ;
60
60
UTF8Encoding enc = new UTF8Encoding ( ) ;
@@ -63,19 +63,21 @@ public class TestConnectionBlocked {
63
63
[ Test ]
64
64
public void TestConnectionBlockedNotification ( )
65
65
{
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 ) ;
71
68
72
69
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
+ }
77
77
}
78
78
79
+
80
+
79
81
public void HandleBlocked ( IConnection sender , ConnectionBlockedEventArgs args )
80
82
{
81
83
Unblock ( ) ;
@@ -104,7 +106,7 @@ protected void ExecRabbitMQCtl(string command)
104
106
if ( IsRunningOnMono ( ) ) {
105
107
ExecCommand ( "../rabbitmq-server/scripts/rabbitmqctl " + command ) ;
106
108
} else {
107
- ExecCommand ( "..\\ rabbitmq-server\\ scripts\\ rabbitmqctl " + command ) ;
109
+ ExecCommand ( "..\\ rabbitmq-server\\ scripts\\ rabbitmqctl.bat " + command ) ;
108
110
}
109
111
}
110
112
@@ -143,5 +145,10 @@ protected void Publish(IConnection conn)
143
145
IModel ch = conn . CreateModel ( ) ;
144
146
ch . BasicPublish ( "" , "amq.fanout" , null , enc . GetBytes ( "message" ) ) ;
145
147
}
148
+
149
+ protected override void ReleaseResources ( )
150
+ {
151
+ Unblock ( ) ;
152
+ }
146
153
}
147
154
}
0 commit comments