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