Search in sources :

Example 1 with UserTransactionImple

use of com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple in project narayana by jbosstm.

the class UserTransactionUnitTest method testRollbackOnly.

@Test
public void testRollbackOnly() throws Exception {
    ThreadActionData.purgeActions();
    UserTransactionImple ut = new UserTransactionImple();
    ut.begin();
    ut.setRollbackOnly();
    try {
        ut.commit();
        fail();
    } catch (final RollbackException ex) {
    }
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) RollbackException(javax.transaction.RollbackException) Test(org.junit.Test)

Example 2 with UserTransactionImple

use of com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple in project narayana by jbosstm.

the class UserTransactionUnitTest method testSubordinate.

@Test
public void testSubordinate() throws Exception {
    ThreadActionData.purgeActions();
    UserTransactionImple ut = new UserTransactionImple();
    assertTrue(ut.createSubordinate() != null);
    ut.begin();
    try {
        ut.createSubordinate();
        fail();
    } catch (final NotSupportedException ex) {
    }
    ut.commit();
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) NotSupportedException(javax.transaction.NotSupportedException) Test(org.junit.Test)

Example 3 with UserTransactionImple

use of com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple in project narayana by jbosstm.

the class UserTransactionUnitTest method test.

@Test
public void test() throws Exception {
    ThreadActionData.purgeActions();
    UserTransactionImple ut = new UserTransactionImple();
    assertEquals(ut.getTimeout(), 0);
    assertTrue(ut.toString() != null);
    assertEquals(ut.getObjectInstance(null, null, null, null), ut);
    try {
        ut = (UserTransactionImple) UserTransaction.userTransaction(new InitialContext());
        fail();
    } catch (final Throwable ex) {
    }
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Example 4 with UserTransactionImple

use of com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple in project narayana by jbosstm.

the class AsyncCommit method test.

@Test
public void test() throws Exception {
    UserTransactionImple ut = new UserTransactionImple();
    ut.begin();
    TransactionImple current = TransactionImple.getTransaction();
    TestResource res1, res2;
    current.enlistResource(res1 = new TestResource());
    current.enlistResource(res2 = new TestResource());
    current.delistResource(res2, XAResource.TMSUCCESS);
    current.delistResource(res1, XAResource.TMSUCCESS);
    Future<Void> commitAsync = ut.commitAsync();
    commitAsync.get();
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) TransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple) UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) TestResource(com.hp.mwtests.ts.jta.common.TestResource) Test(org.junit.Test)

Example 5 with UserTransactionImple

use of com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple in project narayana by jbosstm.

the class UserTransactionUnitTest method testNull.

@Test
public void testNull() throws Exception {
    ThreadActionData.purgeActions();
    UserTransactionImple ut = new UserTransactionImple();
    try {
        ut.commit();
        fail();
    } catch (final IllegalStateException ex) {
    }
    try {
        ut.rollback();
        fail();
    } catch (final IllegalStateException ex) {
    }
    try {
        ut.setRollbackOnly();
        fail();
    } catch (final IllegalStateException ex) {
    }
}
Also used : UserTransactionImple(com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple) Test(org.junit.Test)

Aggregations

UserTransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple)5 Test (org.junit.Test)5 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)1 TestResource (com.hp.mwtests.ts.jta.common.TestResource)1 InitialContext (javax.naming.InitialContext)1 NotSupportedException (javax.transaction.NotSupportedException)1 RollbackException (javax.transaction.RollbackException)1