1
1
/*
2
- * Copyright 2002-2009 the original author or authors.
2
+ * Copyright 2002-2012 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
17
17
package org .springframework .cache .ehcache ;
18
18
19
19
import junit .framework .TestCase ;
20
+
20
21
import net .sf .ehcache .Cache ;
21
22
import net .sf .ehcache .CacheManager ;
22
23
import net .sf .ehcache .Ehcache ;
@@ -82,7 +83,8 @@ private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exceptio
82
83
EhCacheManagerFactoryBean cacheManagerFb = null ;
83
84
try {
84
85
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean ();
85
- assertEquals (Ehcache .class , cacheFb .getObjectType ());
86
+ Class <? extends Ehcache > objectType = cacheFb .getObjectType ();
87
+ assertTrue (Ehcache .class .isAssignableFrom (objectType ));
86
88
assertTrue ("Singleton property" , cacheFb .isSingleton ());
87
89
if (useCacheManagerFb ) {
88
90
cacheManagerFb = new EhCacheManagerFactoryBean ();
@@ -94,6 +96,8 @@ private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exceptio
94
96
cacheFb .setCacheName ("myCache1" );
95
97
cacheFb .afterPropertiesSet ();
96
98
cache = (Cache ) cacheFb .getObject ();
99
+ Class <? extends Ehcache > objectType2 = cacheFb .getObjectType ();
100
+ assertSame (objectType , objectType2 );
97
101
CacheConfiguration config = cache .getCacheConfiguration ();
98
102
assertEquals ("myCache1" , cache .getName ());
99
103
if (useCacheManagerFb ){
@@ -166,6 +170,7 @@ public void testEhCacheFactoryBeanWithBlockingCache() throws Exception {
166
170
cacheFb .setCacheManager (cm );
167
171
cacheFb .setCacheName ("myCache1" );
168
172
cacheFb .setBlocking (true );
173
+ assertEquals (cacheFb .getObjectType (), BlockingCache .class );
169
174
cacheFb .afterPropertiesSet ();
170
175
Ehcache myCache1 = cm .getEhcache ("myCache1" );
171
176
assertTrue (myCache1 instanceof BlockingCache );
@@ -188,6 +193,7 @@ public Object createEntry(Object key) throws Exception {
188
193
return key ;
189
194
}
190
195
});
196
+ assertEquals (cacheFb .getObjectType (), SelfPopulatingCache .class );
191
197
cacheFb .afterPropertiesSet ();
192
198
Ehcache myCache1 = cm .getEhcache ("myCache1" );
193
199
assertTrue (myCache1 instanceof SelfPopulatingCache );
@@ -213,6 +219,7 @@ public Object createEntry(Object key) throws Exception {
213
219
public void updateEntryValue (Object key , Object value ) throws Exception {
214
220
}
215
221
});
222
+ assertEquals (cacheFb .getObjectType (), UpdatingSelfPopulatingCache .class );
216
223
cacheFb .afterPropertiesSet ();
217
224
Ehcache myCache1 = cm .getEhcache ("myCache1" );
218
225
assertTrue (myCache1 instanceof UpdatingSelfPopulatingCache );
0 commit comments