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 22using System . Collections . Generic ;
33using System . Linq ;
44using System . Threading ;
5- using NHibernate . Util ;
5+ using NHibernate . Dialect ;
66using NUnit . Framework ;
77
88namespace NHibernate . Test . NHSpecificTest . NH1908ThreadSafety
@@ -12,29 +12,12 @@ public class Fixture : BugTestCase
1212 {
1313 protected override bool AppliesTo ( Dialect . Dialect dialect )
1414 {
15- return ! ( dialect is Dialect . Oracle8iDialect ) ;
15+ return ! ( dialect is Oracle8iDialect ) ;
1616 // Oracle sometimes causes: ORA-12520: TNS:listener could not find available handler for requested type of server
1717 // Following links bizarrely suggest it's an Oracle limitation under load:
1818 // http://www.orafaq.com/forum/t/60019/2/ & http://www.ispirer.com/wiki/sqlways/troubleshooting-guide/oracle/import/tns_listener
1919 }
2020
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-
3821 [ Test ]
3922 public void UsingFiltersIsThreadSafe ( )
4023 {
Original file line number Diff line number Diff line change 1414using NHibernate . Hql . Ast . ANTLR ;
1515using NUnit . Framework . Interfaces ;
1616using System . Text ;
17+ using NHibernate . Dialect ;
18+ using NHibernate . Util ;
1719
1820namespace NHibernate . Test
1921{
@@ -270,6 +272,26 @@ protected virtual void CreateSchema()
270272 protected virtual void DropSchema ( )
271273 {
272274 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+ try
285+ {
286+ var fbConnectionType = clearConnection . GetType ( ) ;
287+ var clearPool = fbConnectionType . GetMethod ( "ClearPool" ) ;
288+ clearPool . Invoke ( null , new object [ ] { clearConnection } ) ;
289+ }
290+ finally
291+ {
292+ Sfi . ConnectionProvider . CloseConnection ( clearConnection ) ;
293+ }
294+ }
273295 }
274296
275297 protected virtual DebugSessionFactory BuildSessionFactory ( )
You can’t perform that action at this time.
0 commit comments