Polishing
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.cache.interceptor;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cache.CacheTestUtils.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -26,6 +23,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -40,12 +38,16 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.cache.CacheTestUtils.*;
|
||||
|
||||
/**
|
||||
* Provides various {@link CacheResolver} customisations scenario
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
*/
|
||||
public class CacheResolverCustomisationTests {
|
||||
public class CacheResolverCustomizationTests {
|
||||
|
||||
private CacheManager cacheManager;
|
||||
|
||||
@@ -127,13 +129,13 @@ public class CacheResolverCustomisationTests {
|
||||
|
||||
@Test
|
||||
public void noCacheResolved() {
|
||||
Method m = ReflectionUtils.findMethod(SimpleService.class, "noCacheResolved", Object.class);
|
||||
Method method = ReflectionUtils.findMethod(SimpleService.class, "noCacheResolved", Object.class);
|
||||
try {
|
||||
simpleService.noCacheResolved(new Object());
|
||||
fail("Should have failed, no cache resolved");
|
||||
} catch (IllegalStateException e) {
|
||||
String msg = e.getMessage();
|
||||
assertTrue("Reference to the method must be contained in the message", msg.contains(m.toString()));
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
assertTrue("Reference to the method must be contained in the message", ex.getMessage().contains(method.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,13 +144,13 @@ public class CacheResolverCustomisationTests {
|
||||
try {
|
||||
simpleService.unknownCacheResolver(new Object());
|
||||
fail("Should have failed, no cache resolver with that name");
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
assertEquals("Wrong bean name in exception", "unknownCacheResolver", e.getBeanName());
|
||||
}
|
||||
catch (NoSuchBeanDefinitionException ex) {
|
||||
assertEquals("Wrong bean name in exception", "unknownCacheResolver", ex.getBeanName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class Config extends CachingConfigurerSupport {
|
||||
@@ -204,6 +206,7 @@ public class CacheResolverCustomisationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@CacheConfig(cacheNames = "default")
|
||||
static class SimpleService {
|
||||
|
||||
@@ -245,6 +248,7 @@ public class CacheResolverCustomisationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Example of {@link CacheResolver} that resolve the caches at
|
||||
* runtime (i.e. based on method invocation parameters).
|
||||
@@ -263,6 +267,7 @@ public class CacheResolverCustomisationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class NullCacheResolver extends AbstractCacheResolver {
|
||||
|
||||
private NullCacheResolver(CacheManager cacheManager) {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -101,6 +101,7 @@ public class ConfigurationClassPostConstructAndAutowiringTests {
|
||||
|
||||
@Configuration
|
||||
static class Config2 {
|
||||
|
||||
TestBean testBean;
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user