Skip to content

Commit 9b39a2a

Browse files
authored
Merge branch 'master' into master
2 parents 6877b96 + 2d2095b commit 9b39a2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2455
-265
lines changed

lgpl.txt renamed to LICENSE.txt

File renamed without changes.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ can be found [here][C2].
4646
Licenses
4747
--------
4848

49-
This software is distributed under the terms of the Free Software Foundation [Lesser GNU Public License (LGPL), version 2.1][D1] (see lgpl.txt).
49+
- This software is distributed under the terms of the Free Software Foundation [Lesser GNU Public License (LGPL), version 2.1][D1] (see [LICENSE.txt][D2]).
50+
- The documentation for this software is distributed under the terms of the Free Software Foundation [GNU Free Documentation License (GNU FDL), version 1.1][D3] (see [doc/LICENSE.txt][D4]).
5051

5152
[D1]: http://www.gnu.org/licenses/lgpl-2.1-standalone.html
53+
[D2]: LICENSE.txt
54+
[D3]: http://www.gnu.org/licenses/old-licenses/fdl-1.1-standalone.html
55+
[D4]: doc/LICENSE.txt
5256

5357
Credits
5458
-------

default.build

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@
7878
<foreach item="String" delim=" " property="framework" in="${supported.frameworks}">
7979
<call target="set-${framework}-framework-configuration" />
8080
<call target="build" />
81-
<!-- Copy and rename the license -->
82-
<copy file="lgpl.txt" tofile="${bin.dir}/NHibernate.license.txt" />
8381
</foreach>
8482

8583
<!-- Reset the current framework to the saved value -->
@@ -124,10 +122,9 @@
124122
<include name="build-common/**" />
125123

126124
<include name="*.build" />
127-
<include name="gfdl.txt" />
128-
<include name="lgpl.txt" />
125+
<include name="LICENSE.txt" />
129126
<include name="releasenotes.txt" />
130-
<include name="readme.html" />
127+
<include name="README.md" />
131128

132129
<!-- exclude ReSharper stuff -->
133130
<exclude name="**/_ReSharper*/**" />
@@ -170,8 +167,7 @@
170167
<property name="bin-pack.tests" value="${bin-pack.tmpdir}/Tests" />
171168

172169
<copy file="releasenotes.txt" todir="${bin-pack.tmpdir}"/>
173-
<copy file="lgpl.txt" todir="${bin-pack.tmpdir}/NHibernate.license.txt"/>
174-
<copy file="gfdl.txt" todir="${bin-pack.tmpdir}"/>
170+
<copy file="LICENSE.txt" todir="${bin-pack.tmpdir}"/>
175171
<copy file="HowInstall.txt" todir="${bin-pack.tmpdir}"/>
176172

177173
<exec program="CScript.exe"
File renamed without changes.

doc/documentation.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<target name="manual" depends="init">
2828
<property name="lang" value="en" />
29+
<copy file="LICENSE.txt" todir="${doc.out.dir}"/>
2930
<nant target="build" buildfile="reference/reference.build">
3031
<properties>
3132
<property name="lang" value="${lang}" />

src/NHibernate.Everything.sln

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NAnt Build", "NAnt Build",
3535
EndProject
3636
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Information", "Information", "{1631B0BA-59AC-4F0D-B300-3F64CC7579C9}"
3737
ProjectSection(SolutionItems) = preProject
38-
..\gfdl.txt = ..\gfdl.txt
39-
..\lgpl.txt = ..\lgpl.txt
40-
..\readme.html = ..\readme.html
38+
..\LICENSE.txt = ..\LICENSE.txt
39+
..\README.md = ..\README.md
4140
..\releasenotes.txt = ..\releasenotes.txt
4241
..\sample build commands.txt = ..\sample build commands.txt
4342
..\ShowBuildMenu.bat = ..\ShowBuildMenu.bat
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Collections;
2+
using System.Threading;
3+
using NHibernate.Cfg;
4+
using NHibernate.Context;
5+
using NHibernate.Engine;
6+
using NUnit.Framework;
7+
8+
namespace NHibernate.Test.ConnectionTest
9+
{
10+
[TestFixture]
11+
public class MapBasedSessionContextFixture : ConnectionManagementTestCase
12+
{
13+
protected override ISession GetSessionUnderTest()
14+
{
15+
ISession session = OpenSession();
16+
session.BeginTransaction();
17+
return session;
18+
}
19+
20+
protected override void Configure(Configuration configuration)
21+
{
22+
base.Configure(cfg);
23+
cfg.SetProperty(Environment.CurrentSessionContextClass, typeof(TestableMapBasedSessionContext).AssemblyQualifiedName);
24+
}
25+
26+
protected override void OnSetUp()
27+
{
28+
TestableMapBasedSessionContext._map = null;
29+
}
30+
31+
[Test]
32+
public void MapContextThreadSafety()
33+
{
34+
using (var factory1 = cfg.BuildSessionFactory())
35+
using (var session1 = factory1.OpenSession())
36+
using (var factory2 = cfg.BuildSessionFactory())
37+
using (var session2 = factory2.OpenSession())
38+
{
39+
var thread1 = new Thread(() =>
40+
{
41+
CurrentSessionContext.Bind(session1);
42+
});
43+
44+
var thread2 = new Thread(() =>
45+
{
46+
CurrentSessionContext.Bind(session2);
47+
});
48+
49+
thread1.Start();
50+
thread2.Start();
51+
thread1.Join();
52+
thread2.Join();
53+
54+
Assert.IsTrue(CurrentSessionContext.HasBind(factory1), $"No session bound to \"{nameof(factory1)}\" factory.");
55+
Assert.IsTrue(CurrentSessionContext.HasBind(factory2), $"No session bound to \"{nameof(factory2)}\" factory.");
56+
}
57+
}
58+
}
59+
60+
public class TestableMapBasedSessionContext : MapBasedSessionContext
61+
{
62+
public TestableMapBasedSessionContext(ISessionFactoryImplementor factory) : base(factory) { }
63+
64+
// Context is the app with such implementation. Just for the test case.
65+
internal static IDictionary _map;
66+
67+
protected override IDictionary GetMap()
68+
{
69+
return _map;
70+
}
71+
72+
protected override void SetMap(IDictionary value)
73+
{
74+
// Give a fair chance to have a concurrency bug if base implementation is not thread safe.
75+
Thread.Sleep(100);
76+
_map = value;
77+
}
78+
}
79+
}

src/NHibernate.Test/Criteria/Lambda/LambdaFixtureBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ private void AssertObjectsAreEqual(object expected, object actual, string name)
128128

129129
if ((expectedType.IsValueType)
130130
|| (expected is System.Type)
131-
|| (expected is string))
131+
|| (expected is string)
132+
|| (expected is FieldInfo)
133+
|| (expected is PropertyInfo))
132134
{
133135
Assert.AreEqual(expected, actual, fieldPath);
134136
_fieldPath.Pop();

src/NHibernate.Test/Linq/ByMethod/SumTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
23
using NUnit.Framework;
34

45
namespace NHibernate.Test.Linq.ByMethod
@@ -14,7 +15,10 @@ public void EmptySumDecimal()
1415
{
1516
db.OrderLines.Where(ol => false).Sum(ol => ol.Discount);
1617
},
17-
Throws.InstanceOf<HibernateException>());
18+
// Before NH-3850
19+
Throws.InstanceOf<HibernateException>()
20+
// After NH-3850
21+
.Or.InstanceOf<InvalidOperationException>());
1822
}
1923

2024
[Test]

src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ protected override bool AppliesTo(Dialect.Dialect dialect)
3232
{
3333
return false;
3434
}
35-
catch (Exception)
36-
{
37-
Assert.Fail("Probably a bug in the test case.");
38-
}
3935

4036
return true;
4137
}

src/NHibernate.Test/NHSpecificTest/NH1904/Model.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,19 @@ public class Invoice
99

