File tree Expand file tree Collapse file tree 2 files changed +24
-19
lines changed
NHSpecificTest/NH1908ThreadSafety Expand file tree Collapse file tree 2 files changed +24
-19
lines changed Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Threading ;
5
- using NHibernate . Util ;
5
+ using NHibernate . Dialect ;
6
6
using NUnit . Framework ;
7
7
8
8
namespace NHibernate . Test . NHSpecificTest . NH1908ThreadSafety
@@ -12,29 +12,12 @@ public class Fixture : BugTestCase
12
12
{
13
13
protected override bool AppliesTo ( Dialect . Dialect dialect )
14
14
{
15
- return ! ( dialect is Dialect . Oracle8iDialect ) ;
15
+ return ! ( dialect is Oracle8iDialect ) ;
16
16
// Oracle sometimes causes: ORA-12520: TNS:listener could not find available handler for requested type of server
17
17
// Following links bizarrely suggest it's an Oracle limitation under load:
18
18
// http://www.orafaq.com/forum/t/60019/2/ & http://www.ispirer.com/wiki/sqlways/troubleshooting-guide/oracle/import/tns_listener
19
19
}
20
20
21
- protected override void OnTearDown ( )
22
- {
23
- base . OnTearDown ( ) ;
24
-
25
- if ( ! ( Dialect is Dialect . FirebirdDialect ) )
26
- return ;
27
-
28
- // Firebird will pool each connection created during the test and will not drop the created tables
29
- // which will result in other tests failing when they try to create tables with same name
30
- // By clearing the connection pool the tables will get dropped. This is done by the following code.
31
- var fbConnectionType = ReflectHelper . TypeFromAssembly ( "FirebirdSql.Data.FirebirdClient.FbConnection" , "FirebirdSql.Data.FirebirdClient" , false ) ;
32
- var clearPool = fbConnectionType . GetMethod ( "ClearPool" ) ;
33
- var sillyConnection = Sfi . ConnectionProvider . GetConnection ( ) ;
34
- clearPool . Invoke ( null , new object [ ] { sillyConnection } ) ;
35
- Sfi . ConnectionProvider . CloseConnection ( sillyConnection ) ;
36
- }
37
-
38
21
[ Test ]
39
22
public void UsingFiltersIsThreadSafe ( )
40
23
{
Original file line number Diff line number Diff line change 14
14
using NHibernate . Hql . Ast . ANTLR ;
15
15
using NUnit . Framework . Interfaces ;
16
16
using System . Text ;
17
+ using NHibernate . Dialect ;
18
+ using NHibernate . Util ;
17
19
18
20
namespace NHibernate . Test
19
21
{
@@ -270,6 +272,26 @@ protected virtual void CreateSchema()
270
272
protected virtual void DropSchema ( )
271
273
{
272
274
new SchemaExport ( cfg ) . Drop ( OutputDdl , true ) ;
275
+
276
+ if ( Dialect is FirebirdDialect )
277
+ {
278
+ // Firebird will pool each connection created during the test and will marked as used any table
279
+ // referenced by queries. It will delays those tables drop until connections are actually closed.
280
+ // This results in other tests failing when they try to create tables with same name
281
+ // By clearing the connection pool the tables will get dropped. This is done by the following code.
282
+ // Moved from NH1908 test case, contributed by Amro El-Fakharany.
283
+ var clearConnection = Sfi . ConnectionProvider . GetConnection ( ) ;
284
+ var fbConnectionType = clearConnection . GetType ( ) ;
285
+ var clearPool = fbConnectionType . GetMethod ( "ClearPool" ) ;
286
+ try
287
+ {
288
+ clearPool . Invoke ( null , new object [ ] { clearConnection } ) ;
289
+ }
290
+ finally
291
+ {
292
+ Sfi . ConnectionProvider . CloseConnection ( clearConnection ) ;
293
+ }
294
+ }
273
295
}
274
296
275
297
protected virtual DebugSessionFactory BuildSessionFactory ( )
You can’t perform that action at this time.
0 commit comments