Browse Source

Polishing

pull/1702/head
Juergen Hoeller 8 years ago
parent
commit
9e55422334
  1. 4
      spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java
  2. 12
      spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java
  3. 34
      spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java
  4. 2
      spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java

4
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheManagerTests.java vendored

@ -1,5 +1,5 @@ @@ -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 @@ -52,7 +52,7 @@ public class EhCacheCacheManagerTests extends AbstractTransactionSupportingCache
}
@After
public void tearDown() {
public void shutdown() {
nativeCacheManager.shutdown();
}

12
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java vendored

@ -1,5 +1,5 @@ @@ -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.*; @@ -39,11 +39,14 @@ import static org.junit.Assert.*;
public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> {
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<EhCacheCache> { @@ -53,10 +56,11 @@ public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> {
}
@After
public void tearDown() {
public void shutdown() {
cacheManager.shutdown();
}
@Override
protected EhCacheCache getCache() {
return cache;
@ -67,9 +71,11 @@ public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> { @@ -67,9 +71,11 @@ public class EhCacheCacheTests extends AbstractCacheTests<EhCacheCache> {
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);

34
spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java vendored

@ -1,5 +1,5 @@ @@ -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; @@ -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.*; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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);

2
spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java

@ -37,7 +37,6 @@ import org.springframework.format.support.FormattingConversionService; @@ -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<StandaloneM @@ -353,7 +352,6 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
* @since 5.0
*/
public StandaloneMockMvcBuilder setCustomHandlerMapping(Supplier<RequestMappingHandlerMapping> factory) {
Assert.notNull(factory, "RequestMappingHandlerMapping supplier is required.");
this.handlerMappingFactory = factory;
return this;
}

Loading…
Cancel
Save