Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter, except spring-test which will be migrated in a separate commit. See gh-23451
This commit is contained in:
@@ -19,7 +19,7 @@ package org.springframework.cache.caffeine;
|
||||
import com.github.benmanes.caffeine.cache.CacheLoader;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.CaffeineSpec;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.cache.caffeine;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.AbstractValueAdaptingCacheTests;
|
||||
import org.springframework.cache.Cache;
|
||||
@@ -37,7 +37,7 @@ public class CaffeineCacheTests extends AbstractValueAdaptingCacheTests<Caffeine
|
||||
|
||||
private CaffeineCache cacheNoNull;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
nativeCache = Caffeine.newBuilder().build();
|
||||
cache = new CaffeineCache(CACHE_NAME, nativeCache);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cache.ehcache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import net.sf.ehcache.config.CacheConfiguration;
|
||||
import net.sf.ehcache.config.Configuration;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManagerTests;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache
|
||||
private EhCacheCacheManager transactionalCacheManager;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests")
|
||||
.defaultCache(new CacheConfiguration("default", 100)));
|
||||
@@ -51,7 +51,7 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache
|
||||
transactionalCacheManager.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void shutdown() {
|
||||
nativeCacheManager.shutdown();
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.config.CacheConfiguration;
|
||||
import net.sf.ehcache.config.Configuration;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.AbstractCacheTests;
|
||||
import org.springframework.tests.Assume;
|
||||
@@ -45,7 +45,7 @@ public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> {
|
||||
private EhCacheCache cache;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests")
|
||||
.defaultCache(new CacheConfiguration("default", 100)));
|
||||
@@ -55,7 +55,7 @@ public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> {
|
||||
cache = new EhCacheCache(nativeCache);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void shutdown() {
|
||||
cacheManager.shutdown();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.sf.ehcache.constructs.blocking.BlockingCache;
|
||||
import net.sf.ehcache.constructs.blocking.SelfPopulatingCache;
|
||||
import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory;
|
||||
import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.cache.jcache;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -34,11 +34,18 @@ import org.springframework.cache.support.SimpleCacheManager;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public abstract class AbstractJCacheTests {
|
||||
|
||||
@Rule
|
||||
public final TestName name = new TestName();
|
||||
protected String cacheName;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
void trackCacheName(TestInfo testInfo) {
|
||||
this.cacheName = testInfo.getTestMethod().get().getName();
|
||||
}
|
||||
|
||||
|
||||
protected final CacheManager cacheManager = createSimpleCacheManager("default", "simpleCache");
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import javax.cache.Cache;
|
||||
import javax.cache.CacheManager;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManagerTests;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM
|
||||
private JCacheCacheManager transactionalCacheManager;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupOnce() {
|
||||
cacheManagerMock = new CacheManagerMock();
|
||||
cacheManagerMock.addCache(CACHE_NAME);
|
||||
|
||||
@@ -21,9 +21,9 @@ import javax.cache.Caching;
|
||||
import javax.cache.configuration.MutableConfiguration;
|
||||
import javax.cache.spi.CachingProvider;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
@@ -67,7 +67,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
|
||||
return Caching.getCachingProvider("org.ehcache.jcache.JCacheCachingProvider");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void shutdown() {
|
||||
if (jCacheManager != null) {
|
||||
jCacheManager.close();
|
||||
@@ -77,7 +77,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
|
||||
|
||||
@Override
|
||||
@Test
|
||||
@Ignore("Multi cache manager support to be added")
|
||||
@Disabled("Multi cache manager support to be added")
|
||||
public void testCustomCacheManager() {
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import javax.cache.Caching;
|
||||
import javax.cache.configuration.MutableConfiguration;
|
||||
import javax.cache.spi.CachingProvider;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.cache.AbstractValueAdaptingCacheTests;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach
|
||||
private JCacheCache cacheNoNull;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.cacheManager = getCachingProvider().getCacheManager();
|
||||
this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>());
|
||||
@@ -57,7 +57,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests<JCach
|
||||
return Caching.getCachingProvider("org.ehcache.jcache.JCacheCachingProvider");
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void shutdown() {
|
||||
if (this.cacheManager != null) {
|
||||
this.cacheManager.close();
|
||||
|
||||
@@ -19,10 +19,9 @@ package org.springframework.cache.jcache.config;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -43,8 +42,8 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
public static final String EXCEPTION_CACHE = "exception";
|
||||
|
||||
@Rule
|
||||
public final TestName name = new TestName();
|
||||
|
||||
protected String keyItem;
|
||||
|
||||
protected ApplicationContext ctx;
|
||||
|
||||
@@ -54,19 +53,18 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
protected abstract ApplicationContext getApplicationContext();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
ctx = getApplicationContext();
|
||||
service = ctx.getBean(JCacheableService.class);
|
||||
cacheManager = ctx.getBean("cacheManager", CacheManager.class);
|
||||
@BeforeEach
|
||||
public void setUp(TestInfo testInfo) {
|
||||
this.keyItem = testInfo.getTestMethod().get().getName();
|
||||
this.ctx = getApplicationContext();
|
||||
this.service = this.ctx.getBean(JCacheableService.class);
|
||||
this.cacheManager = this.ctx.getBean("cacheManager", CacheManager.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cache() {
|
||||
String keyItem = name.getMethodName();
|
||||
|
||||
Object first = service.cache(keyItem);
|
||||
Object second = service.cache(keyItem);
|
||||
Object first = service.cache(this.keyItem);
|
||||
Object second = service.cache(this.keyItem);
|
||||
assertThat(second).isSameAs(first);
|
||||
}
|
||||
|
||||
@@ -74,14 +72,13 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void cacheNull() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
String keyItem = name.getMethodName();
|
||||
assertThat(cache.get(keyItem)).isNull();
|
||||
assertThat(cache.get(this.keyItem)).isNull();
|
||||
|
||||
Object first = service.cacheNull(keyItem);
|
||||
Object second = service.cacheNull(keyItem);
|
||||
Object first = service.cacheNull(this.keyItem);
|
||||
Object second = service.cacheNull(this.keyItem);
|
||||
assertThat(second).isSameAs(first);
|
||||
|
||||
Cache.ValueWrapper wrapper = cache.get(keyItem);
|
||||
Cache.ValueWrapper wrapper = cache.get(this.keyItem);
|
||||
assertThat(wrapper).isNotNull();
|
||||
assertThat(wrapper.get()).isSameAs(first);
|
||||
assertThat(wrapper.get()).as("Cached value should be null").isNull();
|
||||
@@ -89,14 +86,13 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void cacheException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(EXCEPTION_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.cacheWithException(keyItem, true));
|
||||
service.cacheWithException(this.keyItem, true));
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -105,26 +101,24 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void cacheExceptionVetoed() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(EXCEPTION_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
service.cacheWithException(keyItem, false));
|
||||
service.cacheWithException(this.keyItem, false));
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheCheckedException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(EXCEPTION_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
assertThat(cache.get(key)).isNull();
|
||||
assertThatIOException().isThrownBy(() ->
|
||||
service.cacheWithCheckedException(keyItem, true));
|
||||
service.cacheWithCheckedException(this.keyItem, true));
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -135,16 +129,15 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
|
||||
@Test
|
||||
public void cacheExceptionRewriteCallStack() {
|
||||
String keyItem = name.getMethodName();
|
||||
long ref = service.exceptionInvocations();
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.cacheWithException(keyItem, true))
|
||||
service.cacheWithException(this.keyItem, true))
|
||||
.satisfies(first -> {
|
||||
// Sanity check, this particular call has called the service
|
||||
// First call should not have been cached
|
||||
assertThat(service.exceptionInvocations()).isEqualTo(ref + 1);
|
||||
|
||||
UnsupportedOperationException second = methodInCallStack(keyItem);
|
||||
UnsupportedOperationException second = methodInCallStack(this.keyItem);
|
||||
// Sanity check, this particular call has *not* called the service
|
||||
// Second call should have been cached
|
||||
assertThat(service.exceptionInvocations()).isEqualTo(ref + 1);
|
||||
@@ -159,30 +152,25 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void cacheAlwaysInvoke() {
|
||||
String keyItem = name.getMethodName();
|
||||
|
||||
Object first = service.cacheAlwaysInvoke(keyItem);
|
||||
Object second = service.cacheAlwaysInvoke(keyItem);
|
||||
Object first = service.cacheAlwaysInvoke(this.keyItem);
|
||||
Object second = service.cacheAlwaysInvoke(this.keyItem);
|
||||
assertThat(second).isNotSameAs(first);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheWithPartialKey() {
|
||||
String keyItem = name.getMethodName();
|
||||
|
||||
Object first = service.cacheWithPartialKey(keyItem, true);
|
||||
Object second = service.cacheWithPartialKey(keyItem, false);
|
||||
Object first = service.cacheWithPartialKey(this.keyItem, true);
|
||||
Object second = service.cacheWithPartialKey(this.keyItem, false);
|
||||
// second argument not used, see config
|
||||
assertThat(second).isSameAs(first);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheWithCustomCacheResolver() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
service.cacheWithCustomCacheResolver(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
service.cacheWithCustomCacheResolver(this.keyItem);
|
||||
|
||||
// Cache in mock cache
|
||||
assertThat(cache.get(key)).isNull();
|
||||
@@ -190,25 +178,23 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void cacheWithCustomKeyGenerator() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
service.cacheWithCustomKeyGenerator(keyItem, "ignored");
|
||||
Object key = createKey(this.keyItem);
|
||||
service.cacheWithCustomKeyGenerator(this.keyItem, "ignored");
|
||||
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void put() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
service.put(keyItem, value);
|
||||
service.put(this.keyItem, value);
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -217,15 +203,14 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void putWithException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.putWithException(keyItem, value, true));
|
||||
service.putWithException(this.keyItem, value, true));
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -234,28 +219,26 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void putWithExceptionVetoPut() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
service.putWithException(keyItem, value, false));
|
||||
service.putWithException(this.keyItem, value, false));
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void earlyPut() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
service.earlyPut(keyItem, value);
|
||||
service.earlyPut(this.keyItem, value);
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -264,15 +247,14 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void earlyPutWithException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.earlyPutWithException(keyItem, value, true));
|
||||
service.earlyPutWithException(this.keyItem, value, true));
|
||||
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -281,14 +263,13 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void earlyPutWithExceptionVetoPut() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
assertThat(cache.get(key)).isNull();
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
service.earlyPutWithException(keyItem, value, false));
|
||||
service.earlyPutWithException(this.keyItem, value, false));
|
||||
// This will be cached anyway as the earlyPut has updated the cache before
|
||||
Cache.ValueWrapper result = cache.get(key);
|
||||
assertThat(result).isNotNull();
|
||||
@@ -297,44 +278,41 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void remove() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
service.remove(keyItem);
|
||||
service.remove(this.keyItem);
|
||||
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeWithException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.removeWithException(keyItem, true));
|
||||
service.removeWithException(this.keyItem, true));
|
||||
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeWithExceptionVetoRemove() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
service.removeWithException(keyItem, false));
|
||||
service.removeWithException(this.keyItem, false));
|
||||
Cache.ValueWrapper wrapper = cache.get(key);
|
||||
assertThat(wrapper).isNotNull();
|
||||
assertThat(wrapper.get()).isEqualTo(value);
|
||||
@@ -342,43 +320,40 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
|
||||
@Test
|
||||
public void earlyRemove() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
service.earlyRemove(keyItem);
|
||||
service.earlyRemove(this.keyItem);
|
||||
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void earlyRemoveWithException() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
service.earlyRemoveWithException(keyItem, true));
|
||||
service.earlyRemoveWithException(this.keyItem, true));
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void earlyRemoveWithExceptionVetoRemove() {
|
||||
String keyItem = name.getMethodName();
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(keyItem);
|
||||
Object key = createKey(this.keyItem);
|
||||
Object value = new Object();
|
||||
cache.put(key, value);
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
service.earlyRemoveWithException(keyItem, false));
|
||||
service.earlyRemoveWithException(this.keyItem, false));
|
||||
// This will be remove anyway as the earlyRemove has removed the cache before
|
||||
assertThat(cache.get(key)).isNull();
|
||||
}
|
||||
@@ -387,7 +362,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void removeAll() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
service.removeAll();
|
||||
@@ -399,7 +374,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void removeAllWithException() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
@@ -412,7 +387,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void removeAllWithExceptionVetoRemove() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
@@ -424,7 +399,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void earlyRemoveAll() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
service.earlyRemoveAll();
|
||||
@@ -436,7 +411,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void earlyRemoveAllWithException() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
|
||||
@@ -448,7 +423,7 @@ public abstract class AbstractJCacheAnnotationTests {
|
||||
public void earlyRemoveAllWithExceptionVetoRemove() {
|
||||
Cache cache = getCache(DEFAULT_CACHE);
|
||||
|
||||
Object key = createKey(name.getMethodName());
|
||||
Object key = createKey(this.keyItem);
|
||||
cache.put(key, new Object());
|
||||
|
||||
assertThatNullPointerException().isThrownBy(() ->
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -53,14 +53,14 @@ public class JCacheCustomInterceptorTests {
|
||||
protected Cache exceptionCache;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class);
|
||||
cs = ctx.getBean("service", JCacheableService.class);
|
||||
exceptionCache = ctx.getBean("exceptionCache", Cache.class);
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
if (ctx != null) {
|
||||
ctx.close();
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cache.jcache.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cache.jcache.config;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.reflect.Method;
|
||||
import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.jcache.AbstractJCacheTests;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
|
||||
@@ -24,8 +24,8 @@ import javax.cache.annotation.CacheRemove;
|
||||
import javax.cache.annotation.CacheRemoveAll;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.cache.interceptor.CacheResolver;
|
||||
@@ -52,7 +52,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
source.setCacheResolver(defaultCacheResolver);
|
||||
source.setExceptionCacheResolver(defaultExceptionCacheResolver);
|
||||
@@ -96,13 +96,12 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
|
||||
@Test
|
||||
public void noAnnotation() {
|
||||
assertThat(getCacheOperation(AnnotatedJCacheableService.class, name.getMethodName())).isNull();
|
||||
assertThat(getCacheOperation(AnnotatedJCacheableService.class, this.cacheName)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiAnnotations() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
getCacheOperation(InvalidCases.class, name.getMethodName()));
|
||||
assertThatIllegalStateException().isThrownBy(() -> getCacheOperation(InvalidCases.class, this.cacheName));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +133,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
@Test
|
||||
public void customCacheResolver() {
|
||||
CacheResultOperation operation =
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class);
|
||||
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
|
||||
assertJCacheResolver(operation.getExceptionCacheResolver(), null);
|
||||
assertThat(operation.getKeyGenerator().getClass()).isEqualTo(KeyGeneratorAdapter.class);
|
||||
@@ -144,7 +143,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
@Test
|
||||
public void customKeyGenerator() {
|
||||
CacheResultOperation operation =
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class);
|
||||
assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver);
|
||||
assertThat(operation.getExceptionCacheResolver()).isNull();
|
||||
assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
|
||||
@@ -155,7 +154,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator();
|
||||
beanFactory.registerSingleton("fooBar", bean);
|
||||
CacheResultOperation operation =
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
|
||||
getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class);
|
||||
assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver);
|
||||
assertThat(operation.getExceptionCacheResolver()).isNull();
|
||||
KeyGeneratorAdapter adapter = (KeyGeneratorAdapter) operation.getKeyGenerator();
|
||||
@@ -166,7 +165,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
@Test
|
||||
public void customKeyGeneratorAndCacheResolver() {
|
||||
CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
|
||||
CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
|
||||
CustomServiceWithDefaults.class, this.cacheName, Long.class);
|
||||
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
|
||||
assertJCacheResolver(operation.getExceptionCacheResolver(), null);
|
||||
assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
|
||||
@@ -175,7 +174,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
@Test
|
||||
public void customKeyGeneratorAndCacheResolverWithExceptionName() {
|
||||
CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
|
||||
CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
|
||||
CustomServiceWithDefaults.class, this.cacheName, Long.class);
|
||||
assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
|
||||
assertJCacheResolver(operation.getExceptionCacheResolver(), TestableCacheResolver.class);
|
||||
assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
|
||||
@@ -188,7 +187,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
}
|
||||
|
||||
protected <T extends JCacheOperation<?>> T getDefaultCacheOperation(Class<T> operationType, Class<?>... parameterTypes) {
|
||||
return getCacheOperation(operationType, AnnotatedJCacheableService.class, name.getMethodName(), parameterTypes);
|
||||
return getCacheOperation(operationType, AnnotatedJCacheableService.class, this.cacheName, parameterTypes);
|
||||
}
|
||||
|
||||
protected <T extends JCacheOperation<?>> T getCacheOperation(
|
||||
@@ -246,8 +245,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests {
|
||||
}
|
||||
|
||||
|
||||
@CacheDefaults(cacheResolverFactory = TestableCacheResolverFactory.class,
|
||||
cacheKeyGenerator = TestableCacheKeyGenerator.class)
|
||||
@CacheDefaults(cacheResolverFactory = TestableCacheResolverFactory.class, cacheKeyGenerator = TestableCacheKeyGenerator.class)
|
||||
static class CustomServiceWithDefaults {
|
||||
|
||||
@CacheResult
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CachePut;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheRemoveAll;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.cache.annotation.CacheInvocationParameter;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheRemove;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheResolver;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.jcache.AbstractJCacheTests;
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CacheMethodDetails;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import javax.cache.annotation.CacheRemoveAll;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
import javax.cache.annotation.CacheValue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -59,7 +59,7 @@ public class JCacheErrorHandlerTests {
|
||||
private SimpleService simpleService;
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
this.cache = context.getBean("mockCache", Cache.class);
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cache.jcache.interceptor;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.StaticListableBeanFactory;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
@@ -23,8 +23,8 @@ import javax.cache.annotation.CacheDefaults;
|
||||
import javax.cache.annotation.CacheKey;
|
||||
import javax.cache.annotation.CacheResult;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -51,7 +51,7 @@ public class JCacheKeyGeneratorTests {
|
||||
|
||||
private Cache cache;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||
this.keyGenerator = context.getBean(TestKeyGenerator.class);
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.cache.transaction;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
@@ -30,13 +30,19 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* {@link AbstractTransactionSupportingCacheManager}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
public abstract class AbstractTransactionSupportingCacheManagerTests<T extends CacheManager> {
|
||||
|
||||
public static final String CACHE_NAME = "testCacheManager";
|
||||
|
||||
@Rule
|
||||
public final TestName name = new TestName();
|
||||
|
||||
protected String cacheName;
|
||||
|
||||
@BeforeEach
|
||||
void trackCacheName(TestInfo testInfo) {
|
||||
this.cacheName = testInfo.getTestMethod().get().getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -72,24 +78,22 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
|
||||
@Test
|
||||
public void getOnNewCache() {
|
||||
T cacheManager = getCacheManager(false);
|
||||
String cacheName = name.getMethodName();
|
||||
addNativeCache(cacheName);
|
||||
assertThat(cacheManager.getCacheNames().contains(cacheName)).isFalse();
|
||||
addNativeCache(this.cacheName);
|
||||
assertThat(cacheManager.getCacheNames().contains(this.cacheName)).isFalse();
|
||||
try {
|
||||
assertThat(cacheManager.getCache(cacheName)).isInstanceOf(getCacheType());
|
||||
assertThat(cacheManager.getCacheNames().contains(cacheName)).isTrue();
|
||||
assertThat(cacheManager.getCache(this.cacheName)).isInstanceOf(getCacheType());
|
||||
assertThat(cacheManager.getCacheNames().contains(this.cacheName)).isTrue();
|
||||
}
|
||||
finally {
|
||||
removeNativeCache(cacheName);
|
||||
removeNativeCache(this.cacheName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOnUnknownCache() {
|
||||
T cacheManager = getCacheManager(false);
|
||||
String cacheName = name.getMethodName();
|
||||
assertThat(cacheManager.getCacheNames().contains(cacheName)).isFalse();
|
||||
assertThat(cacheManager.getCache(cacheName)).isNull();
|
||||
assertThat(cacheManager.getCacheNames().contains(this.cacheName)).isFalse();
|
||||
assertThat(cacheManager.getCache(this.cacheName)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,17 +104,16 @@ public abstract class AbstractTransactionSupportingCacheManagerTests<T extends C
|
||||
|
||||
@Test
|
||||
public void getTransactionalOnNewCache() {
|
||||
String cacheName = name.getMethodName();
|
||||
T cacheManager = getCacheManager(true);
|
||||
assertThat(cacheManager.getCacheNames().contains(cacheName)).isFalse();
|
||||
addNativeCache(cacheName);
|
||||
assertThat(cacheManager.getCacheNames().contains(this.cacheName)).isFalse();
|
||||
addNativeCache(this.cacheName);
|
||||
try {
|
||||
assertThat(cacheManager.getCache(cacheName))
|
||||
assertThat(cacheManager.getCache(this.cacheName))
|
||||
.isInstanceOf(TransactionAwareCacheDecorator.class);
|
||||
assertThat(cacheManager.getCacheNames().contains(cacheName)).isTrue();
|
||||
assertThat(cacheManager.getCacheNames().contains(this.cacheName)).isTrue();
|
||||
}
|
||||
finally {
|
||||
removeNativeCache(cacheName);
|
||||
removeNativeCache(this.cacheName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cache.transaction;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCache;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.mail.javamail;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.mail.javamail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
@@ -35,7 +35,7 @@ import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.mail.MailParseException;
|
||||
import org.springframework.mail.MailSendException;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.scheduling.quartz;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.quartz.CronTrigger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.scheduling.quartz;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.scheduling.quartz;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.quartz.SimpleTrigger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Properties;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.PostConstruct;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
|
||||
@@ -45,8 +45,8 @@ import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
@@ -72,7 +72,7 @@ public class SpringValidatorAdapterTests {
|
||||
private final StaticMessageSource messageSource = new StaticMessageSource();
|
||||
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupSpringValidatorAdapter() {
|
||||
messageSource.addMessage("Size", Locale.ENGLISH, "Size of {0} must be between {2} and {1}");
|
||||
messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value as {1}");
|
||||
|
||||
@@ -39,7 +39,7 @@ import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.hibernate.validator.HibernateValidator;
|
||||
import org.hibernate.validator.HibernateValidatorFactory;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
Reference in New Issue
Block a user