Revisit Assert to avoid single-arg assert methods (with refined messages)

Issue: SPR-15196
This commit is contained in:
Juergen Hoeller
2017-01-30 22:15:53 +01:00
parent 768802fa96
commit 1b2dc3638f
118 changed files with 708 additions and 828 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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,8 +30,6 @@ import org.junit.rules.ExpectedException;
import org.springframework.cache.Cache;
import org.springframework.cache.jcache.AbstractJCacheTests;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
@@ -46,7 +44,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
@Test
public void resolveSimpleCache() {
public void resolveSimpleCache() throws Exception {
DefaultCacheInvocationContext<?> dummyContext = createDummyContext();
CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, "testCache"));
Collection<? extends Cache> caches = adapter.resolveCaches(dummyContext);
@@ -56,7 +54,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
}
@Test
public void resolveUnknownCache() {
public void resolveUnknownCache() throws Exception {
DefaultCacheInvocationContext<?> dummyContext = createDummyContext();
CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, null));
@@ -66,7 +64,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
protected CacheResolver getCacheResolver(CacheInvocationContext<? extends Annotation> context, String cacheName) {
CacheResolver cacheResolver = mock(CacheResolver.class);
final javax.cache.Cache cache;
javax.cache.Cache cache;
if (cacheName == null) {
cache = null;
}
@@ -78,9 +76,8 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
return cacheResolver;
}
protected DefaultCacheInvocationContext<?> createDummyContext() {
Method method = ReflectionUtils.findMethod(Sample.class, "get", String.class);
Assert.notNull(method);
protected DefaultCacheInvocationContext<?> createDummyContext() throws Exception {
Method method = Sample.class.getMethod("get", String.class);
CacheResult cacheAnnotation = method.getAnnotation(CacheResult.class);
CacheMethodDetails<CacheResult> methodDetails =
new DefaultCacheMethodDetails<>(method, cacheAnnotation, "test");
@@ -93,7 +90,7 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests {
static class Sample {
@CacheResult
private Object get(String id) {
public Object get(String id) {
return null;
}
}