Browse Source

Rearranged cache test class names across several modules

pull/929/head
Juergen Hoeller 10 years ago
parent
commit
dd647659b3
  1. 13
      spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java
  2. 2
      spring-context-support/src/test/java/org/springframework/cache/AbstractCacheTests.java
  3. 13
      spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java
  4. 20
      spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java
  5. 27
      spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java
  6. 2
      spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java
  7. 13
      spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java
  8. 4
      spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java
  9. 2
      spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java
  10. 1
      spring-test/src/test/java/org/springframework/cache/jcache/JCacheEhCache3AnnotationTests.java
  11. 2
      spring-test/src/test/java/org/springframework/cache/jcache/JCacheEhCache3ApiTests.java

13
spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTests.java → spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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,7 +20,7 @@ import org.junit.Assert; @@ -20,7 +20,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.config.AbstractAnnotationTests;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.CacheableService;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
@ -30,17 +30,18 @@ import static org.junit.Assert.*; @@ -30,17 +30,18 @@ import static org.junit.Assert.*;
/**
* @author Costin Leau
*/
public class AspectJAnnotationTests extends AbstractAnnotationTests {
public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
@Override
protected ConfigurableApplicationContext getApplicationContext() {
return new GenericXmlApplicationContext("/org/springframework/cache/config/annotation-cache-aspectj.xml");
return new GenericXmlApplicationContext(
"/org/springframework/cache/config/annotation-cache-aspectj.xml");
}
@Test
public void testKeyStrategy() throws Exception {
AnnotationCacheAspect aspect = ctx.getBean("org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
AnnotationCacheAspect aspect = ctx.getBean(
"org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
Assert.assertSame(ctx.getBean("keyGenerator"), aspect.getKeyGenerator());
}

2
spring-context-support/src/test/java/org/springframework/cache/AbstractCacheTests.java vendored

@ -33,6 +33,7 @@ public abstract class AbstractCacheTests<T extends Cache> { @@ -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> { @@ -105,6 +106,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
assertNull(cache.get("enescu"));
}
private String createRandomKey() {
return UUID.randomUUID().toString();
}

13
spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java vendored

@ -28,7 +28,7 @@ import org.junit.Test; @@ -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; @@ -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 { @@ -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 { @@ -73,11 +77,6 @@ public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@Configuration
@EnableCaching
static class EnableCachingConfig extends CachingConfigurerSupport {

20
spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java → spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java vendored

@ -30,7 +30,7 @@ import org.springframework.cache.AbstractCacheTests; @@ -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> { @@ -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);
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@After
public void shutdownCacheManager() {
this.cacheManager.close();
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> { @@ -61,8 +69,4 @@ public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
return this.nativeCache;
}
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
}

27
spring-context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java → spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java vendored

@ -34,14 +34,14 @@ import static org.hamcrest.Matchers.*; @@ -34,14 +34,14 @@ import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Abstract annotation test (containing several reusable methods).
* Abstract cache annotation tests (containing several reusable methods).
*
* @author Costin Leau
* @author Chris Beams
* @author Phillip Webb
* @author Stephane Nicoll
*/
public abstract class AbstractAnnotationTests {
public abstract class AbstractCacheAnnotationTests {
protected ConfigurableApplicationContext ctx;
@ -72,7 +72,7 @@ public abstract class AbstractAnnotationTests { @@ -72,7 +72,7 @@ public abstract class AbstractAnnotationTests {
}
@After
public void tearDown() {
public void close() {
if (ctx != null) {
ctx.close();
}
@ -128,7 +128,8 @@ public abstract class AbstractAnnotationTests { @@ -128,7 +128,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r1, r2);
try {
service.evictEarly(o1);
} catch (RuntimeException ex) {
}
catch (RuntimeException ex) {
// expected
}
@ -147,7 +148,8 @@ public abstract class AbstractAnnotationTests { @@ -147,7 +148,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r1, r2);
try {
service.evictWithException(o1);
} catch (RuntimeException ex) {
}
catch (RuntimeException ex) {
// expected
}
// exception occurred, eviction skipped, data should still be in the cache
@ -179,7 +181,8 @@ public abstract class AbstractAnnotationTests { @@ -179,7 +181,8 @@ public abstract class AbstractAnnotationTests {
try {
service.invalidateEarly(o1, null);
} catch (Exception ex) {
}
catch (Exception ex) {
// expected
}
Object r3 = service.cache(o1);
@ -290,7 +293,8 @@ public abstract class AbstractAnnotationTests { @@ -290,7 +293,8 @@ public abstract class AbstractAnnotationTests {
try {
service.throwChecked(arg);
fail("Excepted exception");
} catch (Exception ex) {
}
catch (Exception ex) {
assertEquals("Wrong exception type", IOException.class, ex.getClass());
assertEquals(arg, ex.getMessage());
}
@ -300,7 +304,8 @@ public abstract class AbstractAnnotationTests { @@ -300,7 +304,8 @@ public abstract class AbstractAnnotationTests {
try {
service.throwUnchecked(Long.valueOf(1));
fail("Excepted exception");
} catch (RuntimeException ex) {
}
catch (RuntimeException ex) {
assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass());
assertEquals("1", ex.getMessage());
}
@ -623,7 +628,8 @@ public abstract class AbstractAnnotationTests { @@ -623,7 +628,8 @@ public abstract class AbstractAnnotationTests {
Object param = new Object();
cs.unknownCustomKeyGenerator(param);
fail("should have failed with NoSuchBeanDefinitionException");
} catch (NoSuchBeanDefinitionException e) {
}
catch (NoSuchBeanDefinitionException ex) {
// expected
}
}
@ -645,7 +651,8 @@ public abstract class AbstractAnnotationTests { @@ -645,7 +651,8 @@ public abstract class AbstractAnnotationTests {
Object param = new Object();
cs.unknownCustomCacheManager(param);
fail("should have failed with NoSuchBeanDefinitionException");
} catch (NoSuchBeanDefinitionException e) {
}
catch (NoSuchBeanDefinitionException ex) {
// expected
}
}

2
spring-context/src/test/java/org/springframework/cache/config/AnnotationTests.java → spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java vendored

@ -23,7 +23,7 @@ import org.springframework.context.support.GenericXmlApplicationContext; @@ -23,7 +23,7 @@ import org.springframework.context.support.GenericXmlApplicationContext;
* @author Costin Leau
* @author Chris Beams
*/
public class AnnotationTests extends AbstractAnnotationTests {
public class AnnotationDrivenCacheConfigTests extends AbstractCacheAnnotationTests {
@Override
protected ConfigurableApplicationContext getApplicationContext() {

13
spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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,7 +30,7 @@ import static org.junit.Assert.*; @@ -30,7 +30,7 @@ import static org.junit.Assert.*;
* @author Chris Beams
* @author Stephane Nicoll
*/
public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
public class AnnotationNamespaceDrivenTests extends AbstractCacheAnnotationTests {
@Override
protected ConfigurableApplicationContext getApplicationContext() {
@ -40,8 +40,8 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests { @@ -40,8 +40,8 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
@Test
public void testKeyStrategy() {
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
CacheInterceptor.class);
CacheInterceptor ci = ctx.getBean(
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
}
@ -67,8 +67,9 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests { @@ -67,8 +67,9 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
@Test
public void testCacheErrorHandler() {
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
CacheInterceptor.class);
CacheInterceptor ci = ctx.getBean(
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
}

4
spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@ -27,7 +27,7 @@ import org.springframework.context.support.GenericXmlApplicationContext; @@ -27,7 +27,7 @@ import org.springframework.context.support.GenericXmlApplicationContext;
* @author Costin Leau
* @author Chris Beams
*/
public class CacheAdviceNamespaceTests extends AbstractAnnotationTests {
public class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests {
@Override
protected ConfigurableApplicationContext getApplicationContext() {

2
spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java vendored

@ -44,7 +44,7 @@ import static org.junit.Assert.*; @@ -44,7 +44,7 @@ import static org.junit.Assert.*;
* @author Chris Beams
* @author Stephane Nicoll
*/
public class EnableCachingTests extends AbstractAnnotationTests {
public class EnableCachingTests extends AbstractCacheAnnotationTests {
/** hook into superclass suite of tests */
@Override

1
spring-test/src/test/java/org/springframework/cache/jcache/JCacheEhCache3AnnotationTests.java vendored

@ -24,7 +24,6 @@ import javax.cache.spi.CachingProvider; @@ -24,7 +24,6 @@ import javax.cache.spi.CachingProvider;
* runs against EhCache 2.x with the EhCache-JCache add-on.
*
* @author Juergen Hoeller
* @since 4.2.1
*/
public class JCacheEhCache3AnnotationTests extends JCacheEhCacheAnnotationTests {

2
spring-test/src/test/java/org/springframework/cache/jcache/JCacheEhcache3Tests.java → spring-test/src/test/java/org/springframework/cache/jcache/JCacheEhCache3ApiTests.java vendored

@ -25,7 +25,7 @@ import javax.cache.spi.CachingProvider; @@ -25,7 +25,7 @@ import javax.cache.spi.CachingProvider;
*
* @author Stephane Nicoll
*/
public class JCacheEhcache3Tests extends JCacheEhCacheTests {
public class JCacheEhCache3ApiTests extends JCacheEhCacheApiTests {
@Override
protected CachingProvider getCachingProvider() {
Loading…
Cancel
Save