Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
chenpeng_fei
spring-framework
提交
525d1112
S
spring-framework
项目概览
chenpeng_fei
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
525d1112
编写于
9月 24, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
75ea6f56
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
31 addition
and
17 deletion
+31
-17
spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java
...rg/springframework/cache/ehcache/EhCacheCacheManager.java
+6
-6
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java
...ringframework/cache/ehcache/EhCacheCacheManagerTests.java
+7
-2
spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java
...springframework/cache/jcache/JCacheCacheManagerTests.java
+9
-2
spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java
...ction/AbstractTransactionSupportingCacheManagerTests.java
+9
-7
未找到文件。
spring-context-support/src/main/java/org/springframework/cache/ehcache/EhCacheCacheManager.java
浏览文件 @
525d1112
/*
* 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.
...
...
@@ -24,7 +24,6 @@ import net.sf.ehcache.Status;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager
;
import
org.springframework.util.Assert
;
/**
* CacheManager backed by an EhCache {@link net.sf.ehcache.CacheManager}.
...
...
@@ -81,8 +80,10 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag
@Override
protected
Collection
<
Cache
>
loadCaches
()
{
Status
status
=
getCacheManager
().
getStatus
();
Assert
.
isTrue
(
Status
.
STATUS_ALIVE
.
equals
(
status
),
"An 'alive' EhCache CacheManager is required - current cache is "
+
status
.
toString
());
if
(!
Status
.
STATUS_ALIVE
.
equals
(
status
))
{
throw
new
IllegalStateException
(
"An 'alive' EhCache CacheManager is required - current cache is "
+
status
.
toString
());
}
String
[]
names
=
getCacheManager
().
getCacheNames
();
Collection
<
Cache
>
caches
=
new
LinkedHashSet
<
Cache
>(
names
.
length
);
...
...
@@ -94,8 +95,7 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag
@Override
protected
Cache
getMissingCache
(
String
name
)
{
// check the EhCache cache again
// (in case the cache was added at runtime)
// Check the EhCache cache again (in case the cache was added at runtime)
Ehcache
ehcache
=
getCacheManager
().
getEhcache
(
name
);
if
(
ehcache
!=
null
)
{
return
new
EhCacheCache
(
ehcache
);
...
...
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java
浏览文件 @
525d1112
/*
* 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.
...
...
@@ -30,9 +30,12 @@ import org.springframework.cache.transaction.AbstractTransactionSupportingCacheM
public
class
EhCacheCacheManagerTests
extends
AbstractTransactionSupportingCacheManagerTests
<
EhCacheCacheManager
>
{
private
CacheManager
nativeCacheManager
;
private
EhCacheCacheManager
cacheManager
;
private
EhCacheCacheManager
transactionalCacheManager
;
@Before
public
void
setup
()
{
nativeCacheManager
=
new
CacheManager
(
new
Configuration
().
name
(
"EhCacheCacheManagerTests"
)
...
...
@@ -58,7 +61,8 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache
protected
EhCacheCacheManager
getCacheManager
(
boolean
transactionAware
)
{
if
(
transactionAware
)
{
return
transactionalCacheManager
;
}
else
{
}
else
{
return
cacheManager
;
}
}
...
...
@@ -77,4 +81,5 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache
protected
void
removeNativeCache
(
String
cacheName
)
{
nativeCacheManager
.
removeCache
(
cacheName
);
}
}
spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java
浏览文件 @
525d1112
/*
* 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.
...
...
@@ -33,9 +33,12 @@ import static org.mockito.BDDMockito.*;
public
class
JCacheCacheManagerTests
extends
AbstractTransactionSupportingCacheManagerTests
<
JCacheCacheManager
>
{
private
CacheManagerMock
cacheManagerMock
;
private
JCacheCacheManager
cacheManager
;
private
JCacheCacheManager
transactionalCacheManager
;
@Before
public
void
setupOnce
()
{
cacheManagerMock
=
new
CacheManagerMock
();
...
...
@@ -55,7 +58,8 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
protected
JCacheCacheManager
getCacheManager
(
boolean
transactionAware
)
{
if
(
transactionAware
)
{
return
transactionalCacheManager
;
}
else
{
}
else
{
return
cacheManager
;
}
}
...
...
@@ -75,9 +79,11 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
cacheManagerMock
.
removeCache
(
cacheName
);
}
private
static
class
CacheManagerMock
{
private
final
List
<
String
>
cacheNames
;
private
final
CacheManager
cacheManager
;
private
CacheManagerMock
()
{
...
...
@@ -103,4 +109,5 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
given
(
cacheManager
.
getCache
(
name
)).
willReturn
(
null
);
}
}
}
spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java
浏览文件 @
525d1112
/*
* 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.
...
...
@@ -42,11 +42,10 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
/**
* Returns the {@link CacheManager} to use.
*
* @param transactionAware if the requested cache manager should be aware
* of the transaction
* @return the cache manager to use
* @see org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager#setTransactionAware
(boolean)
* @see org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager#setTransactionAware
*/
protected
abstract
T
getCacheManager
(
boolean
transactionAware
);
...
...
@@ -65,6 +64,7 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
*/
protected
abstract
void
removeNativeCache
(
String
cacheName
);
@Test
public
void
getOnExistingCache
()
{
assertThat
(
getCacheManager
(
false
).
getCache
(
CACHE_NAME
),
is
(
instanceOf
(
getCacheType
())));
...
...
@@ -77,10 +77,10 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
addNativeCache
(
cacheName
);
assertFalse
(
cacheManager
.
getCacheNames
().
contains
(
cacheName
));
try
{
assertThat
(
cacheManager
.
getCache
(
cacheName
),
is
(
instanceOf
(
getCacheType
())));
assertThat
(
cacheManager
.
getCache
(
cacheName
),
is
(
instanceOf
(
getCacheType
())));
assertTrue
(
cacheManager
.
getCacheNames
().
contains
(
cacheName
));
}
finally
{
}
finally
{
removeNativeCache
(
cacheName
);
}
}
...
...
@@ -109,8 +109,10 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
assertThat
(
cacheManager
.
getCache
(
cacheName
),
is
(
instanceOf
(
TransactionAwareCacheDecorator
.
class
)));
assertTrue
(
cacheManager
.
getCacheNames
().
contains
(
cacheName
));
}
finally
{
}
finally
{
removeNativeCache
(
cacheName
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录