Added custom TX Scope Manager and test fixture that shows original error.

This commit is contained in:
Yerko Nauls
2015-03-08 15:46:17 -04:00
committed by Yerko Nauls
parent 50c4683db1
commit 0907b9a796
12 changed files with 1331 additions and 60 deletions

View File

@@ -2,8 +2,14 @@
{
public interface IService1
{
void ServiceMethod1();
void ServiceMethodWithNotSupported1();
void ServiceMethod2();
void ServiceMethodWithNotSupported2();
void ServiceMethodWithNotSupported3();
void ServiceMethodWithNotSupported4();
void ServiceMethodWithRequired();
}
}

View File

@@ -2,8 +2,8 @@
{
public interface IService2
{
void ServiceMethod1();
void ServiceMethodWithNotSupported();
void ServiceMethod2();
void ServiceMethodWithRequiresNew();
}
}

View File

@@ -13,13 +13,31 @@ namespace Spring.SessionFactoryImplError.Tests
#endregion
[Transaction.Interceptor.Transaction(TransactionPropagation.NotSupported)]
public virtual void ServiceMethod1()
public virtual void ServiceMethodWithNotSupported1()
{
ServiceMethod2();
ServiceMethodWithNotSupported2();
}
[Transaction.Interceptor.Transaction(TransactionPropagation.NotSupported)]
public virtual void ServiceMethod2()
public virtual void ServiceMethodWithNotSupported2()
{
// do some stuff
}
[Transaction.Interceptor.Transaction(TransactionPropagation.NotSupported)]
public virtual void ServiceMethodWithNotSupported3()
{
ServiceMethodWithNotSupported4();
}
[Transaction.Interceptor.Transaction(TransactionPropagation.NotSupported)]
public virtual void ServiceMethodWithNotSupported4()
{
ServiceMethodWithRequired();
}
[Transaction.Interceptor.Transaction(TransactionPropagation.Required)]
public virtual void ServiceMethodWithRequired()
{
// do some stuff
}

View File

@@ -13,13 +13,13 @@ namespace Spring.SessionFactoryImplError.Tests
#endregion
[Transaction.Interceptor.Transaction(TransactionPropagation.NotSupported)]
public virtual void ServiceMethod1()
public virtual void ServiceMethodWithNotSupported()
{
ServiceMethod2();
ServiceMethodWithRequiresNew();
}
[Transaction.Interceptor.Transaction(TransactionPropagation.RequiresNew)]
public virtual void ServiceMethod2()
public virtual void ServiceMethodWithRequiresNew()
{
// do stuff
}

View File

@@ -8,11 +8,6 @@
<property name="TemplateFlushMode" value="Auto" />
<property name="CacheQueries" value="true" />
</object>
<object id="Spring.Transaction.IPlatformTransactionManager" type="Spring.Data.NHibernate.HibernateTxScopeTransactionManager, Spring.Data.NHibernate4">
<property name="DbProvider" ref="ActiveDbProvider"/>
<property name="SessionFactory" ref="Spring.Data.NHibernate.LocalSessionFactoryObject"/>
</object>
<tx:advice id="transactionAdvice" transaction-manager="Spring.Transaction.IPlatformTransactionManager" />

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns='http://www.springframework.net' xmlns:db="http://www.springframework.net/database" xmlns:tx="http://www.springframework.net/tx" xmlns:aop="http://www.springframework.net/aop">
<object id="Spring.Transaction.IPlatformTransactionManager" type="Spring.SessionFactoryImplError.Tests.CustomSpring132HibernateTxScopeTransactionManager, Spring.SessionFactoryImplError.Tests">
<property name="DbProvider" ref="ActiveDbProvider"/>
<property name="SessionFactory" ref="Spring.Data.NHibernate.LocalSessionFactoryObject"/>
</object>
</objects>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns='http://www.springframework.net' xmlns:db="http://www.springframework.net/database" xmlns:tx="http://www.springframework.net/tx" xmlns:aop="http://www.springframework.net/aop">
<object id="Spring.Transaction.IPlatformTransactionManager" type="Spring.Data.NHibernate.HibernateTxScopeTransactionManager, Spring.Data.NHibernate4">
<property name="DbProvider" ref="ActiveDbProvider"/>
<property name="SessionFactory" ref="Spring.Data.NHibernate.LocalSessionFactoryObject"/>
</object>
</objects>

View File

