use of org.springframework.transaction.interceptor.DefaultTransactionAttribute 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.transaction.interceptor.DefaultTransactionAttribute 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