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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.springframework.cache.Cache; 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.cache.config.CacheableService;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext;
@ -30,17 +30,18 @@ import static org.junit.Assert.*;
/** /**
* @author Costin Leau * @author Costin Leau
*/ */
public class AspectJAnnotationTests extends AbstractAnnotationTests { public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
@Override @Override
protected ConfigurableApplicationContext getApplicationContext() { 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 @Test
public void testKeyStrategy() throws Exception { 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()); 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> {
protected abstract Object getNativeCache(); protected abstract Object getNativeCache();
@Test @Test
public void testCacheName() throws Exception { public void testCacheName() throws Exception {
assertEquals(CACHE_NAME, getCache().getName()); assertEquals(CACHE_NAME, getCache().getName());
@ -105,6 +106,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
assertNull(cache.get("enescu")); assertNull(cache.get("enescu"));
} }
private String createRandomKey() { private String createRandomKey() {
return UUID.randomUUID().toString(); 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;
import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching; 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.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService; import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService; import org.springframework.cache.config.DefaultCacheableService;
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests { public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
private CacheManager jCacheManager; private CacheManager jCacheManager;
@ -58,6 +58,10 @@ public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
return context; return context;
} }
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@After @After
public void shutdown() { public void shutdown() {
if (jCacheManager != null) { if (jCacheManager != null) {
@ -73,11 +77,6 @@ public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
} }
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@Configuration @Configuration
@EnableCaching @EnableCaching
static class EnableCachingConfig extends CachingConfigurerSupport { 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;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> { public class JCacheEhCacheApiTests extends AbstractCacheTests<JCacheCache> {
private CacheManager cacheManager; private CacheManager cacheManager;
@ -38,19 +38,27 @@ public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
private JCacheCache cache; private JCacheCache cache;
@Before @Before
public void setUp() { public void setup() {
this.cacheManager = getCachingProvider().getCacheManager(); this.cacheManager = getCachingProvider().getCacheManager();
this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>()); this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>());
this.nativeCache = this.cacheManager.getCache(CACHE_NAME); this.nativeCache = this.cacheManager.getCache(CACHE_NAME);
this.cache = new JCacheCache(this.nativeCache); this.cache = new JCacheCache(this.nativeCache);
} }
protected CachingProvider getCachingProvider() {
return Caching.getCachingProvider();
}
@After @After
public void shutdownCacheManager() { public void shutdown() {
this.cacheManager.close(); if (this.cacheManager != null) {
this.cacheManager.close();
}
} }
@Override @Override
protected JCacheCache getCache() { protected JCacheCache getCache() {
return this.cache; return this.cache;
@ -61,8 +69,4 @@ public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
return this.nativeCache; 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.*;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
* Abstract annotation test (containing several reusable methods). * Abstract cache annotation tests (containing several reusable methods).
* *
* @author Costin Leau * @author Costin Leau
* @author Chris Beams * @author Chris Beams
* @author Phillip Webb * @author Phillip Webb
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public abstract class AbstractAnnotationTests { public abstract class AbstractCacheAnnotationTests {
protected ConfigurableApplicationContext ctx; protected ConfigurableApplicationContext ctx;
@ -72,7 +72,7 @@ public abstract class AbstractAnnotationTests {
} }
@After @After
public void tearDown() { public void close() {
if (ctx != null) { if (ctx != null) {
ctx.close(); ctx.close();
} }
@ -128,7 +128,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r1, r2); assertSame(r1, r2);
try { try {
service.evictEarly(o1); service.evictEarly(o1);
} catch (RuntimeException ex) { }
catch (RuntimeException ex) {
// expected // expected
} }
@ -147,7 +148,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r1, r2); assertSame(r1, r2);
try { try {
service.evictWithException(o1); service.evictWithException(o1);
} catch (RuntimeException ex) { }
catch (RuntimeException ex) {
// expected // expected
} }
// exception occurred, eviction skipped, data should still be in the cache // exception occurred, eviction skipped, data should still be in the cache
@ -179,7 +181,8 @@ public abstract class AbstractAnnotationTests {
try { try {
service.invalidateEarly(o1, null); service.invalidateEarly(o1, null);
} catch (Exception ex) { }
catch (Exception ex) {
// expected // expected
} }
Object r3 = service.cache(o1); Object r3 = service.cache(o1);
@ -290,7 +293,8 @@ public abstract class AbstractAnnotationTests {
try { try {
service.throwChecked(arg); service.throwChecked(arg);
fail("Excepted exception"); fail("Excepted exception");
} catch (Exception ex) { }
catch (Exception ex) {
assertEquals("Wrong exception type", IOException.class, ex.getClass()); assertEquals("Wrong exception type", IOException.class, ex.getClass());
assertEquals(arg, ex.getMessage()); assertEquals(arg, ex.getMessage());
} }
@ -300,7 +304,8 @@ public abstract class AbstractAnnotationTests {
try { try {
service.throwUnchecked(Long.valueOf(1)); service.throwUnchecked(Long.valueOf(1));
fail("Excepted exception"); fail("Excepted exception");
} catch (RuntimeException ex) { }
catch (RuntimeException ex) {
assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass()); assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass());
assertEquals("1", ex.getMessage()); assertEquals("1", ex.getMessage());
} }
@ -623,7 +628,8 @@ public abstract class AbstractAnnotationTests {
Object param = new Object(); Object param = new Object();
cs.unknownCustomKeyGenerator(param); cs.unknownCustomKeyGenerator(param);
fail("should have failed with NoSuchBeanDefinitionException"); fail("should have failed with NoSuchBeanDefinitionException");
} catch (NoSuchBeanDefinitionException e) { }
catch (NoSuchBeanDefinitionException ex) {
// expected // expected
} }
} }
@ -645,7 +651,8 @@ public abstract class AbstractAnnotationTests {
Object param = new Object(); Object param = new Object();
cs.unknownCustomCacheManager(param); cs.unknownCustomCacheManager(param);
fail("should have failed with NoSuchBeanDefinitionException"); fail("should have failed with NoSuchBeanDefinitionException");
} catch (NoSuchBeanDefinitionException e) { }
catch (NoSuchBeanDefinitionException ex) {
// expected // 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;
* @author Costin Leau * @author Costin Leau
* @author Chris Beams * @author Chris Beams
*/ */
public class AnnotationTests extends AbstractAnnotationTests { public class AnnotationDrivenCacheConfigTests extends AbstractCacheAnnotationTests {
@Override @Override
protected ConfigurableApplicationContext getApplicationContext() { protected ConfigurableApplicationContext getApplicationContext() {

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

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -30,7 +30,7 @@ import static org.junit.Assert.*;
* @author Chris Beams * @author Chris Beams
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests { public class AnnotationNamespaceDrivenTests extends AbstractCacheAnnotationTests {
@Override @Override
protected ConfigurableApplicationContext getApplicationContext() { protected ConfigurableApplicationContext getApplicationContext() {
@ -40,8 +40,8 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
@Test @Test
public void testKeyStrategy() { public void testKeyStrategy() {
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor ci = ctx.getBean(
CacheInterceptor.class); "org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator()); assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
} }
@ -67,8 +67,9 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
@Test @Test
public void testCacheErrorHandler() { public void testCacheErrorHandler() {
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor ci = ctx.getBean(
CacheInterceptor.class); "org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler()); 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 @@
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.springframework.context.support.GenericXmlApplicationContext;
* @author Costin Leau * @author Costin Leau
* @author Chris Beams * @author Chris Beams
*/ */
public class CacheAdviceNamespaceTests extends AbstractAnnotationTests { public class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests {
@Override @Override
protected ConfigurableApplicationContext getApplicationContext() { 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.*;
* @author Chris Beams * @author Chris Beams
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class EnableCachingTests extends AbstractAnnotationTests { public class EnableCachingTests extends AbstractCacheAnnotationTests {
/** hook into superclass suite of tests */ /** hook into superclass suite of tests */
@Override @Override

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

@ -24,7 +24,6 @@ import javax.cache.spi.CachingProvider;
* runs against EhCache 2.x with the EhCache-JCache add-on. * runs against EhCache 2.x with the EhCache-JCache add-on.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.2.1
*/ */
public class JCacheEhCache3AnnotationTests extends JCacheEhCacheAnnotationTests { 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;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JCacheEhcache3Tests extends JCacheEhCacheTests { public class JCacheEhCache3ApiTests extends JCacheEhCacheApiTests {
@Override @Override
protected CachingProvider getCachingProvider() { protected CachingProvider getCachingProvider() {
Loading…
Cancel
Save