Skip to content

Commit c6b44f8

Browse files
fredericDelaportehazzik
authored andcommitted
Workaround for Firebird not immediately dropping objects added to more test cases.
1 parent 024cde5 commit c6b44f8

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,7 @@ public void Basic_CRUD_should_work()
8585
Assert.That(p, Is.Null);
8686
}
8787

88-
if (((ISessionFactoryImplementor) sf).ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
89-
{
90-
// Firebird will pool each connection created during the test and will marked as used any table
91-
// referenced by queries. It will at best delays those tables drop until connections are actually
92-
// closed, or immediately fail dropping them.
93-
// This results in other tests failing when they try to create tables with same name.
94-
// By clearing the connection pool the tables will get dropped. This is done by the following code.
95-
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
96-
fbDriver.ClearPool(null);
97-
}
98-
99-
export.Drop(true, true);
88+
TestCase.DropSchema(true, export, (ISessionFactoryImplementor)sf);
10089
}
10190
}
102-
}
91+
}

src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using NHibernate.Connection;
99
using NHibernate.Tool.hbm2ddl;
1010
using NUnit.Framework;
11+
using NHibernate.Engine;
1112

1213
namespace NHibernate.Test.Linq
1314
{
@@ -96,7 +97,8 @@ public void DestroyNorthwindDb()
9697
}
9798
else
9899
{
99-
new SchemaExport(configuration).Drop(false, true);
100+
using (var sf = configuration.BuildSessionFactory())
101+
TestCase.DropSchema(false, new SchemaExport(configuration), (ISessionFactoryImplementor)sf);
100102
}
101103
}
102104

@@ -143,4 +145,4 @@ private void CreateTestData(ISessionFactory sessionFactory)
143145
}
144146
}
145147
}
146-
}
148+
}

src/NHibernate.Test/NHSpecificTest/NH1710/Fixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void NotIgnorePrecisionScaleInSchemaExport()
3838
var script = new StringBuilder();
3939
new SchemaExport(cfg).Create(sl => script.AppendLine(sl), true);
4040
Assert.That(script.ToString(), Does.Contain(expectedExportString));
41-
new SchemaExport(cfg).Drop(false, true);
41+
TestCase.DropSchema(false, new SchemaExport(cfg), factory);
4242
}
4343

4444
private Dialect.Dialect GetDialect()

src/NHibernate.Test/NHSpecificTest/NH4004/Fixture.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using NHibernate.Cfg.MappingSchema;
33
using NHibernate.Dialect;
44
using NHibernate.Mapping.ByCode;
5-
using NHibernate.Tool.hbm2ddl;
65
using NUnit.Framework;
76

87
namespace NHibernate.Test.NHSpecificTest.NH4004
@@ -45,7 +44,7 @@ protected override bool CheckDatabaseWasCleaned()
4544
[Test]
4645
public void SequenceShallBeDropped()
4746
{
48-
new SchemaExport(cfg).Drop(true, true);
47+
DropSchema();
4948

5049
using (var connection = Sfi.ConnectionProvider.GetConnection())
5150
{
@@ -58,4 +57,4 @@ public void SequenceShallBeDropped()
5857
}
5958
}
6059
}
61-
}
60+
}

src/NHibernate.Test/TestCase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ protected virtual void CreateSchema()
276276

277277
protected virtual void DropSchema()
278278
{
279-
if (Sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
279+
DropSchema(OutputDdl, new SchemaExport(cfg), Sfi);
280+
}
281+
282+
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi)
283+
{
284+
if (sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
280285
{
281286
// Firebird will pool each connection created during the test and will marked as used any table
282287
// referenced by queries. It will at best delays those tables drop until connections are actually
@@ -287,7 +292,7 @@ protected virtual void DropSchema()
287292
fbDriver.ClearPool(null);
288293
}
289294

290-
new SchemaExport(cfg).Drop(OutputDdl, true);
295+
export.Drop(useStdOut, true);
291296
}
292297

293298
protected virtual DebugSessionFactory BuildSessionFactory()

src/NHibernate.Test/Tools/hbm2ddl/SchemaMetadataUpdaterTest/SchemaMetadataUpdaterFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public void CanWorkWithAutoQuoteTableAndColumnsAtStratup()
248248
t.Commit();
249249
}
250250

251-
new SchemaExport(configuration).Drop(false, true);
251+
TestCase.DropSchema(false, new SchemaExport(configuration), (ISessionFactoryImplementor)sf);
252252
}
253253

254254
[Test]
@@ -285,4 +285,4 @@ public void WhenConfiguredOnlyExplicitAutoQuote()
285285
Assert.That(!GetColumnByName(culs, "Name").IsQuoted);
286286
}
287287
}
288-
}
288+
}

0 commit comments

Comments
 (0)