reanimated NHibernate.Integration.Tests

This commit is contained in:
eeichinger
2008-12-23 23:02:54 +00:00
parent 044e8af105
commit 9608cd67da
17 changed files with 367 additions and 89 deletions

View File

@@ -0,0 +1,99 @@
create database Credits
GO
CREATE TABLE [Credits](
[CreditID] [int] IDENTITY NOT NULL,
[CreditAmount] [float] NOT NULL,
CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
(
[CreditID] ASC
)
)
go
create database Debits
GO
CREATE TABLE [Debits](
[DebitID] [int] IDENTITY NOT NULL,
[DebitAmount] [float] NOT NULL,
CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
(
[DebitID] ASC
) ON [PRIMARY]
)
GO
create database CreditsAndDebits
GO
CREATE TABLE [Debits](
[DebitID] [int] IDENTITY NOT NULL,
[DebitAmount] [float] NOT NULL,
CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
(
[DebitID] ASC
) ON [PRIMARY]
)
CREATE TABLE [Credits](
[CreditID] [int] IDENTITY NOT NULL,
[CreditAmount] [float] NOT NULL,
CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
(
[CreditID] ASC
)
)
GO
create database Spring
GO
CREATE TABLE [Debits](
[DebitID] [int] IDENTITY NOT NULL,
[DebitAmount] [float] NOT NULL,
CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
(
[DebitID] ASC
) ON [PRIMARY]
)
CREATE TABLE [Credits](
[CreditID] [int] IDENTITY NOT NULL,
[CreditAmount] [float] NOT NULL,
CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
(
[CreditID] ASC
)
)
CREATE TABLE [dbo].[TestObjects](
[TestObjectNo] [int] IDENTITY(1,1) NOT NULL,
[Age] [int] NOT NULL,
[Name] [nvarchar](1024) NULL,
CONSTRAINT [TestObjectNo] PRIMARY KEY CLUSTERED
(
[TestObjectNo] ASC
)
)
create database Spring2
GO
CREATE TABLE [Debits](
[DebitID] [int] IDENTITY NOT NULL,
[DebitAmount] [float] NOT NULL,
CONSTRAINT [PK_DebitID] PRIMARY KEY CLUSTERED
(
[DebitID] ASC
) ON [PRIMARY]
)
CREATE TABLE [Credits](
[CreditID] [int] IDENTITY NOT NULL,
[CreditAmount] [float] NOT NULL,
CONSTRAINT [PK_CreditID] PRIMARY KEY CLUSTERED
(
[CreditID] ASC
)
)
CREATE TABLE [dbo].[TestObjects](
[TestObjectNo] [int] IDENTITY(1,1) NOT NULL,
[Age] [int] NOT NULL,
[Name] [nvarchar](1024) NULL,
CONSTRAINT [TestObjectNo] PRIMARY KEY CLUSTERED
(
[TestObjectNo] ASC
)
)

View File

