File tree Expand file tree Collapse file tree 2 files changed +25
-19
lines changed 
NHSpecificTest/NH1908ThreadSafety Expand file tree Collapse file tree 2 files changed +25
-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{ 
@@ -269,6 +271,27 @@ protected virtual void CreateSchema()
269271
270272		protected  virtual  void  DropSchema ( ) 
271273		{ 
274+ 			if  ( Dialect  is  FirebirdDialect ) 
275+ 			{ 
276+ 				// Firebird will pool each connection created during the test and will marked as used any table 
277+ 				// referenced by queries. It will at best delays those tables drop until connections are actually 
278+ 				// closed, or immediately fail dropping them. 
279+ 				// This results in other tests failing when they try to create tables with same name. 
280+ 				// By clearing the connection pool the tables will get dropped. This is done by the following code. 
281+ 				// Moved from NH1908 test case, contributed by Amro El-Fakharany. 
282+ 				var  clearConnection  =  Sfi . ConnectionProvider . GetConnection ( ) ; 
283+ 				try 
284+ 				{ 
285+ 					var  fbConnectionType  =  clearConnection . GetType ( ) ; 
286+ 					var  clearPool  =  fbConnectionType . GetMethod ( "ClearPool" ) ; 
287+ 					clearPool . Invoke ( null ,  new  object [ ]  { clearConnection } ) ; 
288+ 				} 
289+ 				finally 
290+ 				{ 
291+ 					Sfi . ConnectionProvider . CloseConnection ( clearConnection ) ; 
292+ 				} 
293+ 			} 
294+ 
272295			new  SchemaExport ( cfg ) . Drop ( OutputDdl ,  true ) ; 
273296		} 
274297
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments