1
|
|
#region Copyright
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
#endregion
|
18
|
|
|
19
|
|
using System;
|
20
|
|
using System.IO;
|
21
|
|
using System.EnterpriseServices;
|
22
|
|
using System.Reflection;
|
23
|
|
|
24
|
|
using Seasar.Framework.Container;
|
25
|
|
using Seasar.Framework.Container.Factory;
|
26
|
|
|
27
|
|
using log4net;
|
28
|
|
using log4net.Config;
|
29
|
|
using log4net.Util;
|
30
|
|
|
31
|
|
using NUnit.Framework;
|
32
|
|
|
33
|
|
namespace Seasar.Tests.Extension.Tx
|
34
|
|
{
|
35
|
|
|
36
|
|
|
37
|
|
|
38
|
|
[TestFixture]
|
39
|
|
public class DTCRequiredInterceptorTest
|
40
|
|
{
|
41
|
|
private const string path = "Seasar/Tests/Extension/Tx/DTCRequiredInterceptorTest.dicon";
|
42
|
1
|
static DTCRequiredInterceptorTest()
|
43
|
|
{
|
44
|
1
|
FileInfo info = new FileInfo(SystemInfo.AssemblyFileName(
|
45
|
|
Assembly.GetExecutingAssembly()) + ".config");
|
46
|
1
|
XmlConfigurator.Configure(LogManager.GetRepository(), info);
|
47
|
|
}
|
48
|
|
|
49
|
|
private IS2Container container = null;
|
50
|
|
private TxTest tester = null;
|
51
|
2
|
[SetUp]
|
52
|
|
public void SetUp()
|
53
|
|
{
|
54
|
2
|
container = S2ContainerFactory.Create(path);
|
55
|
2
|
container.Init();
|
56
|
2
|
tester = container.GetComponent(typeof(TxTest)) as TxTest;
|
57
|
|
}
|
58
|
|
|
59
|
1
|
[Test]
|
60
|
|
public void TestProceed()
|
61
|
|
{
|
62
|
1
|
Assert.IsTrue(tester.IsInTransaction());
|
63
|
1
|
Assert.IsFalse(ContextUtil.IsInTransaction);
|
64
|
|
}
|
65
|
|
|
66
|
1
|
[Test]
|
67
|
|
public void TestProceedException()
|
68
|
|
{
|
69
|
1
|
try
|
70
|
|
{
|
71
|
1
|
tester.throwException();
|
72
|
0
|
Assert.Fail();
|
73
|
|
}
|
74
|
|
catch(Exception e)
|
75
|
|
{
|
76
|
1
|
Assert.IsTrue(e is NotSupportedException);
|
77
|
1
|
Assert.IsFalse(ContextUtil.IsInTransaction);
|
78
|
|
}
|
79
|
|
|
80
|
|
}
|
81
|
|
}
|
82
|
|
|
83
|
|
[TestFixture]
|
84
|
|
[Transaction(TransactionOption.RequiresNew)]
|
85
|
|
public class DTCRequiredInterceptorTestES : ServicedComponent
|
86
|
|
{
|
87
|
|
private const string path = "Seasar/Tests/Extension/Tx/DTCRequiredInterceptorTest.dicon";
|
88
|
1
|
static DTCRequiredInterceptorTestES()
|
89
|
|
{
|
90
|
1
|
FileInfo info = new FileInfo(SystemInfo.AssemblyFileName(
|
91
|
|
Assembly.GetExecutingAssembly()) + ".config");
|
92
|
1
|
XmlConfigurator.Configure(LogManager.GetRepository(), info);
|
93
|
|
}
|
94
|
|
|
95
|
|
private IS2Container container = null;
|
96
|
|
private TxTest tester = null;
|
97
|
0
|
[SetUp]
|
98
|
|
public void SetUp()
|
99
|
|
{
|
100
|
|
container = S2ContainerFactory.Create(path);
|
101
|
|
container.Init();
|
102
|
|
tester = container.GetComponent(typeof(TxTest)) as TxTest;
|
103
|
|
}
|
104
|
|
|
105
|
0
|
[Test]
|
106
|
|
[AutoComplete]
|
107
|
|
public void TestProceed()
|
108
|
|
{
|
109
|
|
Guid guid = ContextUtil.TransactionId;
|
110
|
|
Assert.IsTrue(tester.IsInTransaction());
|
111
|
|
Assert.AreEqual(guid, tester.GetTransactionId());
|
112
|
|
}
|
113
|
|
}
|
114
|
|
}
|
115
|
|
|