1010
protected virtual DateTime issued { get; set; }
1111
}
12+
13+
public class InvoiceWithAddress : Invoice
14+
{
15+
public virtual Address BillingAddress { get; set; }
16+
}
17+
18+
public struct Address
19+
{
20+
public string Line { get; set; }
21+
public string line { get; set; }
22+
public string Line2 { get; set; }
23+
public string City { get; set; }
24+
public string ZipCode { get; set; }
25+
public string Country { get; set; }
26+
}
1227
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections;
3+
using NUnit.Framework;
4+
5+
namespace NHibernate.Test.NHSpecificTest.NH1904
6+
{
7+
[TestFixture]
8+
public class StructFixture : BugTestCase
9+
{
10+
protected override IList Mappings =>
11+
new string[]
12+
{
13+
"NHSpecificTest." + BugNumber + ".StructMappings.hbm.xml"
14+
};
15+
16+
[Test]
17+
public void ExecuteQuery()
18+
{
19+
using (ISession session = OpenSession())
20+
using (ITransaction transaction = session.BeginTransaction())
21+
{
22+
var invoice = new InvoiceWithAddress
23+
{
24+
Issued = DateTime.Now,
25+
BillingAddress = new Address { Line = "84 rue du 22 septembre", City = "Courbevoie", ZipCode = "92400", Country = "France" }
26+
};
27+
session.Save(invoice);
28+
transaction.Commit();
29+
}
30+
31+
using (ISession session = OpenSession())
32+
{
33+
var invoices = session.CreateCriteria<Invoice>().List<Invoice>();
34+
}
35+
}
36+
37+
protected override void OnTearDown()
38+
{
39+
base.OnTearDown();
40+
using (ISession session = OpenSession())
41+
{
42+
session.CreateQuery("delete from InvoiceWithAddress").ExecuteUpdate();
43+
session.Flush();
44+
}
45+
}
46+
}
47+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
3+
assembly="NHibernate.Test"
4+
namespace="NHibernate.Test.NHSpecificTest.NH1904">
5+
6+
<class name="InvoiceWithAddress">
7+
<id name="ID" type="Int32">
8+
<generator class="hilo" />
9+
</id>
10+
11+
<property name="Issued" type="DateTime" />
12+
13+
<component name="BillingAddress">
14+
<property name="Line"/>
15+
<property name="Line2"/>
16+
<property name="City"/>
17+
<property name="ZipCode"/>
18+
<property name="Country"/>
19+
</component>
20+
</class>
21+
22+
</hibernate-mapping>

src/NHibernate.Test/NHSpecificTest/NH1985/SampleTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ public class SampleTest : BugTestCase
1010
{
1111
protected override void OnSetUp()
1212
{
13-
base.OnSetUp();
14-
1513
if (0 == ExecuteStatement("INSERT INTO DomainClass (Id, Label) VALUES (1, 'TEST record');"))
1614
{
17-
throw new ApplicationException("Insertion of test record failed.");
15+
Assert.Fail("Insertion of test record failed.");
1816
}
1917
}
2018

@@ -26,7 +24,7 @@ protected override void OnTearDown()
2624
}
2725

2826
[Test]
29-
[Ignore("It is valid to be delete immutable entities")]
27+
[Ignore("It is valid to delete immutable entities")]
3028
public void AttemptToDeleteImmutableObjectShouldThrow()
3129
{
3230
using (ISession session = OpenSession())
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.NH3850
4+
{
5+
public abstract class DomainClassBase
6+
{
7+
public virtual int Id { get; set; }
8+
public virtual string Name { get; set; }
9+
public virtual int? Integer { get; set; }
10+
public virtual long? Long { get; set; }
11+
public virtual decimal? Decimal { get; set; }
12+
public virtual double? Double { get; set; }
13+
public virtual DateTime? DateTime { get; set; }
14+
public virtual DateTimeOffset? DateTimeOffset { get; set; }
15+
public virtual decimal NonNullableDecimal { get; set; }
16+
}
17+
18+
public class DomainClassAExtendingB : DomainClassBExtendedByA
19+
{
20+
}
21+
22+
public class DomainClassBExtendedByA : DomainClassBase
23+
{
24+
}
25+
26+
public class DomainClassCExtendedByD : DomainClassBase
27+
{
28+
}
29+
30+
public class DomainClassDExtendingC : DomainClassCExtendedByD
31+
{
32+
}
33+
34+
public class DomainClassE : DomainClassBase
35+
{
36+
}
37+
38+
public class DomainClassF : DomainClassBase
39+
{
40+
}
41+
42+
public class DomainClassGExtendedByH : DomainClassBase
43+
{
44+
}
45+
46+
public class DomainClassHExtendingG : DomainClassGExtendedByH
47+
{
48+
}
49+
}

0 commit comments

Comments
 (0)