Search in sources :

Example 11 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class TransactionFactoryUnitTest method testContext.

@Test
public void testContext() throws Exception {
    TransactionFactoryImple factory = new TransactionFactoryImple("test");
    ControlImple tx = factory.createLocal(1000);
    org.omg.CosTransactions.otid_t txId = Utility.uidToOtid(tx.get_uid());
    Uid theUid = Utility.otidToUid(txId);
    assertEquals(theUid, tx.get_uid());
    // no state in OS yet!
    assertEquals(factory.getOSStatus(tx.get_uid()), org.omg.CosTransactions.Status.StatusNoTransaction);
    PropagationContext ctx = tx.get_coordinator().get_txcontext();
    Control cont = factory.recreate(ctx);
    String toString = Utility.getHierarchy(ctx);
    System.out.println(toString);
    assertTrue(toString != null);
    assertTrue(toString.length() > 1);
    assertTrue(Utility.getUid(cont).equals(tx.get_uid()));
    try {
        tx.getImplHandle().rollback();
    } catch (final Throwable ex) {
    }
}
Also used : CosTransactions.otid_t(org.omg.CosTransactions.otid_t) Uid(com.arjuna.ats.arjuna.common.Uid) Control(org.omg.CosTransactions.Control) PropagationContext(org.omg.CosTransactions.PropagationContext) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Example 12 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class TransactionTest3 method test.

@Test
public void test() throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    myORB = ORB.getInstance("test");
    myOA = OA.getRootOA(myORB);
    myORB.initORB(new String[] {}, null);
    myOA.initOA();
    ORBManager.setORB(myORB);
    ORBManager.setPOA(myOA);
    try {
        OTSManager.get_current().begin();
        Control cont = OTSManager.get_current().get_control();
        OTSManager.get_current().commit(true);
        OTSManager.get_current().resume(cont);
        System.out.println("\nPassed.");
    } catch (Throwable e) {
        fail("caught: " + e);
        e.printStackTrace();
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : Control(org.omg.CosTransactions.Control) RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 13 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class TransactionTest4 method test.

@Test
public void test() throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    myORB = ORB.getInstance("test");
    myOA = OA.getRootOA(myORB);
    myORB.initORB(new String[] {}, null);
    myOA.initOA();
    ORBManager.setORB(myORB);
    ORBManager.setPOA(myOA);
    try {
        OTSManager.get_current().begin();
        Control cont = OTSManager.get_current().get_control();
        OTSManager.get_current().commit(true);
        OTSManager.get_current().resume(cont);
        cont = OTSManager.get_current().suspend();
        System.out.println("\nPassed.");
    } catch (Throwable e) {
        fail("caught: " + e);
        e.printStackTrace();
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : Control(org.omg.CosTransactions.Control) RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 14 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class TransactionTest5 method test.

@Test
public void test() throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    try {
        myORB = ORB.getInstance("test");
        myOA = OA.getRootOA(myORB);
        myORB.initORB(new String[] {}, null);
        myOA.initOA();
        ORBManager.setORB(myORB);
        ORBManager.setPOA(myOA);
    } catch (Exception e) {
        System.err.println("Initialisation failed: " + e);
    }
    try {
        OTSManager.get_current().begin();
        Control cont = OTSManager.get_current().get_control();
        OTSManager.get_current().commit(true);
        OTSManager.get_current().resume(cont);
        OTSManager.get_current().rollback_only();
        System.out.println("\nFailed.");
    } catch (org.omg.CosTransactions.NoTransaction ex) {
        System.out.println("\nPassed.");
    } catch (Throwable e) {
        fail("caught: " + e);
        e.printStackTrace();
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : Control(org.omg.CosTransactions.Control) RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 15 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class OSIInterpositionUnitTest method test.

@Test
public void test() throws Exception {
    OTSImpleManager.current().begin();
    PropagationContext ctx = OTSImpleManager.current().get_control().get_coordinator().get_txcontext();
    OSIInterpositionCreator creator = new OSIInterpositionCreator();
    Control cnt = creator.recreate(ctx);
    ControlImple impl = creator.recreateLocal(ctx);
    assertTrue(cnt != null);
    assertTrue(impl != null);
    OTSImpleManager.current().rollback();
}
Also used : OSIInterpositionCreator(com.arjuna.ats.internal.jts.interposition.resources.osi.OSIInterpositionCreator) Control(org.omg.CosTransactions.Control) PropagationContext(org.omg.CosTransactions.PropagationContext) ControlImple(com.arjuna.ats.internal.jts.orbspecific.ControlImple) Test(org.junit.Test)

Aggregations

Control (org.omg.CosTransactions.Control)103 Test (org.junit.Test)40 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)24 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)20 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 ORB (com.arjuna.orbportability.ORB)20 RootOA (com.arjuna.orbportability.RootOA)18 TransactionFactory (org.omg.CosTransactions.TransactionFactory)16 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)14 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)13 Coordinator (org.omg.CosTransactions.Coordinator)13 SystemException (org.omg.CORBA.SystemException)11 IntHolder (org.omg.CORBA.IntHolder)10 Current (org.omg.CosTransactions.Current)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)6 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)6 Services (com.arjuna.orbportability.Services)6 PropagationContext (org.omg.CosTransactions.PropagationContext)6 ActionControl (com.arjuna.ArjunaOTS.ActionControl)5 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)5