Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
0392a88c
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,体验更适合开发者的 AI 搜索 >>
提交
0392a88c
编写于
4月 18, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move static ContextCache to DefaultCacheAwareContextLoaderDelegate
Issue: SPR-12683
上级
0e287c1a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
16 deletion
+29
-16
spring-test/src/main/java/org/springframework/test/context/DefaultCacheAwareContextLoaderDelegate.java
.../test/context/DefaultCacheAwareContextLoaderDelegate.java
+22
-1
spring-test/src/main/java/org/springframework/test/context/TestContextManager.java
.../org/springframework/test/context/TestContextManager.java
+2
-10
spring-test/src/test/java/org/springframework/test/context/ContextCacheTestUtils.java
...g/springframework/test/context/ContextCacheTestUtils.java
+5
-5
未找到文件。
spring-test/src/main/java/org/springframework/test/context/DefaultCacheAwareContextLoaderDelegate.java
浏览文件 @
0392a88c
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
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.
...
...
@@ -40,9 +40,30 @@ class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContextLoaderD
private
static
final
Log
statsLogger
=
LogFactory
.
getLog
(
"org.springframework.test.context.cache"
);
/**
* Default cache of Spring application contexts.
*
* <p>This default cache is static, so that each context can be cached
* and reused for all subsequent tests that declare the same unique
* context configuration within the same JVM process.
*/
static
final
ContextCache
defaultContextCache
=
new
ContextCache
();
private
final
ContextCache
contextCache
;
/**
* Construct a new {@code DefaultCacheAwareContextLoaderDelegate} that
* uses the default, static {@code ContextCache}.
*/
DefaultCacheAwareContextLoaderDelegate
()
{
this
(
defaultContextCache
);
}
/**
* Construct a new {@code DefaultCacheAwareContextLoaderDelegate} with
* the supplied {@code ContextCache}.
*/
DefaultCacheAwareContextLoaderDelegate
(
ContextCache
contextCache
)
{
Assert
.
notNull
(
contextCache
,
"ContextCache must not be null"
);
this
.
contextCache
=
contextCache
;
...
...
spring-test/src/main/java/org/springframework/test/context/TestContextManager.java
浏览文件 @
0392a88c
...
...
@@ -73,14 +73,6 @@ public class TestContextManager {
private
static
final
Log
logger
=
LogFactory
.
getLog
(
TestContextManager
.
class
);
/**
* Cache of Spring application contexts.
* <p>This needs to be static, since test instances may be destroyed and
* recreated between invocations of individual test methods, as is the case
* with JUnit.
*/
static
final
ContextCache
contextCache
=
new
ContextCache
();
private
final
TestContext
testContext
;
private
final
List
<
TestExecutionListener
>
testExecutionListeners
=
new
ArrayList
<
TestExecutionListener
>();
...
...
@@ -88,14 +80,14 @@ public class TestContextManager {
/**
* Construct a new {@code TestContextManager} for the specified {@linkplain Class test class}
* and automatically {@link #registerTestExecutionListeners register} the
* and automatically {@link
plain
#registerTestExecutionListeners register} the
* {@link TestExecutionListener TestExecutionListeners} configured for the test class
* via the {@link TestExecutionListeners @TestExecutionListeners} annotation.
* @param testClass the test class to be managed
* @see #registerTestExecutionListeners
*/
public
TestContextManager
(
Class
<?>
testClass
)
{
CacheAwareContextLoaderDelegate
cacheAwareContextLoaderDelegate
=
new
DefaultCacheAwareContextLoaderDelegate
(
contextCache
);
CacheAwareContextLoaderDelegate
cacheAwareContextLoaderDelegate
=
new
DefaultCacheAwareContextLoaderDelegate
();
BootstrapContext
bootstrapContext
=
new
DefaultBootstrapContext
(
testClass
,
cacheAwareContextLoaderDelegate
);
TestContextBootstrapper
testContextBootstrapper
=
BootstrapUtils
.
resolveTestContextBootstrapper
(
bootstrapContext
);
this
.
testContext
=
new
DefaultTestContext
(
testContextBootstrapper
);
...
...
spring-test/src/test/java/org/springframework/test/context/ContextCacheTestUtils.java
浏览文件 @
0392a88c
...
...
@@ -28,14 +28,14 @@ import static org.junit.Assert.*;
public
class
ContextCacheTestUtils
{
/**
* Reset the state of the
context cache
.
* Reset the state of the
static context cache in {@link DefaultCacheAwareContextLoaderDelegate}
.
*/
public
static
final
void
resetContextCache
()
{
TestContextManager
.
c
ontextCache
.
reset
();
DefaultCacheAwareContextLoaderDelegate
.
defaultC
ontextCache
.
reset
();
}
/**
* Assert the statistics of the
context cache in {@link TestContextManager
}.
* Assert the statistics of the
static context cache in {@link DefaultCacheAwareContextLoaderDelegate
}.
*
* @param usageScenario the scenario in which the statistics are used
* @param expectedSize the expected number of contexts in the cache
...
...
@@ -44,8 +44,8 @@ public class ContextCacheTestUtils {
*/
public
static
final
void
assertContextCacheStatistics
(
String
usageScenario
,
int
expectedSize
,
int
expectedHitCount
,
int
expectedMissCount
)
{
assertContextCacheStatistics
(
TestContextManager
.
contextCache
,
usageScenario
,
expectedSize
,
expectedHitCount
,
expectedMissCount
);
assertContextCacheStatistics
(
DefaultCacheAwareContextLoaderDelegate
.
defaultContextCache
,
usageScenario
,
expected
Size
,
expectedHitCount
,
expected
MissCount
);
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录