use of org.springframework.cache.concurrent.ConcurrentMapCache in project spring-framework by spring-projects.
the class CachingResourceResolverTests method setup.
@Before
public void setup() {
this.cache = new ConcurrentMapCache("resourceCache");
List<ResourceResolver> resolvers = new ArrayList<>();
resolvers.add(new CachingResourceResolver(this.cache));
resolvers.add(new PathResourceResolver());
this.chain = new DefaultResourceResolverChain(resolvers);
this.locations = new ArrayList<>();
this.locations.add(new ClassPathResource("test/", getClass()));
}
use of org.springframework.cache.concurrent.ConcurrentMapCache in project spring-framework by spring-projects.
the class GzipResourceResolverTests method setup.
@Before
public void setup() {
Cache cache = new ConcurrentMapCache("resourceCache");
Map<String, VersionStrategy> versionStrategyMap = new HashMap<>();
versionStrategyMap.put("/**", new ContentVersionStrategy());
VersionResourceResolver versionResolver = new VersionResourceResolver();
versionResolver.setStrategyMap(versionStrategyMap);
List<ResourceResolver> resolvers = new ArrayList<>();
resolvers.add(new CachingResourceResolver(cache));
resolvers.add(new GzipResourceResolver());
resolvers.add(versionResolver);
resolvers.add(new PathResourceResolver());
this.resolver = new DefaultResourceResolverChain(resolvers);
this.locations = new ArrayList<>();
this.locations.add(new ClassPathResource("test/", getClass()));
this.locations.add(new ClassPathResource("testalternatepath/", getClass()));
}
use of org.springframework.cache.concurrent.ConcurrentMapCache in project spring-framework by spring-projects.
the class AbstractJCacheTests method createSimpleCacheManager.
protected static CacheManager createSimpleCacheManager(String... cacheNames) {
SimpleCacheManager result = new SimpleCacheManager();
List<Cache> caches = new ArrayList<>();
for (String cacheName : cacheNames) {
caches.add(new ConcurrentMapCache(cacheName));
}
result.setCaches(caches);
result.afterPropertiesSet();
return result;
}
use of org.springframework.cache.concurrent.ConcurrentMapCache in project spring-framework by spring-projects.
the class TransactionAwareCacheDecoratorTests method evictTransactional.
@Test
public void evictTransactional() {
Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object();
cache.put(key, "123");
TransactionStatus status = txManager.getTransaction(new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED));
cache.evict(key);
assertEquals("123", target.get(key, String.class));
txManager.commit(status);
assertNull(target.get(key));
}
use of org.springframework.cache.concurrent.ConcurrentMapCache in project spring-framework by spring-projects.
the class TransactionAwareCacheDecoratorTests method clearTransactional.
@Test
public void clearTransactional() {
Cache target = new ConcurrentMapCache("testCache");
Cache cache = new TransactionAwareCacheDecorator(target);
Object key = new Object();
cache.put(key, "123");
TransactionStatus status = txManager.getTransaction(new DefaultTransactionAttribute(TransactionDefinition.PROPAGATION_REQUIRED));
cache.clear();
assertEquals("123", target.get(key, String.class));
txManager.commit(status);
assertNull(target.get(key));
}
Aggregations