Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
ba425c34
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,发现更多精彩内容 >>
提交
ba425c34
编写于
8月 31, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated to EHCache 1.6.0
上级
86752819
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
27 deletion
+31
-27
org.springframework.context.support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java
...rg/springframework/cache/ehcache/EhCacheSupportTests.java
+31
-27
未找到文件。
org.springframework.context.support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java
浏览文件 @
ba425c34
/*
* Copyright 2002-200
7
the original author or authors.
* Copyright 2002-200
9
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.
...
...
@@ -20,6 +20,7 @@ import junit.framework.TestCase;
import
net.sf.ehcache.Cache
;
import
net.sf.ehcache.CacheManager
;
import
net.sf.ehcache.Ehcache
;
import
net.sf.ehcache.config.CacheConfiguration
;
import
net.sf.ehcache.constructs.blocking.BlockingCache
;
import
net.sf.ehcache.constructs.blocking.CacheEntryFactory
;
import
net.sf.ehcache.constructs.blocking.SelfPopulatingCache
;
...
...
@@ -41,7 +42,7 @@ public class EhCacheSupportTests extends TestCase {
assertTrue
(
"Singleton property"
,
cacheManagerFb
.
isSingleton
());
cacheManagerFb
.
afterPropertiesSet
();
try
{
CacheManager
cm
=
(
CacheManager
)
cacheManagerFb
.
getObject
();
CacheManager
cm
=
cacheManagerFb
.
getObject
();
assertTrue
(
"Loaded CacheManager with no caches"
,
cm
.
getCacheNames
().
length
==
0
);
Cache
myCache1
=
cm
.
getCache
(
"myCache1"
);
assertTrue
(
"No myCache1 defined"
,
myCache1
==
null
);
...
...
@@ -57,11 +58,11 @@ public class EhCacheSupportTests extends TestCase {
cacheManagerFb
.
setCacheManagerName
(
"myCacheManager"
);
cacheManagerFb
.
afterPropertiesSet
();
try
{
CacheManager
cm
=
(
CacheManager
)
cacheManagerFb
.
getObject
();
CacheManager
cm
=
cacheManagerFb
.
getObject
();
assertTrue
(
"Correct number of caches loaded"
,
cm
.
getCacheNames
().
length
==
1
);
Cache
myCache1
=
cm
.
getCache
(
"myCache1"
);
assertFalse
(
"myCache1 is not eternal"
,
myCache1
.
isEternal
());
assertTrue
(
"myCache1.maxElements == 300"
,
myCache1
.
getMaxElementsInMemory
()
==
300
);
assertFalse
(
"myCache1 is not eternal"
,
myCache1
.
getCacheConfiguration
().
isEternal
());
assertTrue
(
"myCache1.maxElements == 300"
,
myCache1
.
get
CacheConfiguration
().
get
MaxElementsInMemory
()
==
300
);
}
finally
{
cacheManagerFb
.
destroy
();
...
...
@@ -87,41 +88,43 @@ public class EhCacheSupportTests extends TestCase {
cacheManagerFb
=
new
EhCacheManagerFactoryBean
();
cacheManagerFb
.
setConfigLocation
(
new
ClassPathResource
(
"testEhcache.xml"
,
getClass
()));
cacheManagerFb
.
afterPropertiesSet
();
cacheFb
.
setCacheManager
(
(
CacheManager
)
cacheManagerFb
.
getObject
());
cacheFb
.
setCacheManager
(
cacheManagerFb
.
getObject
());
}
cacheFb
.
setCacheName
(
"myCache1"
);
cacheFb
.
afterPropertiesSet
();
cache
=
(
Cache
)
cacheFb
.
getObject
();
CacheConfiguration
config
=
cache
.
getCacheConfiguration
();
assertEquals
(
"myCache1"
,
cache
.
getName
());
if
(
useCacheManagerFb
){
assertEquals
(
"myCache1.maxElements"
,
300
,
c
ache
.
getMaxElementsInMemory
());
assertEquals
(
"myCache1.maxElements"
,
300
,
c
onfig
.
getMaxElementsInMemory
());
}
else
{
assertEquals
(
"myCache1.maxElements"
,
10000
,
c
ache
.
getMaxElementsInMemory
());
assertEquals
(
"myCache1.maxElements"
,
10000
,
c
onfig
.
getMaxElementsInMemory
());
}
// Cache region is not defined. Should create one with default properties.
cacheFb
=
new
EhCacheFactoryBean
();
if
(
useCacheManagerFb
)
{
cacheFb
.
setCacheManager
(
(
CacheManager
)
cacheManagerFb
.
getObject
());
cacheFb
.
setCacheManager
(
cacheManagerFb
.
getObject
());
}
cacheFb
.
setCacheName
(
"undefinedCache"
);
cacheFb
.
afterPropertiesSet
();
cache
=
(
Cache
)
cacheFb
.
getObject
();
config
=
cache
.
getCacheConfiguration
();
assertEquals
(
"undefinedCache"
,
cache
.
getName
());
assertTrue
(
"default maxElements is correct"
,
c
ache
.
getMaxElementsInMemory
()
==
10000
);
assertTrue
(
"default overflowToDisk is correct"
,
c
ache
.
isOverflowToDisk
());
assertFalse
(
"default eternal is correct"
,
c
ache
.
isEternal
());
assertTrue
(
"default timeToLive is correct"
,
c
ache
.
getTimeToLiveSeconds
()
==
120
);
assertTrue
(
"default timeToIdle is correct"
,
c
ache
.
getTimeToIdleSeconds
()
==
120
);
assertTrue
(
"default diskPersistent is correct"
,
!
c
ache
.
isDiskPersistent
());
assertTrue
(
"default diskExpiryThreadIntervalSeconds is correct"
,
c
ache
.
getDiskExpiryThreadIntervalSeconds
()
==
120
);
assertTrue
(
"default maxElements is correct"
,
c
onfig
.
getMaxElementsInMemory
()
==
10000
);
assertTrue
(
"default overflowToDisk is correct"
,
c
onfig
.
isOverflowToDisk
());
assertFalse
(
"default eternal is correct"
,
c
onfig
.
isEternal
());
assertTrue
(
"default timeToLive is correct"
,
c
onfig
.
getTimeToLiveSeconds
()
==
120
);
assertTrue
(
"default timeToIdle is correct"
,
c
onfig
.
getTimeToIdleSeconds
()
==
120
);
assertTrue
(
"default diskPersistent is correct"
,
!
c
onfig
.
isDiskPersistent
());
assertTrue
(
"default diskExpiryThreadIntervalSeconds is correct"
,
c
onfig
.
getDiskExpiryThreadIntervalSeconds
()
==
120
);
// overriding the default properties
cacheFb
=
new
EhCacheFactoryBean
();
if
(
useCacheManagerFb
)
{
cacheFb
.
setCacheManager
(
(
CacheManager
)
cacheManagerFb
.
getObject
());
cacheFb
.
setCacheManager
(
cacheManagerFb
.
getObject
());
}
cacheFb
.
setBeanName
(
"undefinedCache2"
);
cacheFb
.
setMaxElementsInMemory
(
5
);
...
...
@@ -133,15 +136,16 @@ public class EhCacheSupportTests extends TestCase {
cacheFb
.
setDiskExpiryThreadIntervalSeconds
(
10
);
cacheFb
.
afterPropertiesSet
();
cache
=
(
Cache
)
cacheFb
.
getObject
();
config
=
cache
.
getCacheConfiguration
();
assertEquals
(
"undefinedCache2"
,
cache
.
getName
());
assertTrue
(
"overridden maxElements is correct"
,
c
ache
.
getMaxElementsInMemory
()
==
5
);
assertFalse
(
"overridden overflowToDisk is correct"
,
c
ache
.
isOverflowToDisk
());
assertTrue
(
"overridden eternal is correct"
,
c
ache
.
isEternal
());
assertTrue
(
"default timeToLive is correct"
,
c
ache
.
getTimeToLiveSeconds
()
==
8
);
assertTrue
(
"default timeToIdle is correct"
,
c
ache
.
getTimeToIdleSeconds
()
==
7
);
assertTrue
(
"overridden diskPersistent is correct"
,
c
ache
.
isDiskPersistent
());
assertTrue
(
"overridden diskExpiryThreadIntervalSeconds is correct"
,
c
ache
.
getDiskExpiryThreadIntervalSeconds
()
==
10
);
assertTrue
(
"overridden maxElements is correct"
,
c
onfig
.
getMaxElementsInMemory
()
==
5
);
assertFalse
(
"overridden overflowToDisk is correct"
,
c
onfig
.
isOverflowToDisk
());
assertTrue
(
"overridden eternal is correct"
,
c
onfig
.
isEternal
());
assertTrue
(
"default timeToLive is correct"
,
c
onfig
.
getTimeToLiveSeconds
()
==
8
);
assertTrue
(
"default timeToIdle is correct"
,
c
onfig
.
getTimeToIdleSeconds
()
==
7
);
assertTrue
(
"overridden diskPersistent is correct"
,
c
onfig
.
isDiskPersistent
());
assertTrue
(
"overridden diskExpiryThreadIntervalSeconds is correct"
,
c
onfig
.
getDiskExpiryThreadIntervalSeconds
()
==
10
);
}
finally
{
if
(
useCacheManagerFb
)
{
...
...
@@ -157,7 +161,7 @@ public class EhCacheSupportTests extends TestCase {
EhCacheManagerFactoryBean
cacheManagerFb
=
new
EhCacheManagerFactoryBean
();
cacheManagerFb
.
afterPropertiesSet
();
try
{
CacheManager
cm
=
(
CacheManager
)
cacheManagerFb
.
getObject
();
CacheManager
cm
=
cacheManagerFb
.
getObject
();
EhCacheFactoryBean
cacheFb
=
new
EhCacheFactoryBean
();
cacheFb
.
setCacheManager
(
cm
);
cacheFb
.
setCacheName
(
"myCache1"
);
...
...
@@ -175,7 +179,7 @@ public class EhCacheSupportTests extends TestCase {
EhCacheManagerFactoryBean
cacheManagerFb
=
new
EhCacheManagerFactoryBean
();
cacheManagerFb
.
afterPropertiesSet
();
try
{
CacheManager
cm
=
(
CacheManager
)
cacheManagerFb
.
getObject
();
CacheManager
cm
=
cacheManagerFb
.
getObject
();
EhCacheFactoryBean
cacheFb
=
new
EhCacheFactoryBean
();
cacheFb
.
setCacheManager
(
cm
);
cacheFb
.
setCacheName
(
"myCache1"
);
...
...
@@ -198,7 +202,7 @@ public class EhCacheSupportTests extends TestCase {
EhCacheManagerFactoryBean
cacheManagerFb
=
new
EhCacheManagerFactoryBean
();
cacheManagerFb
.
afterPropertiesSet
();
try
{
CacheManager
cm
=
(
CacheManager
)
cacheManagerFb
.
getObject
();
CacheManager
cm
=
cacheManagerFb
.
getObject
();
EhCacheFactoryBean
cacheFb
=
new
EhCacheFactoryBean
();
cacheFb
.
setCacheManager
(
cm
);
cacheFb
.
setCacheName
(
"myCache1"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录