diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java index e0f7db5f1eb..5f3b825bec1 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -52,7 +52,7 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache } @After - public void tearDown() { + public void shutdown() { nativeCacheManager.shutdown(); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java index f8541b07c7e..0750279e244 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -39,11 +39,14 @@ import static org.junit.Assert.*; public class EhCacheCacheTests extends AbstractCacheTests { private CacheManager cacheManager; + private Ehcache nativeCache; + private EhCacheCache cache; + @Before - public void setUp() { + public void setup() { cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests") .defaultCache(new CacheConfiguration("default", 100))); nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100)); @@ -53,10 +56,11 @@ public class EhCacheCacheTests extends AbstractCacheTests { } @After - public void tearDown() { + public void shutdown() { cacheManager.shutdown(); } + @Override protected EhCacheCache getCache() { return cache; @@ -67,9 +71,11 @@ public class EhCacheCacheTests extends AbstractCacheTests { return nativeCache; } + @Test public void testExpiredElements() throws Exception { Assume.group(TestGroup.LONG_RUNNING); + String key = "brancusi"; String value = "constantin"; Element brancusi = new Element(key, value); diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java index ac411519333..d15107c5836 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 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. @@ -22,7 +22,6 @@ import net.sf.ehcache.CacheManager; import net.sf.ehcache.Ehcache; import net.sf.ehcache.config.CacheConfiguration; import net.sf.ehcache.constructs.blocking.BlockingCache; -import net.sf.ehcache.constructs.blocking.CacheEntryFactory; import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory; import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache; @@ -40,7 +39,7 @@ import static org.junit.Assert.*; public class EhCacheSupportTests { @Test - public void testBlankCacheManager() throws Exception { + public void testBlankCacheManager() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.setCacheManagerName("myCacheManager"); assertEquals(CacheManager.class, cacheManagerFb.getObjectType()); @@ -58,7 +57,7 @@ public class EhCacheSupportTests { } @Test - public void testCacheManagerConflict() throws Exception { + public void testCacheManagerConflict() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.setCacheManagerName("myCacheManager"); assertEquals(CacheManager.class, cacheManagerFb.getObjectType()); @@ -84,7 +83,7 @@ public class EhCacheSupportTests { } @Test - public void testAcceptExistingCacheManager() throws Exception { + public void testAcceptExistingCacheManager() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.setCacheManagerName("myCacheManager"); assertEquals(CacheManager.class, cacheManagerFb.getObjectType()); @@ -109,7 +108,7 @@ public class EhCacheSupportTests { } } - public void testCacheManagerFromConfigFile() throws Exception { + public void testCacheManagerFromConfigFile() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.setConfigLocation(new ClassPathResource("testEhcache.xml", getClass())); cacheManagerFb.setCacheManagerName("myCacheManager"); @@ -127,16 +126,16 @@ public class EhCacheSupportTests { } @Test - public void testEhCacheFactoryBeanWithDefaultCacheManager() throws Exception { + public void testEhCacheFactoryBeanWithDefaultCacheManager() { doTestEhCacheFactoryBean(false); } @Test - public void testEhCacheFactoryBeanWithExplicitCacheManager() throws Exception { + public void testEhCacheFactoryBeanWithExplicitCacheManager() { doTestEhCacheFactoryBean(true); } - private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exception { + private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) { Cache cache; EhCacheManagerFactoryBean cacheManagerFb = null; boolean cacheManagerFbInitialized = false; @@ -215,7 +214,7 @@ public class EhCacheSupportTests { } @Test - public void testEhCacheFactoryBeanWithBlockingCache() throws Exception { + public void testEhCacheFactoryBeanWithBlockingCache() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.afterPropertiesSet(); try { @@ -235,7 +234,7 @@ public class EhCacheSupportTests { } @Test - public void testEhCacheFactoryBeanWithSelfPopulatingCache() throws Exception { + public void testEhCacheFactoryBeanWithSelfPopulatingCache() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.afterPropertiesSet(); try { @@ -243,12 +242,7 @@ public class EhCacheSupportTests { EhCacheFactoryBean cacheFb = new EhCacheFactoryBean(); cacheFb.setCacheManager(cm); cacheFb.setCacheName("myCache1"); - cacheFb.setCacheEntryFactory(new CacheEntryFactory() { - @Override - public Object createEntry(Object key) throws Exception { - return key; - } - }); + cacheFb.setCacheEntryFactory(key -> key); assertEquals(cacheFb.getObjectType(), SelfPopulatingCache.class); cacheFb.afterPropertiesSet(); Ehcache myCache1 = cm.getEhcache("myCache1"); @@ -261,7 +255,7 @@ public class EhCacheSupportTests { } @Test - public void testEhCacheFactoryBeanWithUpdatingSelfPopulatingCache() throws Exception { + public void testEhCacheFactoryBeanWithUpdatingSelfPopulatingCache() { EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean(); cacheManagerFb.afterPropertiesSet(); try { @@ -271,11 +265,11 @@ public class EhCacheSupportTests { cacheFb.setCacheName("myCache1"); cacheFb.setCacheEntryFactory(new UpdatingCacheEntryFactory() { @Override - public Object createEntry(Object key) throws Exception { + public Object createEntry(Object key) { return key; } @Override - public void updateEntryValue(Object key, Object value) throws Exception { + public void updateEntryValue(Object key, Object value) { } }); assertEquals(cacheFb.getObjectType(), UpdatingSelfPopulatingCache.class); diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java index fcd271942d7..35c5b089a45 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java @@ -37,7 +37,6 @@ import org.springframework.format.support.FormattingConversionService; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.lang.Nullable; import org.springframework.mock.web.MockServletContext; -import org.springframework.util.Assert; import org.springframework.util.PropertyPlaceholderHelper; import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver; import org.springframework.util.StringValueResolver; @@ -353,7 +352,6 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder factory) { - Assert.notNull(factory, "RequestMappingHandlerMapping supplier is required."); this.handlerMappingFactory = factory; return this; }