Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
197434b3
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,发现更多精彩内容 >>
提交
197434b3
编写于
2月 29, 2016
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish TestNG integration tests
上级
81618523
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
55 addition
and
55 deletion
+55
-55
spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java
...st/context/cache/ClassLevelDirtiesContextTestNGTests.java
+18
-18
spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java
...nnotationConfigTransactionalTestNGSpringContextTests.java
+11
-11
spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java
...testng/ConcreteTransactionalTestNGSpringContextTests.java
+11
-11
spring-test/src/test/java/org/springframework/test/context/testng/web/ServletTestExecutionListenerTestNGIntegrationTests.java
...b/ServletTestExecutionListenerTestNGIntegrationTests.java
+3
-3
spring-test/src/test/java/org/springframework/test/context/testng/web/TestNGSpringContextWebTests.java
.../test/context/testng/web/TestNGSpringContextWebTests.java
+12
-12
未找到文件。
spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java
浏览文件 @
197434b3
/*
* Copyright 2002-201
5
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -171,7 +171,7 @@ public class ClassLevelDirtiesContextTestNGTests {
@TestExecutionListeners
(
listeners
=
{
DependencyInjectionTestExecutionListener
.
class
,
DirtiesContextTestExecutionListener
.
class
},
inheritListeners
=
false
)
@ContextConfiguration
public
static
abstract
class
BaseTestCase
extends
AbstractTestNGSpringContextTests
{
static
abstract
class
BaseTestCase
extends
AbstractTestNGSpringContextTests
{
@Configuration
static
class
Config
{
...
...
@@ -189,75 +189,75 @@ public class ClassLevelDirtiesContextTestNGTests {
}
}
public
static
final
class
CleanTestCase
extends
BaseTestCase
{
static
final
class
CleanTestCase
extends
BaseTestCase
{
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired
()
{
void
verifyContextWasAutowired
()
{
assertApplicationContextWasAutowired
();
}
}
@DirtiesContext
public
static
class
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
BaseTestCase
{
static
class
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
BaseTestCase
{
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired
()
{
void
verifyContextWasAutowired
()
{
assertApplicationContextWasAutowired
();
}
}
public
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
{
}
@DirtiesContext
(
classMode
=
ClassMode
.
AFTER_CLASS
)
public
static
class
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
BaseTestCase
{
static
class
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
BaseTestCase
{
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired
()
{
void
verifyContextWasAutowired
()
{
assertApplicationContextWasAutowired
();
}
}
public
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
{
}
@DirtiesContext
(
classMode
=
ClassMode
.
AFTER_EACH_TEST_METHOD
)
public
static
class
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
BaseTestCase
{
static
class
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
BaseTestCase
{
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired1
()
{
void
verifyContextWasAutowired1
()
{
assertApplicationContextWasAutowired
();
}
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired2
()
{
void
verifyContextWasAutowired2
()
{
assertApplicationContextWasAutowired
();
}
@org
.
testng
.
annotations
.
Test
public
void
verifyContextWasAutowired3
()
{
void
verifyContextWasAutowired3
()
{
assertApplicationContextWasAutowired
();
}
}
public
static
class
InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
static
class
InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
{
}
@DirtiesContext
public
static
class
ClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
BaseTestCase
{
static
class
ClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
BaseTestCase
{
@org
.
testng
.
annotations
.
Test
@DirtiesContext
public
void
dirtyContext
()
{
void
dirtyContext
()
{
assertApplicationContextWasAutowired
();
}
}
public
static
class
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
static
class
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
ClassLevelDirtiesContextWithDirtyMethodsTestCase
{
}
...
...
spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTransactionalTestNGSpringContextTests.java
浏览文件 @
197434b3
...
...
@@ -54,8 +54,8 @@ import static org.testng.Assert.*;
* @since 3.1
*/
@ContextConfiguration
public
class
AnnotationConfigTransactionalTestNGSpringContextTests
extends
AbstractTransactionalTestNGSpringContextTests
{
public
class
AnnotationConfigTransactionalTestNGSpringContextTests
extends
AbstractTransactionalTestNGSpringContextTests
{
private
static
final
String
JANE
=
"jane"
;
private
static
final
String
SUE
=
"sue"
;
...
...
@@ -94,7 +94,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
}
@BeforeClass
public
void
beforeClass
()
{
void
beforeClass
()
{
numSetUpCalls
=
0
;
numSetUpCallsInTransaction
=
0
;
numTearDownCalls
=
0
;
...
...
@@ -102,7 +102,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
}
@AfterClass
public
void
afterClass
()
{
void
afterClass
()
{
assertEquals
(
numSetUpCalls
,
NUM_TESTS
,
"number of calls to setUp()."
);
assertEquals
(
numSetUpCallsInTransaction
,
NUM_TX_TESTS
,
"number of calls to setUp() within a transaction."
);
assertEquals
(
numTearDownCalls
,
NUM_TESTS
,
"number of calls to tearDown()."
);
...
...
@@ -111,7 +111,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
autowiringFromConfigClass
()
{
void
autowiringFromConfigClass
()
{
assertNotNull
(
employee
,
"The employee should have been autowired."
);
assertEquals
(
employee
.
getName
(),
"John Smith"
);
...
...
@@ -126,7 +126,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
}
@BeforeMethod
public
void
setUp
()
throws
Exception
{
void
setUp
()
throws
Exception
{
numSetUpCalls
++;
if
(
inTransaction
())
{
numSetUpCallsInTransaction
++;
...
...
@@ -143,7 +143,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
}
@AfterMethod
public
void
tearDown
()
throws
Exception
{
void
tearDown
()
throws
Exception
{
numTearDownCalls
++;
if
(
inTransaction
())
{
numTearDownCallsInTransaction
++;
...
...
@@ -162,7 +162,7 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
static
class
ContextConfiguration
{
@Bean
public
Employee
employee
()
{
Employee
employee
()
{
Employee
employee
=
new
Employee
();
employee
.
setName
(
"John Smith"
);
employee
.
setAge
(
42
);
...
...
@@ -171,17 +171,17 @@ public class AnnotationConfigTransactionalTestNGSpringContextTests extends
}
@Bean
public
Pet
pet
()
{
Pet
pet
()
{
return
new
Pet
(
"Fido"
);
}
@Bean
public
PlatformTransactionManager
transactionManager
()
{
PlatformTransactionManager
transactionManager
()
{
return
new
DataSourceTransactionManager
(
dataSource
());
}
@Bean
public
DataSource
dataSource
()
{
DataSource
dataSource
()
{
return
new
EmbeddedDatabaseBuilder
()
//
.
addScript
(
"classpath:/org/springframework/test/jdbc/schema.sql"
)
//
.
addScript
(
"classpath:/org/springframework/test/jdbc/data.sql"
)
//
...
...
spring-test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java
浏览文件 @
197434b3
...
...
@@ -117,7 +117,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
}
@BeforeClass
public
void
beforeClass
()
{
void
beforeClass
()
{
numSetUpCalls
=
0
;
numSetUpCallsInTransaction
=
0
;
numTearDownCalls
=
0
;
...
...
@@ -125,7 +125,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
}
@AfterClass
public
void
afterClass
()
{
void
afterClass
()
{
assertEquals
(
numSetUpCalls
,
NUM_TESTS
,
"number of calls to setUp()."
);
assertEquals
(
numSetUpCallsInTransaction
,
NUM_TX_TESTS
,
"number of calls to setUp() within a transaction."
);
assertEquals
(
numTearDownCalls
,
NUM_TESTS
,
"number of calls to tearDown()."
);
...
...
@@ -134,7 +134,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyApplicationContextSet
()
{
void
verifyApplicationContextSet
()
{
assertInTransaction
(
false
);
assertNotNull
(
super
.
applicationContext
,
"The application context should have been set due to ApplicationContextAware semantics."
);
...
...
@@ -144,7 +144,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyBeanInitialized
()
{
void
verifyBeanInitialized
()
{
assertInTransaction
(
false
);
assertTrue
(
beanInitialized
,
"This test instance should have been initialized due to InitializingBean semantics."
);
...
...
@@ -152,7 +152,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyBeanNameSet
()
{
void
verifyBeanNameSet
()
{
assertInTransaction
(
false
);
assertEquals
(
beanName
,
getClass
().
getName
(),
"The bean name of this test instance should have been set due to BeanNameAware semantics."
);
...
...
@@ -160,7 +160,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyAnnotationAutowiredFields
()
{
void
verifyAnnotationAutowiredFields
()
{
assertInTransaction
(
false
);
assertNull
(
nonrequiredLong
,
"The nonrequiredLong field should NOT have been autowired."
);
assertNotNull
(
pet
,
"The pet field should have been autowired."
);
...
...
@@ -169,7 +169,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyAnnotationAutowiredMethods
()
{
void
verifyAnnotationAutowiredMethods
()
{
assertInTransaction
(
false
);
assertNotNull
(
employee
,
"The setEmployee() method should have been autowired."
);
assertEquals
(
employee
.
getName
(),
"John Smith"
,
"employee's name."
);
...
...
@@ -177,14 +177,14 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyResourceAnnotationInjectedFields
()
{
void
verifyResourceAnnotationInjectedFields
()
{
assertInTransaction
(
false
);
assertEquals
(
foo
,
"Foo"
,
"The foo field should have been injected via @Resource."
);
}
@Test
@Transactional
(
propagation
=
Propagation
.
NOT_SUPPORTED
)
public
void
verifyResourceAnnotationInjectedMethods
()
{
void
verifyResourceAnnotationInjectedMethods
()
{
assertInTransaction
(
false
);
assertEquals
(
bar
,
"Bar"
,
"The setBar() method should have been injected via @Resource."
);
}
...
...
@@ -196,7 +196,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
}
@BeforeMethod
public
void
setUp
()
throws
Exception
{
void
setUp
()
throws
Exception
{
numSetUpCalls
++;
if
(
inTransaction
())
{
numSetUpCallsInTransaction
++;
...
...
@@ -213,7 +213,7 @@ public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTrans
}
@AfterMethod
public
void
tearDown
()
throws
Exception
{
void
tearDown
()
throws
Exception
{
numTearDownCalls
++;
if
(
inTransaction
())
{
numTearDownCallsInTransaction
++;
...
...
spring-test/src/test/java/org/springframework/test/context/testng/web/ServletTestExecutionListenerTestNGIntegrationTests.java
浏览文件 @
197434b3
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -57,7 +57,7 @@ public class ServletTestExecutionListenerTestNGIntegrationTests extends Abstract
* @see #ensureMocksAreReinjectedBetweenTests_2
*/
@Test
public
void
ensureMocksAreReinjectedBetweenTests_1
()
{
void
ensureMocksAreReinjectedBetweenTests_1
()
{
assertInjectedServletRequestEqualsRequestInRequestContextHolder
();
}
...
...
@@ -67,7 +67,7 @@ public class ServletTestExecutionListenerTestNGIntegrationTests extends Abstract
* @see #ensureMocksAreReinjectedBetweenTests_1
*/
@Test
public
void
ensureMocksAreReinjectedBetweenTests_2
()
{
void
ensureMocksAreReinjectedBetweenTests_2
()
{
assertInjectedServletRequestEqualsRequestInRequestContextHolder
();
}
...
...
spring-test/src/test/java/org/springframework/test/context/testng/web/TestNGSpringContextWebTests.java
浏览文件 @
197434b3
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -52,34 +52,34 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
static
class
Config
{
@Bean
public
String
foo
()
{
String
foo
()
{
return
"enigma"
;
}
}
protected
ServletContext
servletContext
;
ServletContext
servletContext
;
@Autowired
protected
WebApplicationContext
wac
;
WebApplicationContext
wac
;
@Autowired
protected
MockServletContext
mockServletContext
;
MockServletContext
mockServletContext
;
@Autowired
protected
MockHttpServletRequest
request
;
MockHttpServletRequest
request
;
@Autowired
protected
MockHttpServletResponse
response
;
MockHttpServletResponse
response
;
@Autowired
protected
MockHttpSession
session
;
MockHttpSession
session
;
@Autowired
protected
ServletWebRequest
webRequest
;
ServletWebRequest
webRequest
;
@Autowired
protected
String
foo
;
String
foo
;
@Override
...
...
@@ -88,7 +88,7 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
}
@Test
public
void
basicWacFeatures
()
throws
Exception
{
void
basicWacFeatures
()
throws
Exception
{
assertNotNull
(
"ServletContext should be set in the WAC."
,
wac
.
getServletContext
());
assertNotNull
(
"ServletContext should have been set via ServletContextAware."
,
servletContext
);
...
...
@@ -112,7 +112,7 @@ public class TestNGSpringContextWebTests extends AbstractTestNGSpringContextTest
}
@Test
public
void
fooEnigmaAutowired
()
{
void
fooEnigmaAutowired
()
{
assertEquals
(
"enigma"
,
foo
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录