Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
6285e614
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6285e614
编写于
12月 16, 2008
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactored jca.cci tests, prepped for move to .context
上级
f11bc471
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
405 addition
and
861 deletion
+405
-861
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java
...org/springframework/jca/cci/CciLocalTransactionTests.java
+41
-81
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/CciTemplateTests.java
...st/java/org/springframework/jca/cci/CciTemplateTests.java
+277
-608
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/EisOperationTests.java
...t/java/org/springframework/jca/cci/EisOperationTests.java
+87
-172
未找到文件。
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java
浏览文件 @
6285e614
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
package
org.springframework.jca.cci
;
package
org.springframework.jca.cci
;
import
static
org
.
easymock
.
EasyMock
.*;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
javax.resource.ResourceException
;
import
javax.resource.ResourceException
;
import
javax.resource.cci.Connection
;
import
javax.resource.cci.Connection
;
import
javax.resource.cci.ConnectionFactory
;
import
javax.resource.cci.ConnectionFactory
;
...
@@ -24,9 +27,7 @@ import javax.resource.cci.InteractionSpec;
...
@@ -24,9 +27,7 @@ import javax.resource.cci.InteractionSpec;
import
javax.resource.cci.LocalTransaction
;
import
javax.resource.cci.LocalTransaction
;
import
javax.resource.cci.Record
;
import
javax.resource.cci.Record
;
import
junit.framework.TestCase
;
import
org.junit.Test
;
import
org.easymock.MockControl
;
import
org.springframework.dao.DataRetrievalFailureException
;
import
org.springframework.dao.DataRetrievalFailureException
;
import
org.springframework.jca.cci.core.CciTemplate
;
import
org.springframework.jca.cci.core.CciTemplate
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.TransactionStatus
;
...
@@ -36,61 +37,44 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
...
@@ -36,61 +37,44 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
import
org.springframework.transaction.support.TransactionTemplate
;
import
org.springframework.transaction.support.TransactionTemplate
;
/**
/**
* @author Thierry TEMPLIER
* @author Thierry Templier
* @author Chris Beams
*/
*/
public
class
CciLocalTransactionTests
extends
TestCase
{
public
class
CciLocalTransactionTests
{
/**
/**
* Test if a transaction ( begin / commit ) is executed on the
* Test if a transaction ( begin / commit ) is executed on the
* LocalTransaction when CciLocalTransactionManager is specified as
* LocalTransaction when CciLocalTransactionManager is specified as
* transaction manager.
* transaction manager.
*/
*/
@Test
public
void
testLocalTransactionCommit
()
throws
ResourceException
{
public
void
testLocalTransactionCommit
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
LocalTransaction
localTransaction
=
createMock
(
LocalTransaction
.
class
);
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
final
Record
record
=
createMock
(
Record
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
final
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
MockControl
localTransactionControl
=
MockControl
.
createControl
(
LocalTransaction
.
class
);
LocalTransaction
localTransaction
=
(
LocalTransaction
)
localTransactionControl
.
getMock
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
MockControl
recordControl
=
MockControl
.
createControl
(
Record
.
class
);
final
Record
record
=
(
Record
)
recordControl
.
getMock
();
expect
(
connection
.
getLocalTransaction
()).
andReturn
(
localTransaction
);
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
final
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
connectionFactory
.
getConnection
();
connectionFactoryControl
.
setReturnValue
(
connection
,
1
);
connection
.
getLocalTransaction
();
connectionControl
.
setReturnValue
(
localTransaction
,
1
);
localTransaction
.
begin
();
localTransaction
.
begin
();
localTransactionControl
.
setVoidCallable
(
1
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
);
interaction
.
execute
(
interactionSpec
,
record
,
record
);
expect
(
interaction
.
execute
(
interactionSpec
,
record
,
record
)).
andReturn
(
true
);
interactionControl
.
setReturnValue
(
true
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
getLocalTransaction
();
expect
(
connection
.
getLocalTransaction
()).
andReturn
(
localTransaction
);
connectionControl
.
setReturnValue
(
localTransaction
);
localTransaction
.
commit
();
localTransaction
.
commit
();
localTransactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
localTransaction
,
interaction
,
record
);
connectionControl
.
replay
();
localTransactionControl
.
replay
();
interactionControl
.
replay
();
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
tm
=
new
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
();
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
tm
=
new
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
();
tm
.
setConnectionFactory
(
connectionFactory
);
tm
.
setConnectionFactory
(
connectionFactory
);
...
@@ -104,10 +88,7 @@ public class CciLocalTransactionTests extends TestCase {
...
@@ -104,10 +88,7 @@ public class CciLocalTransactionTests extends TestCase {
}
}
});
});
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
localTransaction
,
interaction
,
record
);
connectionControl
.
verify
();
interactionControl
.
verify
();
localTransactionControl
.
verify
();
}
}
/**
/**
...
@@ -115,59 +96,41 @@ public class CciLocalTransactionTests extends TestCase {
...
@@ -115,59 +96,41 @@ public class CciLocalTransactionTests extends TestCase {
* LocalTransaction when CciLocalTransactionManager is specified as
* LocalTransaction when CciLocalTransactionManager is specified as
* transaction manager and a non-checked exception is thrown.
* transaction manager and a non-checked exception is thrown.
*/
*/
@Test
public
void
testLocalTransactionRollback
()
throws
ResourceException
{
public
void
testLocalTransactionRollback
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
LocalTransaction
localTransaction
=
createMock
(
LocalTransaction
.
class
);
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
final
Record
record
=
createMock
(
Record
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
final
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
MockControl
localTransactionControl
=
MockControl
.
createControl
(
LocalTransaction
.
class
);
LocalTransaction
localTransaction
=
(
LocalTransaction
)
localTransactionControl
.
getMock
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
MockControl
recordControl
=
MockControl
.
createControl
(
Record
.
class
);
final
Record
record
=
(
Record
)
recordControl
.
getMock
();
expect
(
connection
.
getLocalTransaction
()).
andReturn
(
localTransaction
);
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
final
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
connectionFactory
.
getConnection
();
connectionFactoryControl
.
setReturnValue
(
connection
);
connection
.
getLocalTransaction
();
connectionControl
.
setReturnValue
(
localTransaction
);
localTransaction
.
begin
();
localTransaction
.
begin
();
localTransactionControl
.
setVoidCallable
(
1
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
);
interaction
.
execute
(
interactionSpec
,
record
,
record
);
expect
(
interaction
.
execute
(
interactionSpec
,
record
,
record
)).
andReturn
(
true
);
interactionControl
.
setReturnValue
(
true
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
getLocalTransaction
();
expect
(
connection
.
getLocalTransaction
()).
andReturn
(
localTransaction
);
connectionControl
.
setReturnValue
(
localTransaction
);
localTransaction
.
rollback
();
localTransaction
.
rollback
();
localTransactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
replay
(
connectionFactory
,
connection
,
localTransaction
,
interaction
,
record
);
connectionFactoryControl
.
replay
();
connectionControl
.
replay
();
localTransactionControl
.
replay
();
interactionControl
.
replay
();
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
tm
=
new
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
();
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
tm
=
new
org
.
springframework
.
jca
.
cci
.
connection
.
CciLocalTransactionManager
();
tm
.
setConnectionFactory
(
connectionFactory
);
tm
.
setConnectionFactory
(
connectionFactory
);
TransactionTemplate
tt
=
new
TransactionTemplate
(
tm
);
TransactionTemplate
tt
=
new
TransactionTemplate
(
tm
);
try
{
try
{
Object
result
=
tt
.
execute
(
new
TransactionCallback
()
{
tt
.
execute
(
new
TransactionCallback
()
{
public
Object
doInTransaction
(
TransactionStatus
status
)
{
public
Object
doInTransaction
(
TransactionStatus
status
)
{
assertTrue
(
"Has thread connection"
,
TransactionSynchronizationManager
.
hasResource
(
connectionFactory
));
assertTrue
(
"Has thread connection"
,
TransactionSynchronizationManager
.
hasResource
(
connectionFactory
));
CciTemplate
ct
=
new
CciTemplate
(
connectionFactory
);
CciTemplate
ct
=
new
CciTemplate
(
connectionFactory
);
...
@@ -179,9 +142,6 @@ public class CciLocalTransactionTests extends TestCase {
...
@@ -179,9 +142,6 @@ public class CciLocalTransactionTests extends TestCase {
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
}
}
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
localTransaction
,
interaction
,
record
);
connectionControl
.
verify
();
interactionControl
.
verify
();
localTransactionControl
.
verify
();
}
}
}
}
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/CciTemplateTests.java
浏览文件 @
6285e614
此差异已折叠。
点击以展开。
org.springframework.testsuite/src/test/java/org/springframework/jca/cci/EisOperationTests.java
浏览文件 @
6285e614
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
package
org.springframework.jca.cci
;
package
org.springframework.jca.cci
;
import
static
org
.
easymock
.
EasyMock
.*;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
javax.resource.ResourceException
;
import
javax.resource.ResourceException
;
import
javax.resource.cci.Connection
;
import
javax.resource.cci.Connection
;
import
javax.resource.cci.ConnectionFactory
;
import
javax.resource.cci.ConnectionFactory
;
...
@@ -24,168 +27,119 @@ import javax.resource.cci.InteractionSpec;
...
@@ -24,168 +27,119 @@ import javax.resource.cci.InteractionSpec;
import
javax.resource.cci.Record
;
import
javax.resource.cci.Record
;
import
javax.resource.cci.RecordFactory
;
import
javax.resource.cci.RecordFactory
;
import
junit.framework.TestCase
;
import
org.junit.Test
;
import
org.easymock.MockControl
;
import
org.springframework.jca.cci.core.RecordCreator
;
import
org.springframework.jca.cci.core.RecordCreator
;
import
org.springframework.jca.cci.object.MappingRecordOperation
;
import
org.springframework.jca.cci.object.MappingRecordOperation
;
import
org.springframework.jca.cci.object.SimpleRecordOperation
;
import
org.springframework.jca.cci.object.SimpleRecordOperation
;
/**
/**
* @author Thierry TEMPLIER
* @author Thierry Templier
* @author Chris Beams
*/
*/
public
class
EisOperationTests
extends
TestCase
{
public
class
EisOperationTests
{
@Test
public
void
testSimpleRecordOperation
()
throws
ResourceException
{
public
void
testSimpleRecordOperation
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
MockControl
inputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
inputRecord
=
createMock
(
Record
.
class
);
Record
inputRecord
=
(
Record
)
inputRecordControl
.
getMock
();
Record
outputRecord
=
createMock
(
Record
.
class
);
MockControl
outputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
outputRecord
=
(
Record
)
outputRecordControl
.
getMock
();
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
SimpleRecordOperation
query
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
SimpleRecordOperation
query
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
connectionFactory
.
getConnection
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
connectionFactoryControl
.
setReturnValue
(
connection
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
);
interaction
.
execute
(
interactionSpec
,
inputRecord
);
expect
(
interaction
.
execute
(
interactionSpec
,
inputRecord
)).
andReturn
(
outputRecord
);
interactionControl
.
setReturnValue
(
outputRecord
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
replay
();
interactionControl
.
replay
();
query
.
execute
(
inputRecord
);
query
.
execute
(
inputRecord
);
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
verify
();
interactionControl
.
verify
();
}
}
@Test
public
void
testSimpleRecordOperationWithExplicitOutputRecord
()
throws
ResourceException
{
public
void
testSimpleRecordOperationWithExplicitOutputRecord
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
MockControl
inputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
inputRecord
=
createMock
(
Record
.
class
);
Record
inputRecord
=
(
Record
)
inputRecordControl
.
getMock
();
Record
outputRecord
=
createMock
(
Record
.
class
);
MockControl
outputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
outputRecord
=
(
Record
)
outputRecordControl
.
getMock
();
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
SimpleRecordOperation
operation
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
SimpleRecordOperation
operation
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
connectionFactory
.
getConnection
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionFactoryControl
.
setReturnValue
(
connection
,
1
);
connection
.
createInteraction
();
connectionControl
.
setReturnValue
(
interaction
,
1
);
interaction
.
execute
(
interactionSpec
,
inputRecord
,
outputRecord
);
expect
(
interaction
.
execute
(
interactionSpec
,
inputRecord
,
outputRecord
)).
andReturn
(
true
);
interactionControl
.
setReturnValue
(
true
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
replay
();
interactionControl
.
replay
();
operation
.
execute
(
inputRecord
,
outputRecord
);
operation
.
execute
(
inputRecord
,
outputRecord
);
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
verify
();
interactionControl
.
verify
();
}
}
@Test
public
void
testSimpleRecordOperationWithInputOutputRecord
()
throws
ResourceException
{
public
void
testSimpleRecordOperationWithInputOutputRecord
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
MockControl
inputOutputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
inputOutputRecord
=
createMock
(
Record
.
class
);
Record
inputOutputRecord
=
(
Record
)
inputOutputRecordControl
.
getMock
();
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
SimpleRecordOperation
query
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
SimpleRecordOperation
query
=
new
SimpleRecordOperation
(
connectionFactory
,
interactionSpec
);
connectionFactory
.
getConnection
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
connectionFactoryControl
.
setReturnValue
(
connection
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
);
interaction
.
execute
(
interactionSpec
,
inputOutputRecord
,
inputOutputRecord
);
expect
(
interaction
.
execute
(
interactionSpec
,
inputOutputRecord
,
inputOutputRecord
)).
andReturn
(
true
);
interactionControl
.
setReturnValue
(
true
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
replay
();
interactionControl
.
replay
();
query
.
execute
(
inputOutputRecord
,
inputOutputRecord
);
query
.
execute
(
inputOutputRecord
,
inputOutputRecord
);
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
interaction
);
connectionControl
.
verify
();
interactionControl
.
verify
();
}
}
@Test
public
void
testMappingRecordOperation
()
throws
ResourceException
{
public
void
testMappingRecordOperation
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
recordFactoryControl
=
MockControl
.
createStrictControl
(
RecordFactory
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
RecordFactory
recordFactory
=
(
RecordFactory
)
recordFactoryControl
.
getMock
();
RecordFactory
recordFactory
=
createMock
(
RecordFactory
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
Record
inputRecord
=
createMock
(
Record
.
class
);
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
Record
outputRecord
=
createMock
(
Record
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
MockControl
inputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
inputRecord
=
(
Record
)
inputRecordControl
.
getMock
();
QueryCallDetector
callDetector
=
createMock
(
QueryCallDetector
.
class
);
MockControl
outputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
outputRecord
=
(
Record
)
outputRecordControl
.
getMock
();
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
MockControl
callDetectorControl
=
MockControl
.
createControl
(
QueryCallDetector
.
class
);
QueryCallDetector
callDetector
=
(
QueryCallDetector
)
callDetectorControl
.
getMock
();
MappingRecordOperationImpl
query
=
new
MappingRecordOperationImpl
(
connectionFactory
,
interactionSpec
);
MappingRecordOperationImpl
query
=
new
MappingRecordOperationImpl
(
connectionFactory
,
interactionSpec
);
query
.
setCallDetector
(
callDetector
);
query
.
setCallDetector
(
callDetector
);
...
@@ -193,65 +147,44 @@ public class EisOperationTests extends TestCase {
...
@@ -193,65 +147,44 @@ public class EisOperationTests extends TestCase {
Object
inObj
=
new
Object
();
Object
inObj
=
new
Object
();
Object
outObj
=
new
Object
();
Object
outObj
=
new
Object
();
connectionFactory
.
getRecordFactory
();
expect
(
connectionFactory
.
getRecordFactory
()).
andReturn
(
recordFactory
);
connectionFactoryControl
.
setReturnValue
(
recordFactory
,
1
);
callDetector
.
callCreateInputRecord
(
recordFactory
,
inObj
);
expect
(
callDetector
.
callCreateInputRecord
(
recordFactory
,
inObj
)).
andReturn
(
inputRecord
);
callDetectorControl
.
setReturnValue
(
inputRecord
,
1
);
connectionFactory
.
getConnection
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
connectionFactoryControl
.
setReturnValue
(
connection
,
1
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
,
1
);
interaction
.
execute
(
interactionSpec
,
inputRecord
);
expect
(
interaction
.
execute
(
interactionSpec
,
inputRecord
)).
andReturn
(
outputRecord
);
interactionControl
.
setReturnValue
(
outputRecord
,
1
);
callDetector
.
callExtractOutputData
(
outputRecord
);
expect
(
callDetector
.
callExtractOutputData
(
outputRecord
)).
andReturn
(
outObj
);
callDetectorControl
.
setReturnValue
(
outObj
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
interaction
,
callDetector
);
connectionControl
.
replay
();
interactionControl
.
replay
();
callDetectorControl
.
replay
();
assertSame
(
outObj
,
query
.
execute
(
inObj
));
assertSame
(
outObj
,
query
.
execute
(
inObj
));
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
interaction
,
callDetector
);
connectionControl
.
verify
();
interactionControl
.
verify
();
callDetectorControl
.
verify
();
}
}
@Test
public
void
testMappingRecordOperationWithOutputRecordCreator
()
throws
ResourceException
{
public
void
testMappingRecordOperationWithOutputRecordCreator
()
throws
ResourceException
{
MockControl
connectionFactoryControl
=
MockControl
.
createControl
(
ConnectionFactory
.
class
);
ConnectionFactory
connectionFactory
=
createMock
(
ConnectionFactory
.
class
);
final
ConnectionFactory
connectionFactory
=
(
ConnectionFactory
)
connectionFactoryControl
.
getMock
();
Connection
connection
=
createMock
(
Connection
.
class
);
MockControl
recordFactoryControl
=
MockControl
.
createStrictControl
(
RecordFactory
.
class
);
Interaction
interaction
=
createMock
(
Interaction
.
class
);
RecordFactory
recordFactory
=
(
RecordFactory
)
recordFactoryControl
.
getMock
();
RecordFactory
recordFactory
=
createMock
(
RecordFactory
.
class
);
MockControl
connectionControl
=
MockControl
.
createControl
(
Connection
.
class
);
Connection
connection
=
(
Connection
)
connectionControl
.
getMock
();
Record
inputRecord
=
createMock
(
Record
.
class
);
MockControl
interactionControl
=
MockControl
.
createControl
(
Interaction
.
class
);
Record
outputRecord
=
createMock
(
Record
.
class
);
Interaction
interaction
=
(
Interaction
)
interactionControl
.
getMock
();
RecordCreator
outputCreator
=
createMock
(
RecordCreator
.
class
);
MockControl
inputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
inputRecord
=
(
Record
)
inputRecordControl
.
getMock
();
InteractionSpec
interactionSpec
=
createMock
(
InteractionSpec
.
class
);
MockControl
outputRecordControl
=
MockControl
.
createControl
(
Record
.
class
);
Record
outputRecord
=
(
Record
)
outputRecordControl
.
getMock
();
QueryCallDetector
callDetector
=
createMock
(
QueryCallDetector
.
class
);
MockControl
outputCreatorControl
=
MockControl
.
createControl
(
RecordCreator
.
class
);
RecordCreator
outputCreator
=
(
RecordCreator
)
outputCreatorControl
.
getMock
();
MockControl
interactionSpecControl
=
MockControl
.
createControl
(
InteractionSpec
.
class
);
InteractionSpec
interactionSpec
=
(
InteractionSpec
)
interactionSpecControl
.
getMock
();
MockControl
callDetectorControl
=
MockControl
.
createControl
(
QueryCallDetector
.
class
);
QueryCallDetector
callDetector
=
(
QueryCallDetector
)
callDetectorControl
.
getMock
();
MappingRecordOperationImpl
query
=
new
MappingRecordOperationImpl
(
connectionFactory
,
interactionSpec
);
MappingRecordOperationImpl
query
=
new
MappingRecordOperationImpl
(
connectionFactory
,
interactionSpec
);
query
.
setOutputRecordCreator
(
outputCreator
);
query
.
setOutputRecordCreator
(
outputCreator
);
...
@@ -260,49 +193,31 @@ public class EisOperationTests extends TestCase {
...
@@ -260,49 +193,31 @@ public class EisOperationTests extends TestCase {
Object
inObj
=
new
Object
();
Object
inObj
=
new
Object
();
Object
outObj
=
new
Object
();
Object
outObj
=
new
Object
();
connectionFactory
.
getRecordFactory
();
expect
(
connectionFactory
.
getRecordFactory
()).
andReturn
(
recordFactory
);
connectionFactoryControl
.
setReturnValue
(
recordFactory
,
1
);
callDetector
.
callCreateInputRecord
(
recordFactory
,
inObj
);
expect
(
callDetector
.
callCreateInputRecord
(
recordFactory
,
inObj
)).
andReturn
(
inputRecord
);
callDetectorControl
.
setReturnValue
(
inputRecord
,
1
);
connectionFactory
.
getConnection
();
expect
(
connectionFactory
.
getConnection
()).
andReturn
(
connection
);
connectionFactoryControl
.
setReturnValue
(
connection
,
1
);
connection
.
createInteraction
();
expect
(
connection
.
createInteraction
()).
andReturn
(
interaction
);
connectionControl
.
setReturnValue
(
interaction
,
1
);
connectionFactory
.
getRecordFactory
();
expect
(
connectionFactory
.
getRecordFactory
()).
andReturn
(
recordFactory
);
connectionFactoryControl
.
setReturnValue
(
recordFactory
,
1
);
outputCreator
.
createRecord
(
recordFactory
);
expect
(
outputCreator
.
createRecord
(
recordFactory
)).
andReturn
(
outputRecord
);
outputCreatorControl
.
setReturnValue
(
outputRecord
,
1
);
interaction
.
execute
(
interactionSpec
,
inputRecord
,
outputRecord
);
expect
(
interaction
.
execute
(
interactionSpec
,
inputRecord
,
outputRecord
)).
andReturn
(
true
);
interactionControl
.
setReturnValue
(
true
,
1
);
callDetector
.
callExtractOutputData
(
outputRecord
);
expect
(
callDetector
.
callExtractOutputData
(
outputRecord
)).
andReturn
(
outObj
);
callDetectorControl
.
setReturnValue
(
outObj
,
1
);
interaction
.
close
();
interaction
.
close
();
interactionControl
.
setVoidCallable
(
1
);
connection
.
close
();
connection
.
close
();
connectionControl
.
setVoidCallable
(
1
);
connectionFactoryControl
.
replay
();
replay
(
connectionFactory
,
connection
,
interaction
,
outputCreator
,
callDetector
);
connectionControl
.
replay
();
interactionControl
.
replay
();
outputCreatorControl
.
replay
();
callDetectorControl
.
replay
();
assertSame
(
outObj
,
query
.
execute
(
inObj
));
assertSame
(
outObj
,
query
.
execute
(
inObj
));
connectionFactoryControl
.
verify
();
verify
(
connectionFactory
,
connection
,
interaction
,
outputCreator
,
callDetector
);
connectionControl
.
verify
();
interactionControl
.
verify
();
outputCreatorControl
.
verify
();
callDetectorControl
.
verify
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录