Skip to content

Commit aaab4f3

Browse files
committed
* Close connection mid-integration test for OAuth2
1 parent 2605d90 commit aaab4f3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

projects/Test/OAuth2/TestOAuth2.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using RabbitMQ.Client;
3737
using RabbitMQ.Client.Events;
3838
using RabbitMQ.Client.OAuth2;
39+
using Test;
3940
using Xunit;
4041
using Xunit.Abstractions;
4142

@@ -211,6 +212,8 @@ private Task OnCredentialsRefreshedAsync(Credentials? credentials, Exception? ex
211212
[Fact]
212213
public async void IntegrationTest()
213214
{
215+
Task? closeConnectionTask = null;
216+
214217
using (IChannel publishChannel = await DeclarePublishChannelAsync())
215218
{
216219
using (IChannel consumeChannel = await DeclareConsumeChannelAsync())
@@ -225,7 +228,20 @@ public async void IntegrationTest()
225228
var delaySpan = TimeSpan.FromSeconds(_tokenExpiresInSeconds + 10);
226229
_testOutputHelper.WriteLine("{0} [INFO] wait '{1}' until Token expires. Attempt #{1}",
227230
DateTime.Now, delaySpan, (i + 1));
231+
232+
if (i == 2)
233+
{
234+
closeConnectionTask = Util.CloseConnectionAsync(_connection);
235+
}
236+
228237
await Task.Delay(delaySpan);
238+
239+
if (closeConnectionTask != null)
240+
{
241+
await closeConnectionTask;
242+
closeConnectionTask = null;
243+
}
244+
229245
_testOutputHelper.WriteLine("{0} [INFO] Resuming ...", DateTime.Now);
230246

231247
await PublishAsync(publishChannel);

0 commit comments

Comments
 (0)