SPRNET-1478 change default behavior to use NH internal ProxyFactoryFactory instead of the SPRNET implmentation

This commit is contained in:
Steve Bohlen
2012-04-18 15:44:43 -04:00
parent a8ef1dbf3b
commit e8bed331c9
2 changed files with 9 additions and 19 deletions

View File

@@ -534,21 +534,6 @@ namespace Spring.Data.NHibernate
}
}
// check whether proxy factory has been initialized
if (config.GetProperty(Environment.ProxyFactoryFactoryClass) == null
&& (hibernateProperties == null || !hibernateProperties.Contains(Environment.ProxyFactoryFactoryClass)))
{
// nothing set by user, lets use Spring.NET's proxy factory factory
#region Logging
if (log.IsInfoEnabled)
{
log.Info("Setting proxy factory to Spring provided one as user did not specify any");
}
#endregion
config.Properties.Add(
Environment.ProxyFactoryFactoryClass, typeof(Bytecode.ProxyFactoryFactory).AssemblyQualifiedName);
}
if (this.hibernateProperties != null)
{
if (config.GetProperty(Environment.ConnectionProvider) != null &&

View File

@@ -19,6 +19,7 @@
#endregion
using System.Collections;
using System.Collections.Generic;
using System.IO;
using NHibernate;
@@ -68,9 +69,13 @@ namespace Spring.Data.NHibernate
Assert.AreEqual(sfo.Configuration.Properties[Environment.ConnectionDriver], typeof(SqlClientDriver).AssemblyQualifiedName);
Assert.AreEqual(sfo.Configuration.Properties[Environment.Dialect], typeof(MsSql2000Dialect).AssemblyQualifiedName);
Assert.AreEqual(sfo.Configuration.Properties[Environment.ProxyFactoryFactoryClass], typeof(ProxyFactoryFactory).AssemblyQualifiedName);
// Spring's IBytecodeProvider should be the default
// Assert.AreEqual(typeof(BytecodeProvider), Environment.BytecodeProvider.GetType(), "default IBytecodeProvider was not Spring's BytecodeProvider");
Assert.Throws<KeyNotFoundException>(() =>
{
var x =
sfo.Configuration.Properties[Environment.ProxyFactoryFactoryClass];
}, "ProxyFactoryFactory should not be explicitly set!");
Assert.AreNotEqual(typeof(BytecodeProvider), Environment.BytecodeProvider.GetType(), "default IBytecodeProvider should not be Spring's BytecodeProvider!");
}
[Test]
@@ -78,7 +83,7 @@ namespace Spring.Data.NHibernate
public void LocalSessionFactoryObjectWithInvalidMapping()
{
LocalSessionFactoryObject sfo = new LocalSessionFactoryObject();
sfo.MappingResources = new string[] { "mapping.hbm.xml"};
sfo.MappingResources = new string[] { "mapping.hbm.xml" };
sfo.AfterPropertiesSet();
}