Skip to content

Commit

Permalink
Fix configuration schema forbidding custom bytecode provider (#1764)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Jun 25, 2018
1 parent 8a788d6 commit 82f199e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
23 changes: 19 additions & 4 deletions src/NHibernate.Test/CfgTest/ConfigurationSchemaFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Configuration;
using System.Reflection;
using NHibernate.Event;
using NUnit.Framework;
using NHibernate.Cfg;
Expand All @@ -13,7 +11,7 @@ namespace NHibernate.Test.CfgTest
public class ConfigurationSchemaFixture
{
[Test]
public void InvalidConfig()
public void SessionFactoryIsRequiredWhenConfigurationIsNotLoadedFromAppConfig()
{
string xml =
@"<?xml version='1.0' encoding='utf-8' ?>
Expand All @@ -22,7 +20,7 @@ public void InvalidConfig()
</hibernate-configuration>";

XmlTextReader xtr = new XmlTextReader(xml, XmlNodeType.Document, null);
Assert.Throws<HibernateConfigException>(()=>new HibernateConfiguration(xtr));
Assert.Throws<HibernateConfigException>(() => new HibernateConfiguration(xtr));
}

[Test]
Expand All @@ -35,6 +33,23 @@ public void FromAppConfigTest()
Assert.IsTrue(hc.UseReflectionOptimizer);
Assert.AreEqual("NHibernate.Test", hc.SessionFactory.Name);
}

[Test]
public void ByteCodeProvider()
{
Assume.That(TestsContext.ExecutingWithVsTest, Is.False);

var xml =
@"<?xml version='1.0' encoding='utf-8' ?>
<hibernate-configuration xmlns='urn:nhibernate-configuration-2.2'>
<bytecode-provider type='test'/>
<session-factory>
</session-factory>
</hibernate-configuration>";

var hc = HibernateConfiguration.FromAppConfig(xml);
Assert.That(hc.ByteCodeProviderType, Is.EqualTo("test"));
}

[Test]
public void IgnoreSystemOutOfAppConfig()
Expand Down
15 changes: 11 additions & 4 deletions src/NHibernate/nhibernate-configuration.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,17 @@
</xs:sequence>
<xs:attribute name="type" default="lcg">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lcg" />
<xs:enumeration value="null" />
</xs:restriction>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="lcg" />
<xs:enumeration value="null" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
Expand Down

0 comments on commit 82f199e

Please sign in to comment.