Search in sources :

Example 16 with RTransaction

use of org.redisson.api.RTransaction in project redisson by redisson.

the class TransactionalBean method testRollback.

@Transactional
public void testRollback() {
    RTransaction transaction = transactionManager.getCurrentTransaction();
    transaction.getMap("test2").put("1", "2");
    throw new IllegalStateException();
}
Also used : RTransaction(org.redisson.api.RTransaction) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with RTransaction

use of org.redisson.api.RTransaction in project redisson by redisson.

the class TransactionalBean method testPropagationRequiredWithException.

@Transactional
public void testPropagationRequiredWithException() {
    RTransaction transaction = transactionManager.getCurrentTransaction();
    transaction.getMap("tr4").put("1", "0");
    transactionalBean2.testPropagationRequiredWithException();
}
Also used : RTransaction(org.redisson.api.RTransaction) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with RTransaction

use of org.redisson.api.RTransaction in project redisson by redisson.

the class TransactionalBean method testNoTransaction.

public void testNoTransaction() {
    try {
        RTransaction transaction = transactionManager.getCurrentTransaction();
        Assertions.fail();
    } catch (NoTransactionException e) {
    // skip
    }
}
Also used : NoTransactionException(org.springframework.transaction.NoTransactionException) RTransaction(org.redisson.api.RTransaction)

Example 19 with RTransaction

use of org.redisson.api.RTransaction in project redisson by redisson.

the class TransactionalBean method testCommit.

@Transactional
public void testCommit() {
    RTransaction transaction = transactionManager.getCurrentTransaction();
    transaction.getMap("test1").put("1", "2");
}
Also used : RTransaction(org.redisson.api.RTransaction) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with RTransaction

use of org.redisson.api.RTransaction in project redisson by redisson.

the class RedissonBaseTransactionalMapTest method testPut.

@Test
public void testPut() {
    RMap<String, String> m = getMap();
    m.put("1", "2");
    m.put("3", "4");
    RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
    RMap<String, String> map = getTransactionalMap(transaction);
    assertThat(map.put("3", "5")).isEqualTo("4");
    assertThat(map.get("3")).isEqualTo("5");
    assertThat(m.get("3")).isEqualTo("4");
    transaction.commit();
    assertThat(m.get("1")).isEqualTo("2");
    assertThat(m.get("3")).isEqualTo("5");
}
Also used : RTransaction(org.redisson.api.RTransaction) BaseTest(org.redisson.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

RTransaction (org.redisson.api.RTransaction)49 Test (org.junit.jupiter.api.Test)38 BaseTest (org.redisson.BaseTest)37 Transactional (org.springframework.transaction.annotation.Transactional)9 HashSet (java.util.HashSet)5 RBuckets (org.redisson.api.RBuckets)3 LinkedHashMap (java.util.LinkedHashMap)2 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 TransactionOptions (org.redisson.api.TransactionOptions)1 NoTransactionException (org.springframework.transaction.NoTransactionException)1