Initial import!
This commit is contained in:
5
test/Spring/Spring.Data.NHibernate.Tests/AssemblyInfo.cs
Normal file
5
test/Spring/Spring.Data.NHibernate.Tests/AssemblyInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyTitle("Spring.Data.NHibernate Integration Tests")]
|
||||
[assembly: AssemblyDescription("Integration tests for Spring.Data.NHibernate assembly")]
|
||||
@@ -0,0 +1,83 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using NUnit.Framework;
|
||||
using Spring.Aop.Framework;
|
||||
using Spring.Aop.Framework.DynamicProxy;
|
||||
using Spring.Aop.Support;
|
||||
using Spring.Context;
|
||||
using Spring.Context.Support;
|
||||
using Spring.Transaction;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate.Config
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains tests for
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <version>$Id: AopConfiguration.cs,v 1.2 2007/08/01 17:51:58 markpollack Exp $</version>
|
||||
[TestFixture]
|
||||
public class AopConfiguration
|
||||
{
|
||||
private IApplicationContext ctx;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
ctx =
|
||||
new XmlApplicationContext("assembly://Spring.Data.NHibernate.Tests/Spring.Data.NHibernate.Config/AopConfiguration.xml");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProxyDataAccessAndServiceLayer()
|
||||
{
|
||||
Assert.IsFalse(AopUtils.IsAopProxy( ctx["DbProvider"] ));
|
||||
Assert.IsFalse(AopUtils.IsAopProxy( ctx["SessionFactory"] ));
|
||||
Assert.IsFalse(AopUtils.IsAopProxy(ctx["hibernateTransactionManager"]));
|
||||
Assert.IsFalse(AopUtils.IsAopProxy(ctx["transactionManager"]));
|
||||
//Assert.IsTrue(AopUtils.IsAopProxy(ctx["testObjectDaoTransProxy"]));
|
||||
Assert.IsTrue(AopUtils.IsAopProxy(ctx["TestObjectDao"]));
|
||||
Assert.IsTrue(AopUtils.IsAopProxy(ctx["SimpleService"]));
|
||||
|
||||
CallCountingTransactionManager ccm = ctx["transactionManager"] as CallCountingTransactionManager;
|
||||
Assert.IsNotNull(ccm);
|
||||
Assert.AreEqual(0, ccm.begun);
|
||||
Assert.AreEqual(0, ccm.commits);
|
||||
|
||||
LoggingAroundAdvice caa = ctx["loggingAroundAdvice"] as LoggingAroundAdvice;
|
||||
Assert.IsNotNull(caa);
|
||||
Assert.AreEqual(0, caa.numInvoked);
|
||||
|
||||
ISimpleService simpleService = ctx["SimpleService"] as ISimpleService;
|
||||
Assert.IsNotNull(simpleService);
|
||||
simpleService.DoWork(new TestObject());
|
||||
Assert.AreEqual(1, ccm.begun);
|
||||
Assert.AreEqual(1, ccm.commits);
|
||||
Assert.AreEqual(1, caa.numInvoked);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?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">
|
||||
|
||||
|
||||
<!-- Database and NHibernate Configuration -->
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="SqlServer-2.0"
|
||||
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa;"/>
|
||||
|
||||
|
||||
|
||||
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<property name="MappingResources">
|
||||
<list>
|
||||
<value>assembly://Spring.Data.NHibernate.Tests/Spring.Data.NHibernate/TestObject.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="HibernateProperties">
|
||||
<dictionary>
|
||||
<entry key="hibernate.dialect"
|
||||
value="NHibernate.Dialect.MsSql2000Dialect"/>
|
||||
|
||||
<entry key="hibernate.connection.driver_class"
|
||||
value="NHibernate.Driver.SqlClientDriver"/>
|
||||
|
||||
</dictionary>
|
||||
</property>
|
||||
|
||||
</object>
|
||||
|
||||
|
||||
<object id="TestObjectDao" type="Spring.Data.NHibernate.TestObjectDao, Spring.Data.NHibernate.Tests">
|
||||
<property name="SessionFactory" ref="SessionFactory"/>
|
||||
</object>
|
||||
|
||||
<object id="hibernateTransactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate">
|
||||
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<property name="sessionFactory" ref="SessionFactory"/>
|
||||
|
||||
</object>
|
||||
|
||||
<object name="transactionManager" type="Spring.Transaction.CallCountingTransactionManager, Spring.Data.Tests"/>
|
||||
|
||||
<object name="SimpleService" type="Spring.Data.NHibernate.SimpleService, Spring.Data.NHibernate.Tests">
|
||||
<property name="TestObjectDao" ref="TestObjectDao"/>
|
||||
</object>
|
||||
|
||||
<object id="loggingAroundAdvice" type="Spring.Data.LoggingAroundAdvice, Spring.Data.Tests"/>
|
||||
|
||||
<object id ="myAutoProxy" type="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator">
|
||||
|
||||
<property name="InterceptorNames">
|
||||
<list>
|
||||
<value>loggingAroundAdvice</value>
|
||||
</list>
|
||||
</property>
|
||||
|
||||
<property name="ProxyTargetType" value="false"/>
|
||||
<property name="ExposeProxy" value="false"/>
|
||||
<property name="Optimize" value="false"/>
|
||||
|
||||
<property name="ObjectNames">
|
||||
<list>
|
||||
<value>TestObjectDao</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<tx:attribute-driven transaction-manager="transactionManager"/>
|
||||
|
||||
<!-- Transactional Proxy for TestObjectDao using the TransactionProxyFactory -->
|
||||
<!--
|
||||
<object id="testObjectDaoTransProxy"
|
||||
type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
|
||||
|
||||
<property name="PlatformTransactionManager" ref="transactionManager"/>
|
||||
<property name="Target" ref="SimpleService"/>
|
||||
|
||||
<property name="ProxyInterfaces" value="Spring.Data.NHibernate.ISimpleService"/>
|
||||
|
||||
<property name="TransactionAttributes">
|
||||
<name-values>
|
||||
<add key="Create*" value="PROPAGATION_REQUIRED"/>
|
||||
<add key="Delete*" value="PROPAGATION_REQUIRED"/>
|
||||
<add key="Update*" value="PROPAGATION_REQUIRED"/>
|
||||
<add key="Find*" value="PROPAGATION_REQUIRED"/>
|
||||
</name-values>
|
||||
</property>
|
||||
</object>
|
||||
-->
|
||||
|
||||
</objects>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?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">
|
||||
|
||||
|
||||
<!-- Database and NHibernate Configuration -->
|
||||
|
||||
<db:provider id="DbProvider"
|
||||
provider="SqlServer-2.0"
|
||||
connectionString="Data Source=MARKT60\SQL2005;Initial Catalog=Spring;Persist Security Info=True;User ID=springqa;Password=springqa;"/>
|
||||
|
||||
|
||||
|
||||
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate">
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<property name="MappingResources">
|
||||
<list>
|
||||
<value>assembly://Spring.Data.NHibernate.Tests/Spring.Data.NHibernate/TestObject.hbm.xml</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="HibernateProperties">
|
||||
<dictionary>
|
||||
<entry key="hibernate.dialect"
|
||||
value="NHibernate.Dialect.MsSql2000Dialect"/>
|
||||
|
||||
<entry key="hibernate.connection.driver_class"
|
||||
value="NHibernate.Driver.SqlClientDriver"/>
|
||||
|
||||
</dictionary>
|
||||
</property>
|
||||
|
||||
</object>
|
||||
|
||||
|
||||
<object id="TestObjectDao" type="Spring.Data.NHibernate.TestObjectDao, Spring.Data.NHibernate.Tests">
|
||||
<property name="SessionFactory" ref="SessionFactory"/>
|
||||
</object>
|
||||
|
||||
<object id="transactionManager" type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate">
|
||||
|
||||
<property name="DbProvider" ref="DbProvider"/>
|
||||
<property name="sessionFactory" ref="SessionFactory"/>
|
||||
|
||||
</object>
|
||||
|
||||
|
||||
<object name="SimpleService" type="Spring.Data.NHibernate.SimpleService, Spring.Data.NHibernate.Tests">
|
||||
<property name="TestObjectDao" ref="TestObjectDao"/>
|
||||
</object>
|
||||
|
||||
<object name="hibernateTemplate" type="Spring.Data.NHibernate.HibernateTemplate, Spring.Data.NHibernate">
|
||||
<property name="sessionFactory" ref="SessionFactory"/>
|
||||
</object>
|
||||
|
||||
<!-- once add 'internal' role for autoproxycreator that is created via the tx:attribute-driven element -->
|
||||
<!-- then we can add advisors to the config and have them picked up by any 'user' role defined autoproxycreators -->
|
||||
|
||||
<object id="loggingAdvisor" type="Spring.Aop.Support.NameMatchMethodPointcutAdvisor, Spring.Aop">
|
||||
<property name="Advice">
|
||||
<object id="loggingAroundAdvice" type="Spring.Data.LoggingAroundAdvice, Spring.Data.Tests"/>
|
||||
</property>
|
||||
<property name="MappedNames">
|
||||
<list>
|
||||
<value>12341234asdf*</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
<object id ="myAutoProxy" type="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxyCreator">
|
||||
|
||||
<property name="InterceptorNames">
|
||||
<list>
|
||||
<value>loggingAdvisor</value>
|
||||
</list>
|
||||
</property>
|
||||
|
||||
<property name="ProxyTargetType" value="false"/>
|
||||
<property name="ExposeProxy" value="false"/>
|
||||
<property name="Optimize" value="false"/>
|
||||
|
||||
<property name="ObjectNames">
|
||||
<list>
|
||||
<value>TestObjectDao</value>
|
||||
</list>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
|
||||
<tx:attribute-driven transaction-manager="transactionManager"/>
|
||||
|
||||
|
||||
</objects>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Created by:
|
||||
* Created: Monday, July 16, 2007
|
||||
*/
|
||||
|
||||
using Spring.Objects;
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
public interface ISimpleService
|
||||
{
|
||||
void DoWork(TestObject testObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
/// <version>$Id: ITestObjectDao.cs,v 1.1 2007/07/18 18:44:57 oakinger Exp $</version>
|
||||
public interface ITestObjectDao
|
||||
{
|
||||
void Create(TestObject to);
|
||||
void Update(TestObject to);
|
||||
void Delete(TestObject to);
|
||||
TestObject FindByName(string name);
|
||||
//IList FindAll();
|
||||
//int GetCount();
|
||||
//int GetCountByDelegate();
|
||||
void CreateUpdateRollback(TestObject to);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using NUnit.Framework;
|
||||
using Spring.Data.Common;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains tests for LocalSessionFactoryObject
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <version>$Id: LocalSessionFactoryObjectTests.cs,v 1.1 2008/01/29 20:07:18 markpollack Exp $</version>
|
||||
[TestFixture]
|
||||
public class LocalSessionFactoryObjectTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void LocalSessionFactoryObjectWithDbProviderAndProperties()
|
||||
{
|
||||
IDbProvider dbProvider = DbProviderFactory.GetDbProvider("System.Data.SqlClient");
|
||||
dbProvider.ConnectionString = "badConnectionString";
|
||||
LocalSessionFactoryObject sfo = new LocalSessionFactoryObject();
|
||||
sfo.DbProvider = dbProvider;
|
||||
IDictionary properties = new Hashtable();
|
||||
properties.Add("hibernate.connection.driver_class", "NHibernate.Driver.SqlClientDriver");
|
||||
properties.Add("hibernate.connection.provider", "NHibernate.Connection.DriverConnectionProvider");
|
||||
sfo.HibernateProperties = properties;
|
||||
sfo.AfterPropertiesSet();
|
||||
|
||||
Assert.IsNotNull(sfo.Configuration);
|
||||
Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionProvider].ToString(),
|
||||
"NHibernate.Connection.DriverConnectionProvider");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(FileNotFoundException))]
|
||||
public void LocalSessionFactoryObjectWithInvalidMapping()
|
||||
{
|
||||
LocalSessionFactoryObject sfo = new LocalSessionFactoryObject();
|
||||
sfo.MappingResources = new string[] { "mapping.hbm.xml"};
|
||||
sfo.AfterPropertiesSet();
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(HibernateException))]
|
||||
public void LocalSessionFactoryObjectWithInvalidProperties()
|
||||
{
|
||||
LocalSessionFactoryObject sfo = new LocalSessionFactoryObject();
|
||||
IDictionary properties = new Hashtable();
|
||||
properties.Add(Environment.ConnectionProvider, "myClass");
|
||||
sfo.HibernateProperties = properties;
|
||||
sfo.AfterPropertiesSet();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using NHibernate.Type;
|
||||
using Spring.Data.NHibernate.Support;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
/// <summary>
|
||||
/// NHibernate based DAO implementation of ITestObjectDAao:
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
/// <version>$Id: NHTestObjectDao.cs,v 1.1 2007/07/18 18:44:57 oakinger Exp $</version>
|
||||
public class TestObjectDao : HibernateDaoSupport, ITestObjectDao
|
||||
{
|
||||
|
||||
#region Constructor (s)
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestObjectDao"/> class.
|
||||
/// </summary>
|
||||
public TestObjectDao()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITestObjectDao Members
|
||||
|
||||
|
||||
public void Create(TestObject to)
|
||||
{
|
||||
//HibernateTemplate.Save(to);
|
||||
}
|
||||
|
||||
|
||||
public void Update(TestObject to)
|
||||
{
|
||||
HibernateTemplate.SaveOrUpdate(to);
|
||||
}
|
||||
|
||||
|
||||
public void Delete(TestObject to)
|
||||
{
|
||||
HibernateTemplate.Delete(to);
|
||||
}
|
||||
|
||||
public TestObject FindByName(string name)
|
||||
{
|
||||
IList result = HibernateTemplate.Find(
|
||||
"select from TestObject as to where to.Name=?",
|
||||
name,
|
||||
TypeFactory.GetStringType(50)
|
||||
);
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
return (TestObject)result[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateUpdateRollback(TestObject to)
|
||||
{
|
||||
HibernateTemplate.Save(to);
|
||||
to.Name = "Updated Name";
|
||||
HibernateTemplate.SaveOrUpdate(to);
|
||||
throw new Exception("My expected exception for test purposes.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
using Spring.Transaction.Interceptor;
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
/// <summary>
|
||||
/// This is
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <author>Mark Pollack</author>
|
||||
/// <version>$Id: SimpleService.cs,v 1.1 2007/07/18 18:44:57 oakinger Exp $</version>
|
||||
public class SimpleService : ISimpleService
|
||||
{
|
||||
private ITestObjectDao testObjectDao;
|
||||
|
||||
|
||||
public ITestObjectDao TestObjectDao
|
||||
{
|
||||
get { return testObjectDao; }
|
||||
set { testObjectDao = value; }
|
||||
}
|
||||
|
||||
[Transaction()]
|
||||
public void DoWork(TestObject testObject)
|
||||
{
|
||||
testObjectDao.Create(testObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Rhino.Mocks;
|
||||
using Spring.Context.Support;
|
||||
using Spring.Objects.Factory.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate.Support
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests <see cref="ConfigSectionSessionScopeSettings"/> behaviour.
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
/// <version>$Id: ConfigSectionSessionScopeSettingsTests.cs,v 1.1 2007/08/22 20:17:43 oakinger Exp $</version>
|
||||
[TestFixture]
|
||||
public class ConfigSectionSessionScopeSettingsTests
|
||||
{
|
||||
private class NameValueCollectionVariableSource : IVariableSource
|
||||
{
|
||||
private readonly NameValueCollection nameValuePairs = new NameValueCollection();
|
||||
|
||||
public NameValueCollectionVariableSource Add(string key, string value)
|
||||
{
|
||||
nameValuePairs.Add(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public string ResolveVariable(string name)
|
||||
{
|
||||
return nameValuePairs[name];
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCreateWithDefaults()
|
||||
{
|
||||
string SESSIONFACTORY_OBJECTNAME = ConfigSectionSessionScopeSettings.DEFAULT_SESSION_FACTORY_OBJECT_NAME;
|
||||
|
||||
// setup expected values
|
||||
MockRepository mocks = new MockRepository();
|
||||
ISessionFactory expectedSessionFactory = (ISessionFactory)mocks.CreateMock(typeof(ISessionFactory));
|
||||
IInterceptor expectedEntityInterceptor = null;
|
||||
bool expectedSingleSession = SessionScopeSettings.SINGLESESSION_DEFAULT;
|
||||
FlushMode expectedDefaultFlushMode = SessionScopeSettings.FLUSHMODE_DEFAULT;
|
||||
|
||||
// create and register context
|
||||
StaticApplicationContext appCtx = new StaticApplicationContext();
|
||||
appCtx.Name = AbstractApplicationContext.DefaultRootContextName;
|
||||
appCtx.ObjectFactory.RegisterSingleton(SESSIONFACTORY_OBJECTNAME, expectedSessionFactory);
|
||||
ContextRegistry.Clear();
|
||||
ContextRegistry.RegisterContext(appCtx);
|
||||
|
||||
ConfigSectionSessionScopeSettings settings = new ConfigSectionSessionScopeSettings(this.GetType(), (IVariableSource)null);
|
||||
|
||||
Assert.AreEqual(expectedSessionFactory, settings.SessionFactory);
|
||||
Assert.AreEqual(expectedEntityInterceptor, settings.EntityInterceptor);
|
||||
Assert.AreEqual(expectedSingleSession, settings.SingleSession);
|
||||
Assert.AreEqual(expectedDefaultFlushMode, settings.DefaultFlushMode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCreateFromExplicitConfiguration()
|
||||
{
|
||||
string SESSIONFACTORY_OBJECTNAME = "SessionFactory";
|
||||
string ENTITYINTERCEPTOR_OBJECTNAME = "EntityInterceptor";
|
||||
|
||||
MockRepository mocks = new MockRepository();
|
||||
ISessionFactory expectedSessionFactory = (ISessionFactory) mocks.CreateMock(typeof(ISessionFactory));
|
||||
IInterceptor expectedEntityInterceptor = (IInterceptor) mocks.CreateMock(typeof(IInterceptor));
|
||||
bool expectedSingleSession = false;
|
||||
FlushMode expectedDefaultFlushMode = FlushMode.Auto;
|
||||
|
||||
// create and register context
|
||||
StaticApplicationContext appCtx = new StaticApplicationContext();
|
||||
appCtx.Name = AbstractApplicationContext.DefaultRootContextName;
|
||||
appCtx.ObjectFactory.RegisterSingleton(SESSIONFACTORY_OBJECTNAME, expectedSessionFactory);
|
||||
appCtx.ObjectFactory.RegisterSingleton(ENTITYINTERCEPTOR_OBJECTNAME, expectedEntityInterceptor);
|
||||
ContextRegistry.Clear();
|
||||
ContextRegistry.RegisterContext(appCtx);
|
||||
|
||||
// simulate config section
|
||||
string thisTypeName = this.GetType().FullName;
|
||||
NameValueCollectionVariableSource variableSource = new NameValueCollectionVariableSource()
|
||||
.Add(thisTypeName + ".SessionFactoryObjectName", SESSIONFACTORY_OBJECTNAME)
|
||||
.Add(thisTypeName + ".EntityInterceptorObjectName", ENTITYINTERCEPTOR_OBJECTNAME)
|
||||
.Add(thisTypeName + ".SingleSession", expectedSingleSession.ToString().ToLower() ) // case insensitive!
|
||||
.Add(thisTypeName + ".DefaultFlushMode", expectedDefaultFlushMode.ToString().ToLower() ) // case insensitive!
|
||||
;
|
||||
|
||||
|
||||
ConfigSectionSessionScopeSettings settings = new ConfigSectionSessionScopeSettings(this.GetType(), variableSource);
|
||||
|
||||
Assert.AreEqual( expectedSessionFactory, settings.SessionFactory );
|
||||
Assert.AreEqual( expectedEntityInterceptor, settings.EntityInterceptor );
|
||||
Assert.AreEqual( expectedSingleSession, settings.SingleSession );
|
||||
Assert.AreEqual( expectedDefaultFlushMode, settings.DefaultFlushMode );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Rhino.Mocks;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate.Support
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests <see cref="SessionScopeSettings"/> functionality.
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
/// <version>$Id: SessionScopeSettingsTests.cs,v 1.2 2008/04/25 13:25:09 markpollack Exp $</version>
|
||||
[TestFixture]
|
||||
public class SessionScopeSettingsTests
|
||||
{
|
||||
private class DerivedSessionScopeSettings : SessionScopeSettings
|
||||
{
|
||||
public DerivedSessionScopeSettings()
|
||||
:base() // note, that we're calling default ctor here
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class LazyResolvingSessionScopeSettings : SessionScopeSettings
|
||||
{
|
||||
private readonly ISessionFactory sessionFactory;
|
||||
private readonly IInterceptor entityInterceptor;
|
||||
|
||||
|
||||
public LazyResolvingSessionScopeSettings(ISessionFactory sessionFactory, IInterceptor entityInterceptor)
|
||||
: base() // note, that we're calling default ctor here
|
||||
{
|
||||
this.sessionFactory = sessionFactory;
|
||||
this.entityInterceptor = entityInterceptor;
|
||||
}
|
||||
|
||||
protected override ISessionFactory ResolveSessionFactory()
|
||||
{
|
||||
// simulates lazy resolving
|
||||
return this.sessionFactory;
|
||||
}
|
||||
|
||||
protected override IInterceptor ResolveEntityInterceptor()
|
||||
{
|
||||
// simulates lazy resolving
|
||||
return this.entityInterceptor;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CheckDefaults()
|
||||
{
|
||||
Assert.IsTrue( SessionScopeSettings.SINGLESESSION_DEFAULT );
|
||||
Assert.AreEqual( FlushMode.Never, SessionScopeSettings.FLUSHMODE_DEFAULT );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorksAsExpected()
|
||||
{
|
||||
MockRepository mocks = new MockRepository();
|
||||
ISessionFactory sessionFactory = (ISessionFactory) mocks.CreateMock(typeof(ISessionFactory));
|
||||
IInterceptor entityInterceptor = (IInterceptor) mocks.CreateMock(typeof(IInterceptor));
|
||||
Assert.AreNotEqual( FlushMode.Auto, SessionScopeSettings.FLUSHMODE_DEFAULT ); // ensure noone changed our assumptions
|
||||
SessionScopeSettings sss = new SessionScopeSettings(sessionFactory, entityInterceptor, !SessionScopeSettings.SINGLESESSION_DEFAULT, FlushMode.Auto );
|
||||
|
||||
Assert.AreEqual( sessionFactory, sss.SessionFactory );
|
||||
Assert.AreEqual( entityInterceptor, sss.EntityInterceptor);
|
||||
Assert.AreEqual( !SessionScopeSettings.SINGLESESSION_DEFAULT, sss.SingleSession );
|
||||
Assert.AreEqual( FlushMode.Auto, sss.DefaultFlushMode );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CallingDefaultConstructorLeavesReferencesMarkedUninitialized()
|
||||
{
|
||||
DerivedSessionScopeSettings sss = new DerivedSessionScopeSettings();
|
||||
// config values are set to their defaults
|
||||
Assert.AreEqual(SessionScopeSettings.SINGLESESSION_DEFAULT, sss.SingleSession);
|
||||
Assert.AreEqual(SessionScopeSettings.FLUSHMODE_DEFAULT, sss.DefaultFlushMode);
|
||||
|
||||
IInterceptor interceptor = sss.EntityInterceptor;
|
||||
Assert.IsNull(interceptor);
|
||||
|
||||
try
|
||||
{
|
||||
ISessionFactory sessionFactory = sss.SessionFactory;
|
||||
Assert.Fail("should fail, because derived classes must override ResolveSessionFactory()");
|
||||
}
|
||||
catch (NotImplementedException) { }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CallingDefaultConstructorCausesLazyResolvingReferences()
|
||||
{
|
||||
MockRepository mocks = new MockRepository();
|
||||
ISessionFactory expectedSessionFactory = (ISessionFactory)mocks.CreateMock(typeof(ISessionFactory));
|
||||
IInterceptor expectedEntityInterceptor = (IInterceptor)mocks.CreateMock(typeof(IInterceptor));
|
||||
|
||||
SessionScopeSettings sss = new LazyResolvingSessionScopeSettings(expectedSessionFactory, expectedEntityInterceptor);
|
||||
|
||||
// config values are set to their defaults
|
||||
Assert.AreEqual(SessionScopeSettings.SINGLESESSION_DEFAULT, sss.SingleSession);
|
||||
Assert.AreEqual(SessionScopeSettings.FLUSHMODE_DEFAULT, sss.DefaultFlushMode);
|
||||
|
||||
Assert.AreSame(expectedSessionFactory, sss.SessionFactory);
|
||||
Assert.AreSame(expectedEntityInterceptor, sss.EntityInterceptor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void MissingSessionFactoryCausesArgumentExceptionDuringLazyResolving()
|
||||
{
|
||||
SessionScopeSettings sss = new LazyResolvingSessionScopeSettings(null, null);
|
||||
|
||||
// config values are set to their defaults
|
||||
Assert.AreEqual(SessionScopeSettings.SINGLESESSION_DEFAULT, sss.SingleSession);
|
||||
Assert.AreEqual(SessionScopeSettings.FLUSHMODE_DEFAULT, sss.DefaultFlushMode);
|
||||
|
||||
ISessionFactory sessionFactory = sss.SessionFactory;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MissingEntityInterceptorIsOkDuringLazyResolving()
|
||||
{
|
||||
MockRepository mocks = new MockRepository();
|
||||
ISessionFactory expectedSessionFactory = (ISessionFactory)mocks.CreateMock(typeof(ISessionFactory));
|
||||
|
||||
SessionScopeSettings sss = new LazyResolvingSessionScopeSettings(expectedSessionFactory, null);
|
||||
|
||||
// config values are set to their defaults
|
||||
Assert.AreEqual(SessionScopeSettings.SINGLESESSION_DEFAULT, sss.SingleSession);
|
||||
Assert.AreEqual(SessionScopeSettings.FLUSHMODE_DEFAULT, sss.DefaultFlushMode);
|
||||
|
||||
Assert.AreSame(expectedSessionFactory, sss.SessionFactory);
|
||||
Assert.AreSame(null, sss.EntityInterceptor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Rhino.Mocks;
|
||||
using Spring.Transaction.Support;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Data.NHibernate.Support
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for SessionScope
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
/// <version>$Id: SessionScopeTests.cs,v 1.5 2008/05/13 14:22:47 oakinger Exp $</version>
|
||||
[TestFixture]
|
||||
public class SessionScopeTests
|
||||
{
|
||||
private MockRepository repository;
|
||||
private ISessionFactory expectedSessionFactory;
|
||||
private IInterceptor expectedEntityInterceptor;
|
||||
private bool expectedSingleSession;
|
||||
private FlushMode expectedDefaultFlushMode;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
repository = new MockRepository();
|
||||
expectedSessionFactory = (ISessionFactory)repository.CreateMock(typeof(ISessionFactory));
|
||||
expectedEntityInterceptor = (IInterceptor)repository.CreateMock(typeof(IInterceptor));
|
||||
expectedSingleSession = SessionScopeSettings.SINGLESESSION_DEFAULT;
|
||||
expectedDefaultFlushMode = SessionScopeSettings.FLUSHMODE_DEFAULT;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCreateAndClose()
|
||||
{
|
||||
using (SessionScope scope = new SessionScope(expectedSessionFactory, expectedEntityInterceptor, expectedSingleSession, expectedDefaultFlushMode, false))
|
||||
{
|
||||
// no op - just create & dispose
|
||||
Assert.AreSame(expectedSessionFactory, scope.SessionFactory);
|
||||
Assert.AreSame(expectedEntityInterceptor, scope.EntityInterceptor);
|
||||
Assert.AreEqual(expectedSingleSession, scope.SingleSession);
|
||||
Assert.AreEqual(expectedDefaultFlushMode, scope.DefaultFlushMode);
|
||||
|
||||
// ensure nothing got registered with TSM
|
||||
Assert.IsFalse(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
|
||||
scope.Close();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCreateAndCloseSimpleCtor()
|
||||
{
|
||||
using (repository.Ordered())
|
||||
{
|
||||
ISession session = (ISession) repository.CreateMock(typeof (ISession));
|
||||
Expect.Call(expectedSessionFactory.OpenSession()).Return(session);
|
||||
session.FlushMode = FlushMode.Never;
|
||||
Expect.Call(session.Close()).Return(null);
|
||||
}
|
||||
repository.ReplayAll();
|
||||
using (SessionScope scope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
// no op - just create & dispose
|
||||
Assert.AreSame(expectedSessionFactory, scope.SessionFactory);
|
||||
//Assert.AreSame(null, scope.EntityInterceptor);
|
||||
Assert.AreEqual(expectedSingleSession, scope.SingleSession);
|
||||
Assert.AreEqual(expectedDefaultFlushMode, scope.DefaultFlushMode);
|
||||
|
||||
// ensure SessionHolder object is registered with TSM
|
||||
Assert.IsTrue(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
|
||||
SessionHolder sessionHolder =
|
||||
(SessionHolder) TransactionSynchronizationManager.GetResource(expectedSessionFactory);
|
||||
// by default session is lazy, so ask for it.
|
||||
Assert.IsNotNull(sessionHolder.Session);
|
||||
scope.Close();
|
||||
}
|
||||
repository.VerifyAll();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(InvalidOperationException))]
|
||||
public void OpeningTwiceThrowsInvalidOperationException()
|
||||
{
|
||||
using (SessionScope scope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
scope.Open();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ClosingTwiceIsIgnored()
|
||||
{
|
||||
using (SessionScope scope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
scope.Close();
|
||||
scope.Close();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisposeClosesScope()
|
||||
{
|
||||
SessionScope scope = new SessionScope(expectedSessionFactory, true);
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
scope.Dispose();
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DoesOpenImmediatelyOnOpenIsTrue()
|
||||
{
|
||||
SessionScope scope = null;
|
||||
using (scope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
// ensure is open
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
scope.Close();
|
||||
// ensure is closed
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
}
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
using (scope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
// ensure is open
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
}
|
||||
// ensure dispose closes scope
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DoesNotOpenImmediatelyOnOpenIsFalse()
|
||||
{
|
||||
SessionScope scope = null;
|
||||
using (scope = new SessionScope(expectedSessionFactory, false))
|
||||
{
|
||||
// ensure is *not* open
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
scope.Open();
|
||||
// ensure is open now
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
|
||||
scope.Close();
|
||||
// ensure is closed
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
}
|
||||
// ensure is closed
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleSessionRegistersSessionHolderWithTSM()
|
||||
{
|
||||
SessionScope scope = null;
|
||||
using (scope = new SessionScope(expectedSessionFactory, null, true, FlushMode.Auto, true))
|
||||
{
|
||||
// ensure is open
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
// ensure registered sessionholder with TSM
|
||||
Assert.IsTrue(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
// ensure a sessionHolder is registered
|
||||
SessionHolder sessionHolder = TransactionSynchronizationManager.GetResource(expectedSessionFactory) as SessionHolder;
|
||||
Assert.IsNotNull(sessionHolder);
|
||||
}
|
||||
// ensure scope is closed and sessionHolder is unregistered from TSM
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleSessionAppliesDefaultFlushModeOnOpenSessionAndClosesSession()
|
||||
{
|
||||
ISession expectedSession = (ISession)repository.CreateMock(typeof(ISession));
|
||||
|
||||
Expect.Call(expectedSessionFactory.OpenSession()).Return(expectedSession);
|
||||
expectedSession.FlushMode = FlushMode.Auto;
|
||||
Expect.Call(expectedSession.Close()).Return(null);
|
||||
repository.ReplayAll();
|
||||
|
||||
SessionScope scope = null;
|
||||
using (scope = new SessionScope(expectedSessionFactory, null, true, FlushMode.Auto, true))
|
||||
{
|
||||
SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.GetResource(expectedSessionFactory);
|
||||
Assert.IsTrue(sessionHolder.ContainsSession(expectedSession));
|
||||
}
|
||||
// ensure scope is closed and sessionHolder is unregistered from TSM
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
|
||||
repository.VerifyAll();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleSessionNestedSessionParticipatesInParentScopeSessionFactory()
|
||||
{
|
||||
SessionScope scope = null;
|
||||
using (scope = new SessionScope(expectedSessionFactory, null, true, FlushMode.Auto, true))
|
||||
{
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
using (SessionScope innerScope = new SessionScope(expectedSessionFactory, true))
|
||||
{
|
||||
// outer scope didn't change
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
|
||||
// participating only - no SessionHolder will be registered!
|
||||
Assert.IsTrue(innerScope.IsOpen);
|
||||
Assert.IsTrue(innerScope.IsParticipating);
|
||||
|
||||
innerScope.Close();
|
||||
|
||||
Assert.IsFalse(innerScope.IsOpen);
|
||||
Assert.IsFalse(innerScope.IsParticipating);
|
||||
|
||||
// outer scope didn't change
|
||||
Assert.IsTrue(scope.IsOpen);
|
||||
Assert.IsFalse(scope.IsParticipating);
|
||||
Assert.IsTrue(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
}
|
||||
}
|
||||
|
||||
// ensure scope is closed and sessionHolder is unregistered from TSM
|
||||
Assert.IsFalse(scope.IsOpen);
|
||||
Assert.IsFalse(TransactionSynchronizationManager.HasResource(expectedSessionFactory));
|
||||
}
|
||||
|
||||
public class TestSessionScopeSettings : SessionScopeSettings
|
||||
{
|
||||
public TestSessionScopeSettings(ISessionFactory sessionFactory)
|
||||
: base(sessionFactory)
|
||||
{
|
||||
}
|
||||
|
||||
protected override IInterceptor ResolveEntityInterceptor()
|
||||
{
|
||||
return DoResolveEntityInterceptor();
|
||||
}
|
||||
|
||||
public virtual IInterceptor DoResolveEntityInterceptor()
|
||||
{
|
||||
return base.ResolveEntityInterceptor();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResolvesEntityInterceptorOnEachOpen()
|
||||
{
|
||||
TestSessionScopeSettings sss =
|
||||
(TestSessionScopeSettings)repository.PartialMock(typeof(TestSessionScopeSettings), expectedSessionFactory);
|
||||
ISession expectedSession = (ISession)repository.CreateMock(typeof(ISession));
|
||||
sss.DefaultFlushMode = FlushMode.Never;
|
||||
|
||||
SessionScope sc = new SessionScope(sss, false);
|
||||
|
||||
using (repository.Ordered())
|
||||
{
|
||||
Expect.Call(sss.DoResolveEntityInterceptor()).Return(expectedEntityInterceptor);
|
||||
Expect.Call(expectedSessionFactory.OpenSession(expectedEntityInterceptor)).Return(expectedSession);
|
||||
expectedSession.FlushMode = FlushMode.Never;
|
||||
Expect.Call(expectedSession.Close()).Return(null);
|
||||
|
||||
Expect.Call(sss.DoResolveEntityInterceptor()).Return(expectedEntityInterceptor);
|
||||
Expect.Call(expectedSessionFactory.OpenSession(expectedEntityInterceptor)).Return(expectedSession);
|
||||
expectedSession.FlushMode = FlushMode.Never;
|
||||
Expect.Call(expectedSession.Close()).Return(null);
|
||||
}
|
||||
repository.ReplayAll();
|
||||
|
||||
sc.Open();
|
||||
SessionHolder sessionHolder = (SessionHolder)TransactionSynchronizationManager.GetResource(expectedSessionFactory);
|
||||
sessionHolder.ContainsSession(null); // force opening session
|
||||
sc.Close();
|
||||
|
||||
sc.Open();
|
||||
sessionHolder = (SessionHolder)TransactionSynchronizationManager.GetResource(expectedSessionFactory);
|
||||
sessionHolder.ContainsSession(null); // force opening session
|
||||
sc.Close();
|
||||
|
||||
repository.VerifyAll();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
namespace Spring.Data.NHibernate
|
||||
{
|
||||
/// <summary>
|
||||
/// TODO:
|
||||
/// </summary>
|
||||
/// <author>Mark Pollack (.NET)</author>
|
||||
/// <version>$Id: TestObject.cs,v 1.1 2007/07/18 18:44:57 oakinger Exp $</version>
|
||||
public class TestObject
|
||||
{
|
||||
#region Fields
|
||||
private int age;
|
||||
private string name;
|
||||
private int objectNumber;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor (s)
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestObject"/> class.
|
||||
/// </summary>
|
||||
public TestObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public int Age
|
||||
{
|
||||
get { return age; }
|
||||
set { age = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
|
||||
public int ObjectNumber
|
||||
{
|
||||
get { return objectNumber; }
|
||||
set { objectNumber = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
|
||||
<class name="Spring.Data.NHibernate.TestObject, Spring.Data.NHibernate.Tests" table="TestObjects">
|
||||
<id name="ObjectNumber" column="TestObjectNo" type="Int32">
|
||||
<generator class="identity" />
|
||||
|
||||
<!--
|
||||
<generator class="sequence">
|
||||
<param name="sequence">ID_SEQ</param>
|
||||
</generator>
|
||||
-->
|
||||
|
||||
</id>
|
||||
<property name="Age" column="Age" type="Int32"/>
|
||||
<property name="Name" type="String" length="50"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -0,0 +1,207 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{8755D942-7828-4971-835B-37A5992C06C9}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "Spring.Data.NHibernate.Tests"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = 'echo "Copying .xml files for tests"
xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2003\Spring.Data.NHibernate.Tests\$(ConfigurationName)\ /y /s /q /d
xcopy "$(ProjectDir)$(TargetFileName).config" ..\..\..\..\build\VS.Net.2003\Spring.Data.NHibernate.Tests\$(ConfigurationName)\ /y /s /q'
|
||||
RootNamespace = "Spring"
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug-1.1"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE;NET_1_1"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "false"
|
||||
OutputPath = "..\..\..\build\VS.Net.2003\Spring.Data.NHibernate.Tests\Debug-1.1\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release-1.1"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE;NET_1_1"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "true"
|
||||
OutputPath = "..\..\..\build\VS.Net.2003\Spring.Data.NHibernate.Tests\Release-1.1\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "nunit.framework"
|
||||
AssemblyName = "nunit.framework"
|
||||
HintPath = "..\..\..\lib\net\1.1\nunit.framework.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Spring.Core.2003"
|
||||
Project = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Spring.Data.NHibernate.2003"
|
||||
Project = "{E8467024-8AE3-44A4-BAAD-1D78747EC7BD}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Spring.Aop.2003"
|
||||
Project = "{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Spring.Data.2003"
|
||||
Project = "{E10A3BED-795F-41CB-A4A8-8C4B342ACDDF}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Spring.Data.Tests.2003"
|
||||
Project = "{C5585365-561C-4EC4-8956-87FFBD9AB1CD}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Castle.DynamicProxy"
|
||||
AssemblyName = "Castle.DynamicProxy"
|
||||
HintPath = "..\..\..\lib\NHibernate10\net\1.1\Castle.DynamicProxy.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Iesi.Collections"
|
||||
AssemblyName = "Iesi.Collections"
|
||||
HintPath = "..\..\..\lib\NHibernate10\net\1.1\Iesi.Collections.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "log4net"
|
||||
AssemblyName = "log4net"
|
||||
HintPath = "..\..\..\lib\NHibernate10\net\1.1\log4net.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "NHibernate"
|
||||
AssemblyName = "NHibernate"
|
||||
HintPath = "..\..\..\lib\NHibernate10\net\1.1\NHibernate.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Rhino.Mocks"
|
||||
AssemblyName = "Rhino.Mocks"
|
||||
HintPath = "..\..\..\lib\Net\1.1\Rhino.Mocks.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Spring.Data.NHibernate.Tests.dll.config"
|
||||
BuildAction = "None"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\ISimpleService.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\ITestObjectDao.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\NHTestObjectDao.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\SimpleService.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\TestObject.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\TestObject.hbm.xml"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\Config\AopConfiguration.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\Config\AopConfiguration.xml"
|
||||
BuildAction = "EmbeddedResource"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\Support\ConfigSectionSessionScopeSettingsTests.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\Support\SessionScopeSettingsTests.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Data\NHibernate\Support\SessionScopeTests.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{94E4E1B4-D424-4EB9-BF34-2EE8CC3D7048}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Spring</RootNamespace>
|
||||
<AssemblyName>Spring.Data.NHibernate.Tests</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\build\VS.Net.2005\Spring.Data.NHibernate.Tests\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;NET_2_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\..\build\VS.Net.2005\Spring.Data.NHibernate.Tests\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NET_2_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate10\net\2.0\Castle.DynamicProxy.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Common.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections, Version=1.0.0.1, Culture=neutral, PublicKeyToken=154fdcb44c4484fc">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate10\net\2.0\Iesi.Collections.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=b32731d11ce58905">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate10\net\2.0\log4net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NHibernate, Version=1.0.4.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\NHibernate10\net\2.0\NHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.2.7.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\net\2.0\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Rhino.Mocks, Version=2.9.6.40380, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\lib\Net\2.0\Rhino.Mocks.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Aop\Spring.Aop.2005.csproj">
|
||||
<Project>{3A3A4E65-45A6-4B20-B460-0BEDC302C02C}</Project>
|
||||
<Name>Spring.Aop.2005</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Core\Spring.Core.2005.csproj">
|
||||
<Project>{710961A3-0DF4-49E4-A26E-F5B9C044AC84}</Project>
|
||||
<Name>Spring.Core.2005</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Data.NHibernate\Spring.Data.NHibernate.2005.csproj">
|
||||
<Project>{130E1609-45A7-4F65-B112-105F2DD3E2CE}</Project>
|
||||
<Name>Spring.Data.NHibernate.2005</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\src\Spring\Spring.Data\Spring.Data.2005.csproj">
|
||||
<Project>{AE00E5AB-C39A-436F-86D2-33BFE33E2E40}</Project>
|
||||
<Name>Spring.Data.2005</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Spring.Data.Tests\Spring.Data.Tests.2005.csproj">
|
||||
<Project>{ACD39D47-1811-40FA-9E7E-5DEA5B9CE6C0}</Project>
|
||||
<Name>Spring.Data.Tests.2005</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\NHibernate\Config\AopConfiguration.cs" />
|
||||
<Compile Include="Data\NHibernate\HibernateTransactionManagerTests.cs" />
|
||||
<Compile Include="Data\NHibernate\ISimpleService.cs" />
|
||||
<Compile Include="Data\NHibernate\ITestObjectDao.cs" />
|
||||
<Compile Include="Data\NHibernate\LocalSessionFactoryObjectTests.cs" />
|
||||
<Compile Include="Data\NHibernate\NHTestObjectDao.cs" />
|
||||
<Compile Include="Data\NHibernate\SimpleService.cs" />
|
||||
<Compile Include="Data\NHibernate\Support\ConfigSectionSessionScopeSettingsTests.cs" />
|
||||
<Compile Include="Data\NHibernate\Support\SessionScopeSettingsTests.cs" />
|
||||
<Compile Include="Data\NHibernate\Support\SessionScopeTests.cs" />
|
||||
<Compile Include="Data\NHibernate\TestObject.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\NHibernate\Config\AopConfiguration.xml" />
|
||||
<EmbeddedResource Include="Data\NHibernate\TestObject.hbm.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Spring.Data.NHibernate.Tests.dll.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Data\NHibernate\Config\AopConfigurationTxPointcut.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>echo "Copying .xml files for tests"
|
||||
xcopy "$(ProjectDir)Data" ..\..\..\..\build\VS.Net.2005\Spring.Data.NHibernate.Tests\$(ConfigurationName)\ /y /s /q /d
|
||||
xcopy "$(ProjectDir)$(TargetFileName).config" ..\..\..\..\build\VS.Net.2005\Spring.Data.NHibernate.Tests\$(ConfigurationName)\ /y /s /q</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" ?>
|
||||
<project name="Spring.Data.NHibernate.Tests" default="build" xmlns="http://nant.sf.net/schemas/nant.xsd">
|
||||
<!--
|
||||
Required properties:
|
||||
* current.bin.dir - (path) root level to build to
|
||||
* build.debug - (true|false) debug build?
|
||||
* current.build.defines.csc - framework-specific build defines
|
||||
-->
|
||||
<target name="build">
|
||||
<csc target="library" define="${current.build.defines.csc}"
|
||||
warnaserror="true"
|
||||
debug="${current.build.debug}"
|
||||
output="${current.bin.dir}/${project::get-name()}.dll"
|
||||
doc="${current.bin.dir}/${project::get-name()}.xml">
|
||||
<nowarn>
|
||||
<warning number="${nowarn.numbers.test}" />
|
||||
</nowarn>
|
||||
<sources failonempty="true">
|
||||
<include name="**/*.cs" />
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
</sources>
|
||||
<references basedir="${current.bin.dir}">
|
||||
<lib>
|
||||
<include name="${nh.lib.dir}"/>
|
||||
</lib>
|
||||
<include name="System.Data.dll" />
|
||||
<include name="System.EnterpriseServices.dll" />
|
||||
<include name="NHibernate.dll" />
|
||||
<include name="*.dll" />
|
||||
<exclude name="${project::get-name()}.dll" />
|
||||
<exclude name="Spring.Data.NHibernate12.dll" />
|
||||
<exclude name="CloverRuntime.dll" />
|
||||
</references>
|
||||
<resources prefix="Spring" dynamicprefix="true" failonempty="true">
|
||||
<include name="**/*.xml" />
|
||||
</resources>
|
||||
</csc>
|
||||
|
||||
<copy file="${project::get-base-directory()}/${project::get-name()}.dll.config"
|
||||
tofile="${current.bin.dir}/${project::get-name()}.dll.config"/>
|
||||
|
||||
<!-- copy nh libs -->
|
||||
<copy todir="${current.bin.dir}" overwrite="true">
|
||||
<fileset basedir="${nh.lib.dir}">
|
||||
<include name="**/*.dll" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="test" depends="build">
|
||||
<nunit2outproc>
|
||||
<formatter type="Plain" />
|
||||
<formatter type="Xml" usefile="true" extension=".xml"
|
||||
outputdir="${current.bin.dir}/results" />
|
||||
<test assemblyname="${current.bin.dir}/${project::get-name()}.dll"
|
||||
appconfig="${current.bin.dir}/${project::get-name()}.dll.config" />
|
||||
</nunit2outproc>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<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>
|
||||
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net129">
|
||||
<arg key="configType" value="EXTERNAL" />
|
||||
</factoryAdapter>
|
||||
</logging>
|
||||
</common>
|
||||
-->
|
||||
|
||||
<spring>
|
||||
<parsers>
|
||||
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
|
||||
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data" />
|
||||
<parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop" />
|
||||
</parsers>
|
||||
</spring>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user