From: <aye...@us...> - 2009-03-22 17:56:22
|
Revision: 4150 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4150&view=rev Author: ayenderahien Date: 2009-03-22 17:56:16 +0000 (Sun, 22 Mar 2009) Log Message: ----------- Renaming file to match class name. Adding ignored failing test Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/FutureCriteriaFixture.cs Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/DtcFailuresFixture.cs 2009-03-22 17:56:16 UTC (rev 4150) @@ -0,0 +1,119 @@ +using System; +using System.Data; +using System.Data.SqlClient; +using System.Threading; +using System.Transactions; +using NHibernate.Criterion; +using NHibernate.Dialect; +using NHibernate.Exceptions; +using NHibernate.Impl; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.DtcFailures +{ + using System.Collections; + + [TestFixture] + public class DtcFailuresFixture : TestCase + { + + protected override IList Mappings + { + get { return new string[] { "NHSpecificTest.DtcFailures.Mappings.hbm.xml" }; } + } + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + [Test] + public void WillNotCrashOnDtcPrepareFailure() + { + var tx = new TransactionScope(); + using (var s = sessions.OpenSession()) + { + s.Save(new Person + { + CreatedAt = DateTime.MinValue // will cause SQL date failure + }); + } + + new ForceEscalationToDistributedTx(); + + tx.Complete(); + try + { + tx.Dispose(); + Assert.Fail("Expected failure"); + } + catch (AssertionException) + { + throw; + } + catch (Exception) + { + } + } + + [Test] + public void CanDeleteItemInDtc() + { + object id; + using (var tx = new TransactionScope()) + using (var s = sessions.OpenSession()) + { + id = s.Save(new Person + { + CreatedAt = DateTime.Today + }); + + new ForceEscalationToDistributedTx(); + + tx.Complete(); + } + + using (var tx = new TransactionScope()) + using (var s = sessions.OpenSession()) + { + new ForceEscalationToDistributedTx(); + + s.Delete(s.Get<Person>(id)); + + tx.Complete(); + } + + } + + public class ForceEscalationToDistributedTx : IEnlistmentNotification + { + private readonly int thread; + public ForceEscalationToDistributedTx() + { + thread = Thread.CurrentThread.ManagedThreadId; + System.Transactions.Transaction.Current.EnlistDurable(Guid.NewGuid(), this, EnlistmentOptions.None); + } + + public void Prepare(PreparingEnlistment preparingEnlistment) + { + Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); + preparingEnlistment.Prepared(); + } + + public void Commit(Enlistment enlistment) + { + enlistment.Done(); + } + + public void Rollback(Enlistment enlistment) + { + enlistment.Done(); + } + + public void InDoubt(Enlistment enlistment) + { + enlistment.Done(); + } + } + } +} Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/FutureCriteriaFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/FutureCriteriaFixture.cs 2009-03-22 14:21:03 UTC (rev 4149) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DtcFailures/FutureCriteriaFixture.cs 2009-03-22 17:56:16 UTC (rev 4150) @@ -1,90 +0,0 @@ -using System; -using System.Data; -using System.Data.SqlClient; -using System.Threading; -using System.Transactions; -using NHibernate.Criterion; -using NHibernate.Dialect; -using NHibernate.Exceptions; -using NHibernate.Impl; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.DtcFailures -{ - using System.Collections; - - [TestFixture] - public class DtcFailuresFixture : TestCase - { - - protected override IList Mappings - { - get { return new string[] { "NHSpecificTest.DtcFailures.Mappings.hbm.xml" }; } - } - - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - [Test] - public void WillNotCrashOnDtcPrepareFailure() - { - var tx = new TransactionScope(); - using (var s = sessions.OpenSession()) - { - s.Save(new Person - { - CreatedAt = DateTime.MinValue // will cause SQL date failure - }); - } - - new ForceEscalationToDistributedTx(); - - tx.Complete(); - try - { - tx.Dispose(); - Assert.Fail("Expected failure"); - } - catch (AssertionException) - { - throw; - } - catch (Exception) - { - } - } - - public class ForceEscalationToDistributedTx : IEnlistmentNotification - { - private readonly int thread; - public ForceEscalationToDistributedTx() - { - thread = Thread.CurrentThread.ManagedThreadId; - System.Transactions.Transaction.Current.EnlistDurable(Guid.NewGuid(), this, EnlistmentOptions.None); - } - - public void Prepare(PreparingEnlistment preparingEnlistment) - { - Assert.AreNotEqual(thread, Thread.CurrentThread.ManagedThreadId); - preparingEnlistment.Prepared(); - } - - public void Commit(Enlistment enlistment) - { - enlistment.Done(); - } - - public void Rollback(Enlistment enlistment) - { - enlistment.Done(); - } - - public void InDoubt(Enlistment enlistment) - { - enlistment.Done(); - } - } - } -} Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-22 14:21:03 UTC (rev 4149) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-03-22 17:56:16 UTC (rev 4150) @@ -292,7 +292,7 @@ <Compile Include="GenericTest\SetGeneric\SetGenericFixture.cs" /> <Compile Include="HQL\Animal.cs" /> <Compile Include="HQL\BaseFunctionFixture.cs" /> - <Compile Include="NHSpecificTest\DtcFailures\FutureCriteriaFixture.cs" /> + <Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" /> <Compile Include="NHSpecificTest\DtcFailures\Person.cs" /> <Compile Include="NHSpecificTest\NH1694\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1706\Domain.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |