Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
80b8fb8b
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,发现更多精彩内容 >>
提交
80b8fb8b
编写于
2月 23, 2010
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[SPR-6879] @DirtiesContext is now an @Inherited annotation.
上级
ef227c5d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
16 deletion
+55
-16
org.springframework.test/src/main/java/org/springframework/test/annotation/DirtiesContext.java
...a/org/springframework/test/annotation/DirtiesContext.java
+2
-0
org.springframework.test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTests.java
...framework/test/context/ClassLevelDirtiesContextTests.java
+53
-16
未找到文件。
org.springframework.test/src/main/java/org/springframework/test/annotation/DirtiesContext.java
浏览文件 @
80b8fb8b
...
...
@@ -18,6 +18,7 @@ package org.springframework.test.annotation;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
...
...
@@ -54,6 +55,7 @@ import java.lang.annotation.Target;
* @since 2.0
*/
@Documented
@Inherited
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
{
ElementType
.
TYPE
,
ElementType
.
METHOD
})
public
@interface
DirtiesContext
{
...
...
org.springframework.test/src/test/java/org/springframework/test/context/ClassLevelDirtiesContextTests.java
浏览文件 @
80b8fb8b
...
...
@@ -103,50 +103,71 @@ public class ClassLevelDirtiesContextTests {
@Test
public
void
verifyDirtiesContextBehavior
()
throws
Exception
{
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with clean test method and default class mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
.
class
,
1
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with clean test method and default class mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with clean test method and AFTER_CLASS mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
.
class
,
1
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with clean test method and AFTER_CLASS mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
.
class
,
3
);
assertCacheStats
(
"after class-level @DirtiesContext with clean test method and AFTER_EACH_TEST_METHOD mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
addAndGet
(
2
));
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
.
class
,
3
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with clean test method and AFTER_EACH_TEST_METHOD mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
addAndGet
(
2
));
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
runTestClassAndAssertStats
(
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
.
class
,
1
);
assertCacheStats
(
"after inherited class-level @DirtiesContext with dirty test method"
,
0
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
assertBehaviorForCleanTestCase
();
runTestClassAndAssertStats
(
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
.
class
,
1
);
assertCacheStats
(
"after class-level @DirtiesContext with clean test method and AFTER_CLASS mode"
,
0
,
cacheHits
.
incrementAndGet
(),
cacheMisses
.
get
());
}
private
void
assertBehaviorForCleanTestCase
()
{
runTestClassAndAssertStats
(
CleanTestCase
.
class
,
1
);
assertCacheStats
(
"after clean test class"
,
1
,
cacheHits
.
get
(),
cacheMisses
.
incrementAndGet
());
}
@AfterClass
public
static
void
verifyFinalCacheState
()
{
assertCacheStats
(
"AfterClass"
,
0
,
cacheHits
.
get
(),
cacheMisses
.
get
());
...
...
@@ -180,7 +201,7 @@ public class ClassLevelDirtiesContextTests {
}
@DirtiesContext
public
static
final
class
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
BaseTestCase
{
public
static
class
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
BaseTestCase
{
@Test
public
void
verifyContextWasAutowired
()
{
...
...
@@ -188,8 +209,12 @@ public class ClassLevelDirtiesContextTests {
}
}
public
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
extends
ClassLevelDirtiesContextWithCleanMethodsAndDefaultModeTestCase
{
}
@DirtiesContext
(
classMode
=
ClassMode
.
AFTER_CLASS
)
public
static
final
class
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
BaseTestCase
{
public
static
class
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
BaseTestCase
{
@Test
public
void
verifyContextWasAutowired
()
{
...
...
@@ -197,8 +222,12 @@ public class ClassLevelDirtiesContextTests {
}
}
public
static
class
InheritedClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
extends
ClassLevelDirtiesContextWithCleanMethodsAndAfterClassModeTestCase
{
}
@DirtiesContext
(
classMode
=
ClassMode
.
AFTER_EACH_TEST_METHOD
)
public
static
final
class
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
BaseTestCase
{
public
static
class
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
BaseTestCase
{
@Test
public
void
verifyContextWasAutowired1
()
{
...
...
@@ -216,8 +245,12 @@ public class ClassLevelDirtiesContextTests {
}
}
public
static
class
InheritedClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
extends
ClassLevelDirtiesContextWithAfterEachTestMethodModeTestCase
{
}
@DirtiesContext
public
static
final
class
ClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
BaseTestCase
{
public
static
class
ClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
BaseTestCase
{
@Test
@DirtiesContext
...
...
@@ -226,4 +259,8 @@ public class ClassLevelDirtiesContextTests {
}
}
public
static
class
InheritedClassLevelDirtiesContextWithDirtyMethodsTestCase
extends
ClassLevelDirtiesContextWithDirtyMethodsTestCase
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录