FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rearranged cache test class names across several modules · Java1024/spring-framework@dd64765 · GitHub

Repository navigation

Commit dd64765

Browse files
committed
Rearranged cache test class names across several modules
1 parent 331e739 commit dd64765

11 files changed

Lines changed: 56 additions & 43 deletions

File tree

spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJAnnotationTests.java renamed to spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import org.junit.Test;
2121

2222
import org.springframework.cache.Cache;
23-
import org.springframework.cache.config.AbstractAnnotationTests;
23+
import org.springframework.cache.config.AbstractCacheAnnotationTests;
2424
import org.springframework.cache.config.CacheableService;
2525
import org.springframework.context.ConfigurableApplicationContext;
2626
import org.springframework.context.support.GenericXmlApplicationContext;
@@ -30,17 +30,18 @@
3030
/**
3131
* @author Costin Leau
3232
*/
33-
public class AspectJAnnotationTests extends AbstractAnnotationTests {
34-
33+
public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
3534

3635
@Override
3736
protected ConfigurableApplicationContext getApplicationContext() {
38-
return new GenericXmlApplicationContext("/org/springframework/cache/config/annotation-cache-aspectj.xml");
37+
return new GenericXmlApplicationContext(
38+
"/org/springframework/cache/config/annotation-cache-aspectj.xml");
3939
}
4040

4141
@Test
4242
public void testKeyStrategy() throws Exception {
43-
AnnotationCacheAspect aspect = ctx.getBean("org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
43+
AnnotationCacheAspect aspect = ctx.getBean(
44+
"org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
4445
Assert.assertSame(ctx.getBean("keyGenerator"), aspect.getKeyGenerator());
4546
}
4647

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public abstract class AbstractCacheTests<T extends Cache> {
3333

3434
protected abstract Object getNativeCache();
3535

36+
3637
@Test
3738
public void testCacheName() throws Exception {
3839
assertEquals(CACHE_NAME, getCache().getName());
@@ -105,6 +106,7 @@ public void testCacheClear() throws Exception {
105106
assertNull(cache.get("enescu"));
106107
}
107108

109+
108110
private String createRandomKey() {
109111
return UUID.randomUUID().toString();
110112
}

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import org.springframework.cache.annotation.CachingConfigurerSupport;
3030
import org.springframework.cache.annotation.EnableCaching;
31-
import org.springframework.cache.config.AbstractAnnotationTests;
31+
import org.springframework.cache.config.AbstractCacheAnnotationTests;
3232
import org.springframework.cache.config.AnnotatedClassCacheableService;
3333
import org.springframework.cache.config.CacheableService;
3434
import org.springframework.cache.config.DefaultCacheableService;
@@ -43,7 +43,7 @@
4343
/**
4444
* @author Stephane Nicoll
4545
*/
46-
public class JCacheEhCacheAnnotationTests extends AbstractAnnotationTests {
46+
public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
4747

4848
private CacheManager jCacheManager;
4949

@@ -58,6 +58,10 @@ protected ConfigurableApplicationContext getApplicationContext() {
5858
return context;
5959
}
6060

61+
protected CachingProvider getCachingProvider() {
62+
return Caching.getCachingProvider();
63+
}
64+
6165
@After
6266
public void shutdown() {
6367
if (jCacheManager != null) {
@@ -73,11 +77,6 @@ public void testCustomCacheManager() {
7377
}
7478

7579

76-
protected CachingProvider getCachingProvider() {
77-
return Caching.getCachingProvider();
78-
}
79-
80-
8180
@Configuration
8281
@EnableCaching
8382
static class EnableCachingConfig extends CachingConfigurerSupport {

spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheTests.java renamed to spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,35 @@
3030
/**
3131
* @author Stephane Nicoll
3232
*/
33-
public class JCacheEhCacheTests extends AbstractCacheTests<JCacheCache> {
33+
public class JCacheEhCacheApiTests extends AbstractCacheTests<JCacheCache> {
3434

3535
private CacheManager cacheManager;
3636

3737
private Cache<Object, Object> nativeCache;
3838

3939
private JCacheCache cache;
4040

41+
4142
@Before
42-
public void setUp() {
43+
public void setup() {
4344
this.cacheManager = getCachingProvider().getCacheManager();
4445
this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>());
4546
this.nativeCache = this.cacheManager.getCache(CACHE_NAME);
4647
this.cache = new JCacheCache(this.nativeCache);
4748
}
4849

50+
protected CachingProvider getCachingProvider() {
51+
return Caching.getCachingProvider();
52+
}
53+
4954
@After
50-
public void shutdownCacheManager() {
51-
this.cacheManager.close();
55+
public void shutdown() {
56+
if (this.cacheManager != null) {
57+
this.cacheManager.close();
58+
}
5259
}
5360

61+
5462
@Override
5563
protected JCacheCache getCache() {
5664
return this.cache;
@@ -61,8 +69,4 @@ protected Object getNativeCache() {
6169
return this.nativeCache;
6270
}
6371

64-
protected CachingProvider getCachingProvider() {
65-
return Caching.getCachingProvider();
66-
}
67-
6872
}

spring-context/src/test/java/org/springframework/cache/config/AbstractAnnotationTests.java renamed to spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
import static org.junit.Assert.*;
3535

3636
/**
37-
* Abstract annotation test (containing several reusable methods).
37+
* Abstract cache annotation tests (containing several reusable methods).
3838
*
3939
* @author Costin Leau
4040
* @author Chris Beams
4141
* @author Phillip Webb
4242
* @author Stephane Nicoll
4343
*/
44-
public abstract class AbstractAnnotationTests {
44+
public abstract class AbstractCacheAnnotationTests {
4545

4646
protected ConfigurableApplicationContext ctx;
4747

@@ -72,7 +72,7 @@ public void setup() {
7272
}
7373

7474
@After
75-
public void tearDown() {
75+
public void close() {
7676
if (ctx != null) {
7777
ctx.close();
7878
}
@@ -128,7 +128,8 @@ public void testEvictEarly(CacheableService<?> service) throws Exception {
128128
assertSame(r1, r2);
129129
try {
130130
service.evictEarly(o1);
131-
} catch (RuntimeException ex) {
131+
}
132+
catch (RuntimeException ex) {
132133
// expected
133134
}
134135

@@ -147,7 +148,8 @@ public void testEvictException(CacheableService<?> service) throws Exception {
147148
assertSame(r1, r2);
148149
try {
149150
service.evictWithException(o1);
150-
} catch (RuntimeException ex) {
151+
}
152+
catch (RuntimeException ex) {
151153
// expected
152154
}
153155
// exception occurred, eviction skipped, data should still be in the cache
@@ -179,7 +181,8 @@ public void testEvictWKeyEarly(CacheableService<?> service) throws Exception {
179181

180182
try {
181183
service.invalidateEarly(o1, null);
182-
} catch (Exception ex) {
184+
}
185+
catch (Exception ex) {
183186
// expected
184187
}
185188
Object r3 = service.cache(o1);
@@ -290,7 +293,8 @@ public void testCheckedThrowable(CacheableService<?> service) throws Exception {
290293
try {
291294
service.throwChecked(arg);
292295
fail("Excepted exception");
293-
} catch (Exception ex) {
296+
}
297+
catch (Exception ex) {
294298
assertEquals("Wrong exception type", IOException.class, ex.getClass());
295299
assertEquals(arg, ex.getMessage());
296300
}
@@ -300,7 +304,8 @@ public void testUncheckedThrowable(CacheableService<?> service) throws Exception
300304
try {
301305
service.throwUnchecked(Long.valueOf(1));
302306
fail("Excepted exception");
303-
} catch (RuntimeException ex) {
307+
}
308+
catch (RuntimeException ex) {
304309
assertEquals("Wrong exception type", UnsupportedOperationException.class, ex.getClass());
305310
assertEquals("1", ex.getMessage());
306311
}
@@ -623,7 +628,8 @@ public void testUnknownCustomKeyGenerator() {
623628
Object param = new Object();
624629
cs.unknownCustomKeyGenerator(param);
625630
fail("should have failed with NoSuchBeanDefinitionException");
626-
} catch (NoSuchBeanDefinitionException e) {
631+
}
632+
catch (NoSuchBeanDefinitionException ex) {
627633
// expected
628634
}
629635
}
@@ -645,7 +651,8 @@ public void testUnknownCustomCacheManager() {
645651
Object param = new Object();
646652
cs.unknownCustomCacheManager(param);
647653
fail("should have failed with NoSuchBeanDefinitionException");
648-
} catch (NoSuchBeanDefinitionException e) {
654+
}
655+
catch (NoSuchBeanDefinitionException ex) {
649656
// expected
650657
}
651658
}

spring-context/src/test/java/org/springframework/cache/config/AnnotationTests.java renamed to spring-context/src/test/java/org/springframework/cache/config/AnnotationDrivenCacheConfigTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @author Costin Leau
2424
* @author Chris Beams
2525
*/
26-
public class AnnotationTests extends AbstractAnnotationTests {
26+
public class AnnotationDrivenCacheConfigTests extends AbstractCacheAnnotationTests {
2727

2828
@Override
2929
protected ConfigurableApplicationContext getApplicationContext() {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@
3030
* @author Chris Beams
3131
* @author Stephane Nicoll
3232
*/
33-
public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
33+
public class AnnotationNamespaceDrivenTests extends AbstractCacheAnnotationTests {
3434

3535
@Override
3636
protected ConfigurableApplicationContext getApplicationContext() {
@@ -40,8 +40,8 @@ protected ConfigurableApplicationContext getApplicationContext() {
4040

4141
@Test
4242
public void testKeyStrategy() {
43-
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
44-
CacheInterceptor.class);
43+
CacheInterceptor ci = ctx.getBean(
44+
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
4545
assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
4646
}
4747

@@ -67,8 +67,9 @@ public void bothSetOnlyResolverIsUsed() {
6767

6868
@Test
6969
public void testCacheErrorHandler() {
70-
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
71-
CacheInterceptor.class);
70+
CacheInterceptor ci = ctx.getBean(
71+
"org.springframework.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
7272
assertSame(ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
7373
}
74+
7475
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
2727
* @author Costin Leau
2828
* @author Chris Beams
2929
*/
30-
public class CacheAdviceNamespaceTests extends AbstractAnnotationTests {
30+
public class CacheAdviceNamespaceTests extends AbstractCacheAnnotationTests {
3131

3232
@Override
3333
protected ConfigurableApplicationContext getApplicationContext() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* @author Chris Beams
4545
* @author Stephane Nicoll
4646
*/
47-
public class EnableCachingTests extends AbstractAnnotationTests {
47+
public class EnableCachingTests extends AbstractCacheAnnotationTests {
4848

4949
/** hook into superclass suite of tests */
5050
@Override

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* runs against EhCache 2.x with the EhCache-JCache add-on.
2525
*
2626
* @author Juergen Hoeller
27-
* @since 4.2.1
2827
*/
2928
public class JCacheEhCache3AnnotationTests extends JCacheEhCacheAnnotationTests {
3029

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL