Search in sources :

Example 1 with TopLevelTransaction

use of com.arjuna.ats.jts.extensions.TopLevelTransaction in project narayana by jbosstm.

the class TopLevelTransactionUnitTest method testSuspendResume.

@Test
public void testSuspendResume() throws Exception {
    TopLevelTransaction A = new TopLevelTransaction();
    A.begin();
    assertTrue(A.control() != null);
    A.suspend();
    assertEquals(OTSImpleManager.current().get_control(), null);
    A.resume();
    assertTrue(OTSImpleManager.current() != null);
    A.rollback();
}
Also used : TopLevelTransaction(com.arjuna.ats.jts.extensions.TopLevelTransaction) Test(org.junit.Test)

Example 2 with TopLevelTransaction

use of com.arjuna.ats.jts.extensions.TopLevelTransaction in project narayana by jbosstm.

the class TopLevelTransactionUnitTest method test.

@Test
public void test() throws Exception {
    TopLevelTransaction A = new TopLevelTransaction();
    A.begin();
    assertTrue(A.get_transaction_name() != null);
    A.set_timeout(10);
    assertEquals(A.get_timeout(), 10);
    assertTrue(A.getTimeout() != -1);
    assertTrue(A.get_txcontext() != null);
    assertTrue(A.get_uid().notEquals(Uid.nullUid()));
    assertTrue(A.control() != null);
    assertFalse(A.equals(null));
    assertTrue(A.equals(A));
    assertFalse(A.equals(new TopLevelTransaction()));
    A.rollback();
}
Also used : TopLevelTransaction(com.arjuna.ats.jts.extensions.TopLevelTransaction) Test(org.junit.Test)

Example 3 with TopLevelTransaction

use of com.arjuna.ats.jts.extensions.TopLevelTransaction in project narayana by jbosstm.

the class TopLevelTransactionUnitTest method testRollback.

@Test
public void testRollback() throws Exception {
    AtomicTransaction A = new AtomicTransaction();
    A.begin();
    assertTrue(A.get_txcontext() != null);
    A.registerResource(new DemoResource().getResource());
    TopLevelTransaction B = new TopLevelTransaction();
    DemoResource d = new DemoResource();
    B.begin();
    B.registerResource(d.getResource());
    B.commit(true);
    A.rollback();
    assertEquals(d.getResourceTrace().getTrace(), ResourceTrace.ResourceTraceCommitOnePhase);
}
Also used : DemoResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource) AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) TopLevelTransaction(com.arjuna.ats.jts.extensions.TopLevelTransaction) Test(org.junit.Test)

Example 4 with TopLevelTransaction

use of com.arjuna.ats.jts.extensions.TopLevelTransaction in project narayana by jbosstm.

the class TopLevelTransactionUnitTest method testCommit.

@Test
public void testCommit() throws Exception {
    AtomicTransaction A = new AtomicTransaction();
    A.begin();
    assertTrue(A.get_txcontext() != null);
    A.registerResource(new DemoResource().getResource());
    TopLevelTransaction B = new TopLevelTransaction();
    DemoResource d = new DemoResource();
    B.begin();
    B.registerResource(d.getResource());
    B.commit(true);
    A.commit(true);
    assertEquals(d.getResourceTrace().getTrace(), ResourceTrace.ResourceTraceCommitOnePhase);
}
Also used : DemoResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource) AtomicTransaction(com.arjuna.ats.jts.extensions.AtomicTransaction) TopLevelTransaction(com.arjuna.ats.jts.extensions.TopLevelTransaction) Test(org.junit.Test)

Aggregations

TopLevelTransaction (com.arjuna.ats.jts.extensions.TopLevelTransaction)4 Test (org.junit.Test)4 AtomicTransaction (com.arjuna.ats.jts.extensions.AtomicTransaction)2 DemoResource (com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource)2