@@ -47,6 +47,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -55,10 +56,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Container.cs" />
<Compile Include="TestUsingCustomHibernateTxScopeTransactionManager.cs" />
<Compile Include="CustomSpring132HibernateTxScopeTransactionManager.cs" />
<Compile Include="IContainer.cs" />
<Compile Include="IService1.cs" />
<Compile Include="IService2.cs" />
<Compile Include="TestFixture.cs" />
<Compile Include="TestUsingHibernateTxScopeTransactionManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service1.cs" />
<Compile Include="Service2.cs" />
@@ -95,6 +98,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="CreateTable.sql" />
<EmbeddedResource Include="Spring.CustomHibernateTxScopeTransactionManager.xml" />
<EmbeddedResource Include="Spring.HibernateTxScopeTransactionManager.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -1,44 +0,0 @@
using NUnit.Framework;
using Spring.Data.NHibernate.Generic;
using Spring.Testing.NUnit;
namespace Spring.SessionFactoryImplError.Tests
{
[TestFixture]
public class TestFixture : AbstractTransactionalSpringContextTests
{
#region DI
public HibernateTemplate HibernateTemplate { get; set; }
public IService1 Service1 { get; set; }
public IService2 Service2 { get; set; }
#endregion
protected override string[] ConfigLocations
{
get
{
return new[]
{
"config://spring/objects",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.Configuration.xml",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.NHibernate.xml"
};
}
}
[Test(Description = "This is failing test case in my unit test, Not Supported -> Not Supported")]
public void TestSuspendTransactionOnNotSupported()
{
Service1.ServiceMethod1();
}
[Test(Description = "This is also failing, Not Supported -> Requires New")]
public void TestSuspendTransactionOnRequiresNew()
{
Service2.ServiceMethod1();
}
}
}

View File

@@ -0,0 +1,50 @@
using NUnit.Framework;
using Spring.Data.NHibernate.Generic;
using Spring.Testing.NUnit;
namespace Spring.SessionFactoryImplError.Tests
{
[TestFixture]
public class TestUsingCustomHibernateTxScopeTransactionManager : AbstractTransactionalSpringContextTests
{
#region DI
public HibernateTemplate HibernateTemplate { get; set; }
public IService1 Service1 { get; set; }
public IService2 Service2 { get; set; }
#endregion
protected override string[] ConfigLocations
{
get
{
return new[]
{
"config://spring/objects",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.Configuration.xml",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.NHibernate.xml",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.CustomHibernateTxScopeTransactionManager.xml"
};
}
}
[Test(Description = "This is failing test case in my unit test with original NH TX Scope Manager, but not Custom TX Scope Manager, Not Supported -> Not Supported")]
public void TestSuspendTransactionOnNotSupported()
{
Service1.ServiceMethodWithNotSupported1();
}
[Test(Description = "This is also failing with NH TX Scope manager, but nto with Custom TX Scope Manager, Not Supported -> Requires New")]
public void TestSuspendTransactionOnNotSupportedWithNestedRequiresNew()
{
Service2.ServiceMethodWithNotSupported();
}
[Test(Description = "This is failing test case in my unit test with Custom TX Scope Manager (this is the original bug reported), Not Supported -> Not Supported -> Required")]
public void TestSuspendTransactionOnNotSupportedWithNestedRequired()
{
Service1.ServiceMethodWithNotSupported3();
}
}
}

View File

@@ -0,0 +1,51 @@
using NUnit.Framework;
using Spring.Data.NHibernate.Generic;
using Spring.Testing.NUnit;
namespace Spring.SessionFactoryImplError.Tests
{
[TestFixture]
public class TestUsingHibernateTxScopeTransactionManager : AbstractTransactionalSpringContextTests
{
#region DI
public HibernateTemplate HibernateTemplate { get; set; }
public IService1 Service1 { get; set; }
public IService2 Service2 { get; set; }
#endregion
protected override string[] ConfigLocations
{
get
{
return new[]
{
"config://spring/objects",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.Configuration.xml",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.NHibernate.xml",
"assembly://Spring.SessionFactoryImplError.Tests/Spring.SessionFactoryImplError.Tests/Spring.HibernateTxScopeTransactionManager.xml"
};
}
}
[Test(Description = "This is failing test case in my unit test with original NH TX Scope Manager, but not Custom TX Scope Manager, Not Supported -> Not Supported")]
public void TestSuspendTransactionOnNotSupported()
{
Service1.ServiceMethodWithNotSupported1();
}
[Test(Description = "This is also failing with NH TX Scope manager, but not with Custom TX Scope Manager, Not Supported -> Requires New")]
public void TestSuspendTransactionOnNotSupportedWithNestedRequiresNew()
{
Service2.ServiceMethodWithNotSupported();
}
[Test(Description = "This is failing test case in my unit test with Custom TX Scope Manager (this is the original bug reported), Not Supported -> Not Supported -> Required")]
public void TestSuspendTransactionOnNotSupportedWithNestedRequired()
{
Service1.ServiceMethodWithNotSupported3();
}
}
}