Skip to content

Commit f626f7b

Browse files
Add a test for #58 (it passes)
1 parent fd92c57 commit f626f7b

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

projects/client/Unit/RabbitMQ.Client.Unit.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!-- Warning! This file contains important customizations. Using Visual Studio to edit project's properties might break things. -->
44
<!-- Props file -->
@@ -95,6 +95,7 @@
9595
<Compile Include="src\unit\TestChannelAllocation.cs" />
9696
<Compile Include="src\unit\TestConfirmSelect.cs" />
9797
<Compile Include="src\unit\TestConnectionBlocked.cs" />
98+
<Compile Include="src\unit\TestConnectionChurnHandleLeak.cs" />
9899
<Compile Include="src\unit\TestConnectionFactory.cs" />
99100
<Compile Include="src\unit\TestConnectionRecovery.cs" />
100101
<Compile Include="src\unit\TestConnectionShutdown.cs" />
@@ -145,4 +146,4 @@
145146
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
146147
<!-- Custom BeforeClean -->
147148
<Target Name="BeforeClean" DependsOnTargets="CleanTestResults" />
148-
</Project>
149+
</Project>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This source code is dual-licensed under the Apache License, version
2+
// 2.0, and the Mozilla Public License, version 1.1.
3+
//
4+
// The APL v2.0:
5+
//
6+
//---------------------------------------------------------------------------
7+
// Copyright (C) 2007-2014 GoPivotal, Inc.
8+
//
9+
// Licensed under the Apache License, Version 2.0 (the "License");
10+
// you may not use this file except in compliance with the License.
11+
// You may obtain a copy of the License at
12+
//
13+
// http://www.apache.org/licenses/LICENSE-2.0
14+
//
15+
// Unless required by applicable law or agreed to in writing, software
16+
// distributed under the License is distributed on an "AS IS" BASIS,
17+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// See the License for the specific language governing permissions and
19+
// limitations under the License.
20+
//---------------------------------------------------------------------------
21+
//
22+
// The MPL v1.1:
23+
//
24+
//---------------------------------------------------------------------------
25+
// The contents of this file are subject to the Mozilla Public License
26+
// Version 1.1 (the "License"); you may not use this file except in
27+
// compliance with the License. You may obtain a copy of the License
28+
// at http://www.mozilla.org/MPL/
29+
//
30+
// Software distributed under the License is distributed on an "AS IS"
31+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
32+
// the License for the specific language governing rights and
33+
// limitations under the License.
34+
//
35+
// The Original Code is RabbitMQ.
36+
//
37+
// The Initial Developer of the Original Code is GoPivotal, Inc.
38+
// Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
39+
//---------------------------------------------------------------------------
40+
41+
using NUnit.Framework;
42+
using RabbitMQ.Client.Exceptions;
43+
using System;
44+
using System.Diagnostics;
45+
using System.Threading;
46+
47+
namespace RabbitMQ.Client.Unit
48+
{
49+
[TestFixture]
50+
public class TestConnectionChurnHandleLeak : IntegrationFixture
51+
{
52+
[Test]
53+
[Category("RequireSMP")]
54+
public void TestHandleLeak()
55+
{
56+
var cf = new ConnectionFactory();
57+
var me = Process.GetCurrentProcess();
58+
var n = me.HandleCount;
59+
Console.WriteLine("{0} handles before the test...", me.HandleCount);
60+
for (var i = 0; i < 1000; i++)
61+
{
62+
using (var conn = cf.CreateConnection())
63+
{
64+
}
65+
}
66+
Thread.Sleep(TimeSpan.FromSeconds(10));
67+
Console.WriteLine("{0} handles after the test...", me.HandleCount);
68+
Assert.That(me.HandleCount, Is.LessThanOrEqualTo(n));
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)