Rearranged cache test class names across several modules

This commit is contained in:
Juergen Hoeller
2015-11-26 16:30:44 +01:00
parent 331e739255
commit dd647659b3
11 changed files with 57 additions and 44 deletions

View File

@@ -33,6 +33,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
protected abstract Object getNativeCache();
@Test
public void testCacheName() throws Exception {
assertEquals(CACHE_NAME, getCache().getName());
@@ -105,6 +106,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
assertNull(cache.get("enescu"));
}
private String createRandomKey() {
return UUID.randomUUID().toString();
}

View File

@@ -28,7 +28,7 @@ import org.junit.Test;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.config.AbstractAnnotationTests;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService;
@@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
/**
* @author Stephane Nicoll
*/
public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
private CacheManager jCacheManager;
@@ -58,6 +58,10 @@ public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
return context;
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@After
public void shutdown() {
if (jCacheManager != null) {
@@ -73,11 +77,6 @@ public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@Configuration
@EnableCaching
static class EnableCachingConfig extends CachingConfigurerSupport {

View File

@@ -30,7 +30,7 @@ import org.springframework.cache.AbstractCacheTests;
/**
* @author Stephane Nicoll
*/
public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
public class JCacheEhCacheApiTests extends AbstractCacheTests<JCacheCache> {
private CacheManager cacheManager;
@@ -38,19 +38,27 @@ public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
private JCacheCache cache;
@Before
public void setUp() {
public void setup() {
this.cacheManager = getCachingProvider().getCacheManager();
this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>());
this.nativeCache = this.cacheManager.getCache(CACHE_NAME);
this.cache = new JCacheCache(this.nativeCache);
}
@After
public void shutdownCacheManager() {
this.cacheManager.close();
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@After
public void shutdown() {
if (this.cacheManager != null) {
this.cacheManager.close();
}
}
@Override
protected JCacheCache getCache() {
return this.cache;
@@ -61,8 +69,4 @@ public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
return this.nativeCache;
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
}