Consistent early eviction tests in regular and transactional scenarios

See gh-23192
This commit is contained in:
Juergen Hoeller
2019-07-20 15:05:07 +02:00
parent be65bef91b
commit 8aa0b07768
11 changed files with 290 additions and 243 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -39,12 +39,17 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.support.TransactionTemplate;
/**
* @author Stephane Nicoll
* @author Juergen Hoeller
*/
public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
private final TransactionTemplate txTemplate = new TransactionTemplate(new CallCountingTransactionManager());
private CacheManager jCacheManager;
@@ -76,6 +81,26 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
public void testCustomCacheManager() {
}
@Test
public void testEvictWithTransaction() {
txTemplate.execute(() -> testEvict(this.cs, false));
}
@Test
public void testEvictEarlyWithTransaction() {
txTemplate.execute(() -> testEvictEarly(this.cs));
}
@Test
public void testEvictAllWithTransaction() {
txTemplate.execute(() -> testEvictAll(this.cs, false));
}
@Test
public void testEvictAllEarlyWithTransaction() {
txTemplate.execute(() -> testEvictAllEarly(this.cs));
}
@Configuration
@EnableCaching
@@ -87,7 +112,9 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests {
@Override
@Bean
public org.springframework.cache.CacheManager cacheManager() {
return new JCacheCacheManager(jCacheManager());
JCacheCacheManager cm = new JCacheCacheManager(jCacheManager());
cm.setTransactionAware(true);
return cm;
}
@Bean