@@ -0,0 +1,127 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F04753EF-7A1B-4837-AB63-8C0821E8155D}"
ProjectSection(SolutionItems) = preProject
Spring.build = Spring.build
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.2008", "..\..\src\Spring\Spring.Core\Spring.Core.2008.csproj", "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Aop.2008", "..\..\src\Spring\Spring.Aop\Spring.Aop.2008.csproj", "{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.2008", "..\..\src\Spring\Spring.Data\Spring.Data.2008.csproj", "{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.Tests.2008", "..\..\test\Spring\Spring.Data.Tests\Spring.Data.Tests.2008.csproj", "{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Tests.2008", "..\..\test\Spring\Spring.Core.Tests\Spring.Core.Tests.2008.csproj", "{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate.2008", "..\..\src\Spring\Spring.Data.NHibernate\Spring.Data.NHibernate.2008.csproj", "{130E1609-45A7-4F65-B112-105F2DD3E2CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate.Tests.2008", "..\..\test\Spring\Spring.Data.NHibernate.Tests\Spring.Data.NHibernate.Tests.2008.csproj", "{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Data.NHibernate.Integration.Tests.2008", "..\..\test\Spring\Spring.Data.NHibernate.Integration.Tests\Spring.Data.NHibernate.Integration.Tests.2008.csproj", "{4A07E150-ED90-407C-8CAD-4760444DDFD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Release|.NET = Release|.NET
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|.NET.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|.NET.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|.NET.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|.NET.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Any CPU.Build.0 = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|.NET.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|.NET.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|.NET.ActiveCfg = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|.NET.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Any CPU.Build.0 = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|.NET.ActiveCfg = Debug|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|.NET.ActiveCfg = Release|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Any CPU.Build.0 = Release|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|.NET.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|.NET.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Debug|.NET.ActiveCfg = Debug|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Release|.NET.ActiveCfg = Release|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Release|Any CPU.Build.0 = Release|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{130E1609-45A7-4F65-B112-105F2DD3E2CE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Debug|.NET.ActiveCfg = Debug|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Release|.NET.ActiveCfg = Release|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Release|Any CPU.Build.0 = Release|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Debug|.NET.ActiveCfg = Debug|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|.NET.ActiveCfg = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Any CPU.Build.0 = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{4A07E150-ED90-407C-8CAD-4760444DDFD9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
NAntAddinLastFileName = Spring.build
EndGlobalSection
EndGlobal

View File

@@ -412,8 +412,8 @@ namespace Spring.Data.NHibernate.Support
{
// single session mode
if (isLogDebugEnabled) log.Debug("Closing single Hibernate Session in SessionScope");
TransactionSynchronizationManager.UnbindResource(SessionFactory);
LazySessionHolder.Current.Close();
LazySessionHolder holder = (LazySessionHolder)TransactionSynchronizationManager.UnbindResource(SessionFactory);
holder.Close();
}
else
{
@@ -448,8 +448,6 @@ namespace Spring.Data.NHibernate.Support
/// </remarks>
private class LazySessionHolder : SessionHolder
{
private static readonly string ThreadDataSlotKey = UniqueKey.GetTypeScopedString(typeof(LazySessionHolder), "Current");
private readonly ILog log = LogManager.GetLogger(typeof(LazySessionHolder));
private SessionScope owner;
private ISession session;
@@ -461,16 +459,6 @@ namespace Spring.Data.NHibernate.Support
{
if (log.IsDebugEnabled) log.Debug("Created LazySessionHolder");
this.owner = owner;
Current = this;
}
/// <summary>
/// Gets or sets the LazySessionHolder instance for the current request
/// </summary>
public static LazySessionHolder Current
{
get { return (LazySessionHolder) LogicalThreadContext.GetData(ThreadDataSlotKey); }
set { LogicalThreadContext.SetData(ThreadDataSlotKey, value); }
}
/// <summary>
@@ -492,7 +480,6 @@ namespace Spring.Data.NHibernate.Support
public void Close()
{
owner = null;
Current = null;
if (session != null)
{
ISession tmpSession = session;

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{130E1609-45A7-4F65-B112-105F2DD3E2CE}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -93,10 +93,6 @@
<Project>{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}</Project>
<Name>Spring.Data.2008</Name>
</ProjectReference>
<ProjectReference Include="..\Spring.Web\Spring.Web.2008.csproj">
<Project>{BA4789EB-281A-48EA-8763-28B9F0596A18}</Project>
<Name>Spring.Web.2008</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -80,9 +80,9 @@ namespace Spring.Dao.Attributes
}
}
/// <summary>
/// Callback that supplies the owning factory to an object instance.
/// </summary>
public IObjectFactory ObjectFactory
{
set

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Spring.Data.NHibernate.Credit, Spring.Data.NHibernate.Integration.Tests"
table="Credits" lazy="false">
<id name="CreditID" column="CreditID" type="Int32">

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Spring.Data.NHibernate.Debit, Spring.Data.NHibernate.Integration.Tests"
table="Debits" lazy="false">
<id name="DebitID" column="DebitID" type="Int32">

View File

@@ -28,6 +28,7 @@ using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using Spring.Data.Common;
using Spring.Data.NHibernate.Support;
using Spring.Data.Support;
using Spring.Transaction;
using Spring.Transaction.Support;
@@ -36,41 +37,41 @@ using Spring.Transaction.Support;
namespace Spring.Data.NHibernate
{
/// <summary>
/// Use of Hibernate Template against database.
/// </summary>
/// <author>Mark Pollack (.NET)</author>
[TestFixture]
public class MultipleDbTests
{
#region Fields
/// <summary>
/// Use of Hibernate Template against database.
/// </summary>
/// <author>Mark Pollack (.NET)</author>
[TestFixture]
public class MultipleDbTests
{
#region Fields
private IApplicationContext ctx;
#endregion
#region Constants
#endregion
/// <summary>
/// The shared <see cref="log4net.ILog"/> instance for this class (and derived classes).
/// </summary>
protected static readonly ILog log =
LogManager.GetLogger(typeof (TemplateTests));
#endregion
#region Constants
#region Constructor (s)
/// <summary>
/// <summary>
/// The shared <see cref="log4net.ILog"/> instance for this class (and derived classes).
/// </summary>
protected static readonly ILog log =
LogManager.GetLogger(typeof(TemplateTests));
#endregion
#region Constructor (s)
/// <summary>
/// Initializes a new instance of the <see cref="MultipleDbTests"/> class.
/// </summary>
public MultipleDbTests()
{
{
}
}
#endregion
#endregion
[SetUp]
public void SetUp()
@@ -83,7 +84,7 @@ namespace Spring.Data.NHibernate
#else
ctx = new XmlApplicationContext("assembly://Spring.Data.NHibernate.Integration.Tests/Spring.Data.NHibernate/MultipleDbTests.xml");
#endif
}
[Test]
@@ -92,15 +93,27 @@ namespace Spring.Data.NHibernate
float transferAmount = 114;
IAccountManager mgr = null;
Assert.IsNotNull(ctx, "Application Context is null");
mgr = ctx["accountManager"] as IAccountManager;
Assert.IsNotNull(mgr, "accountManager not of expected type. Type = " + ctx["accountManager"].GetType().ToString());
mgr.DoTransfer(transferAmount, transferAmount);
Assert.IsNotNull(ctx, "Application Context is null");
mgr = ctx["accountManager"] as IAccountManager;
Assert.IsNotNull(mgr, "accountManager not of expected type. Type = " + ctx["accountManager"].GetType().ToString());
mgr.DoTransfer(transferAmount, transferAmount);
}
[Test]
public void MultipleDBAccessUsingMultipleSessionScopes()
{
SessionScope scope1 = new SessionScope( (ISessionFactory) ctx["SessionFactory1"], false );
SessionScope scope2 = new SessionScope( (ISessionFactory) ctx["SessionFactory2"], false );
}
scope1.Open();
scope2.Open();
// do something
MultipleDBAccess();
scope1.Close();
scope2.Close();
}
}
}

View File

@@ -4,13 +4,13 @@
<db:provider id="DbProvider1"
provider="SqlServer-1.1"
connectionString="Data Source=(local);Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>
connectionString="Data Source=MARKT60\SQL2005;Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/>
<db:provider id="DbProvider2"
provider="SqlServer-1.1"
connectionString="Data Source=(local);Database=Spring2;User ID=springqa2;Password=springqa2;Trusted_Connection=False"/>
connectionString="Data Source=MARKT60\SQL2005;Database=Spring2;User ID=springqa2;Password=springqa2;Trusted_Connection=False"/>
<object id="SessionFactory1" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
<object id="SessionFactory1" type="Spring.Data.NHibernate.LocalSessionFactoryObject">
<property name="DbProvider" ref="DbProvider1"/>
<property name="MappingAssemblies">
@@ -18,7 +18,7 @@
<value>Spring.Data.NHibernate.Integration.Tests</value>
</list>
</property>
<property name="HibernateProperties">
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider"
@@ -35,7 +35,7 @@
</object>
<object id="SessionFactory2" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
<object id="SessionFactory2" type="Spring.Data.NHibernate.LocalSessionFactoryObject">
<property name="DbProvider" ref="DbProvider2"/>
<property name="MappingAssemblies">
@@ -62,20 +62,20 @@
<object id="transactionManager"
type="Spring.Data.TxScopeTransactionManager, Spring.Data">
type="Spring.Data.Core.TxScopeTransactionManager, Spring.Data">
</object>
<object id="AccountCreditDao" type="Spring.Data.NHibernate.AccountCreditDao, Spring.Data.NHibernate.Integration.Tests">
<object id="AccountCreditDao" type="Spring.Data.NHibernate.AccountCreditDao">
<property name="SessionFactory" ref="SessionFactory1"/>
</object>
<object id="AccountDebitDao" type="Spring.Data.NHibernate.AccountDebitDao, Spring.Data.NHibernate.Integration.Tests">
<object id="AccountDebitDao" type="Spring.Data.NHibernate.AccountDebitDao">
<property name="SessionFactory" ref="SessionFactory2"/>
</object>
<!-- The DAO object that performs multiple data access operations -->
<object id="accountManagerTarget"
type="Spring.Data.NHibernate.AccountManager, Spring.Data.NHibernate.Integration.Tests">
type="Spring.Data.NHibernate.AccountManager">
<property name="AccountCreditDao" ref="AccountCreditDao"/>
<property name="AccountDebitDao" ref="AccountDebitDao"/>

View File

@@ -7,7 +7,7 @@
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=CreditsAndDebits;User ID=springqa;Password=springqa"/>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject">
<property name="DbProvider" ref="DbProvider"/>
@@ -67,7 +67,7 @@
</object>
<object id="hibernateTransactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
type="Spring.Data.NHibernate.HibernateTransactionManager">
<!-- Comment out DbProvider if you want to have the tx mgr infer the DbProvider from
the session factory. -->
<!-- Set the DbProvider explicitly if you would like to have ADO.NET and NHibernate

View File

@@ -21,6 +21,7 @@
#region Imports
using System;
using System.Data;
using log4net;
using log4net.Config;
using NHibernate;
@@ -59,6 +60,9 @@ namespace Spring.Data.NHibernate
protected static readonly ILog log =
LogManager.GetLogger(typeof (TemplateTests));
// force Spring.Data.NHibernate to be preloaded by runtime
private Type TLocalSessionFactoryObject = typeof (LocalSessionFactoryObject);
#endregion
#region Constructor (s)
@@ -86,9 +90,29 @@ namespace Spring.Data.NHibernate
#endif
dbProvider = ctx["DbProvider"] as IDbProvider;
transactionManager = ctx["hibernateTransactionManager"] as IPlatformTransactionManager;
CleanupDatabase(dbProvider.CreateConnection());
}
private static void CleanupDatabase(IDbConnection conn)
{
conn.Open();
using(conn)
{
ExecuteSql(conn, "delete credits");
ExecuteSql(conn, "delete debits");
ExecuteSql(conn, "delete TestObjects");
ExecuteSql(conn, "insert TestObjects(Age,Name) Values(5, 'Gabriel')");
}
}
private static void ExecuteSql(IDbConnection conn, string sql)
{
IDbCommand cmd;
cmd = conn.CreateCommand();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
[Test]
public void ExceptionTranslator()
{
@@ -102,6 +126,7 @@ namespace Spring.Data.NHibernate
}
[Test]
[Ignore("what's the purpose of this test?")] // TODO: what's the purpose of this test?
public void FallbackExceptionTranslator()
{
//ISessionFactory sessionFactory = ctx["SessionFactory"] as ISessionFactory;

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Spring.Data.NHibernate.TestObject, Spring.Data.NHibernate.Integration.Tests" table="TestObjects">
<id name="ObjectNumber" column="TestObjectNo" type="Int32">
<generator class="identity" />

View File

@@ -25,7 +25,7 @@
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject">
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingResources">
<list>
@@ -71,7 +71,7 @@
-->
<object id="hibernateTransactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
type="Spring.Data.NHibernate.HibernateTransactionManager">
<property name="DbProvider" ref="DbProvider"/>
<property name="sessionFactory" ref="SessionFactory"/>
@@ -85,7 +85,7 @@
type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
<property name="PlatformTransactionManager" ref="hibernateTransactionManager"/>
<property name="Target">
<object type="Spring.Data.NHibernate.NHTestObjectDao, Spring.Data.NHibernate.Integration.Tests">
<object type="Spring.Data.NHibernate.NHTestObjectDao">
<property name="SessionFactory" ref="SessionFactory"/>
</object>
</property>

View File

@@ -20,7 +20,7 @@
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;User ID=springqa; Password=springqa"/>
-->
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate12">
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject">
<!-- TODO Provide dedicated NHibernate Schema -->
<property name="DbProvider" ref="DbProvider"/>
<property name="MappingResources">
@@ -58,16 +58,16 @@
</object>
<object id="nativeNHTestObjectDao" type="Spring.Data.NHibernate.NativeNHTestObjectDao, Spring.Data.NHibernate.Integration.Tests">
<object id="nativeNHTestObjectDao" type="Spring.Data.NHibernate.NativeNHTestObjectDao">
<property name="SessionFactory" ref="SessionFactory"/>
</object>
<object id="NHTestObjectDao" type="Spring.Data.NHibernate.NHTestObjectDao, Spring.Data.NHibernate.Integration.Tests">
<object id="NHTestObjectDao" type="Spring.Data.NHibernate.NHTestObjectDao">
<property name="SessionFactory" ref="SessionFactory"/>
</object>
<object id="hibernateTransactionManager"
type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate12">
type="Spring.Data.NHibernate.HibernateTransactionManager">
<property name="DbProvider" ref="DbProvider"/>
<property name="sessionFactory" ref="SessionFactory"/>
@@ -76,13 +76,31 @@
<!-- Transactional Proxy for TestObjectDao using transaction attributes -->
<object id="testObjectDaoViaTxAttributes"
type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
<property name="PlatformTransactionManager" ref="hibernateTransactionManager"/>
<property name="Target">
<object type="Spring.Data.NHibernate.NHTestObjectDao">
<property name="SessionFactory" ref="SessionFactory"/>
</object>
</property>
<property name="ProxyInterfaces" value="Spring.Data.NHibernate.ITestObjectDao"/>
<property name="TransactionAttributeSource">
<object type="Spring.Transaction.Interceptor.AttributesTransactionAttributeSource" />
</property>
</object>
<!-- Transactional Proxy for TestObjectDao using the TransactionProxyFactory -->
<object id="testObjectDaoTransProxy"
type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
<property name="PlatformTransactionManager" ref="hibernateTransactionManager"/>
<property name="Target">
<object type="Spring.Data.NHibernate.NHTestObjectDao, Spring.Data.NHibernate.Integration.Tests">
<object type="Spring.Data.NHibernate.NHTestObjectDao">
<property name="SessionFactory" ref="SessionFactory"/>
</object>
</property>

View File

@@ -0,0 +1,10 @@

CREATE TABLE [TestObjects] (
[TestObjectNo] int IDENTITY NOT NULL,
[Age] int NOT NULL,
[Name] nvarchar(1024),
CONSTRAINT [TestObjectNo] PRIMARY KEY CLUSTERED
(
[TestObjectNo] ASC
)
)

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4A07E150-ED90-407C-8CAD-4760444DDFD9}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -31,7 +31,7 @@
<ItemGroup>
<Reference Include="Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\NHibernate12\net\2.0\Castle.DynamicProxy.dll</HintPath>
<HintPath>..\..\..\lib\NHibernate10\net\2.0\Castle.DynamicProxy.dll</HintPath>
</Reference>
<Reference Include="Common.Logging, Version=1.0.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
<SpecificVersion>False</SpecificVersion>
@@ -39,15 +39,15 @@
</Reference>
<Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\NHibernate12\net\2.0\Iesi.Collections.dll</HintPath>
<HintPath>..\..\..\lib\NHibernate10\net\2.0\Iesi.Collections.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\NHibernate12\net\2.0\log4net.dll</HintPath>
<HintPath>..\..\..\lib\NHibernate10\net\2.0\log4net.dll</HintPath>
</Reference>
<Reference Include="NHibernate, Version=1.2.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
<Reference Include="NHibernate, Version=1.0.4.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\NHibernate12\net\2.0\NHibernate.dll</HintPath>
<HintPath>..\..\..\lib\NHibernate10\net\2.0\NHibernate.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.4.1.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
<SpecificVersion>False</SpecificVersion>
@@ -88,7 +88,7 @@
<EmbeddedResource Include="Data\NHibernate\Credit.hbm.xml" />
<Content Include="Data\NHibernate\creditdebit.sql" />
<EmbeddedResource Include="Data\NHibernate\Debit.hbm.xml" />
<Content Include="Data\NHibernate\MultipleDbTests.xml" />
<EmbeddedResource Include="Data\NHibernate\MultipleDbTests.xml" />
<EmbeddedResource Include="Data\NHibernate\NHDAOTests.xml" />
<EmbeddedResource Include="Data\NHibernate\templateTests.xml" />
<EmbeddedResource Include="Data\NHibernate\TestObject.hbm.xml" />
@@ -102,9 +102,9 @@
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
<Name>Spring.Core.2008</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Data.NHibernate12\Spring.Data.NHibernate12.2008.csproj">
<Project>{90F2D070-6F98-4926-A626-BD7A6071D6D9}</Project>
<Name>Spring.Data.NHibernate12.2008</Name>
<ProjectReference Include="..\..\..\src\Spring\Spring.Data.NHibernate\Spring.Data.NHibernate.2008.csproj">
<Project>{130E1609-45A7-4F65-B112-105F2DD3E2CE}</Project>
<Name>Spring.Data.NHibernate.2008</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\src\Spring\Spring.Data\Spring.Data.2008.csproj">
<Project>{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}</Project>
@@ -112,6 +112,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Data\NHibernate\testObject.sql" />
<None Include="Spring.Data.NHibernate.Integration.Tests.dll.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
@@ -124,7 +125,7 @@
-->
<PropertyGroup>
<PostBuildEvent>echo "Copying .xml files for tests"
xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2008\Spring.Data.NHibernate.Integration.Tests\$(ConfigurationName)\ /y /s /q /d
rem xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2008\Spring.Data.NHibernate.Integration.Tests\$(ConfigurationName)\ /y /s /q /d
xcopy "$(ProjectDir)$(TargetFileName).config" ..\..\..\..\build\VS.Net.2008\Spring.Data.NHibernate.Integration.Tests\$(ConfigurationName)\ /y /s /q</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -4,9 +4,11 @@
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<common>
<logging>