Search in sources :

Example 16 with ORB

use of com.arjuna.orbportability.ORB in project narayana by jbosstm.

the class NestedTester method test.

@Test
public void test() {
    boolean registerSubtran = false;
    boolean doAbort = false;
    DemoResource r = null;
    DemoSubTranResource sr = null;
    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);
        org.omg.CosTransactions.Current current = OTSManager.get_current();
        r = new DemoResource();
        sr = new DemoSubTranResource();
        current.begin();
        current.begin();
        current.begin();
        sr.registerResource(registerSubtran);
        r.registerResource();
        System.out.println("committing first nested transaction");
        current.commit(true);
        System.out.println("committing second nested transaction");
        current.commit(true);
        if (!doAbort) {
            System.out.println("committing top-level transaction");
            current.commit(true);
        } else {
            System.out.println("aborting top-level transaction");
            current.rollback();
        }
        System.out.println("Test completed successfully.");
        if ((!doAbort) && (!registerSubtran) && (sr.getNumberOfSubtransactionsRolledBack() == 0) && (sr.getNumberOfSubtransactionsCommitted() == 1) && (sr.getResourceTrace().getTrace() == ResourceTrace.ResourceTracePrepareCommit) && (r.getResourceTrace().getTrace() == ResourceTrace.ResourceTracePrepareCommit)) {
        // assertSuccess();
        } else {
            if ((doAbort) && (!registerSubtran) && (sr.getNumberOfSubtransactionsRolledBack() == 0) && (sr.getNumberOfSubtransactionsCommitted() == 1) && (sr.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceRollback) && (r.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceRollback)) {
            // assertSuccess();
            } else {
                if ((!doAbort) && (registerSubtran) && (sr.getNumberOfSubtransactionsRolledBack() == 0) && (sr.getNumberOfSubtransactionsCommitted() == 1) && (sr.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceNone) && (r.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceCommitOnePhase)) {
                // assertSuccess();
                } else {
                    if ((doAbort) && (registerSubtran) && (sr.getNumberOfSubtransactionsRolledBack() == 0) && (sr.getNumberOfSubtransactionsCommitted() == 1) && (sr.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceNone) && (r.getResourceTrace().getTrace() == ResourceTrace.ResourceTraceRollback)) {
                    // assertSuccess();
                    } else
                        fail();
                }
            }
        }
    } catch (UserException e) {
        fail("Caught UserException: " + e);
        e.printStackTrace(System.err);
    } catch (SystemException e) {
        fail("Caught SystemException: " + e);
        e.printStackTrace(System.err);
    }
    myOA.shutdownObject(r);
    myOA.shutdownObject(sr);
    myOA.destroy();
    myORB.shutdown();
}
Also used : DemoResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource) SystemException(org.omg.CORBA.SystemException) DemoSubTranResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoSubTranResource) RootOA(com.arjuna.orbportability.RootOA) UserException(org.omg.CORBA.UserException) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 17 with ORB

use of com.arjuna.orbportability.ORB 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 18 with ORB

use of com.arjuna.orbportability.ORB 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 19 with ORB

use of com.arjuna.orbportability.ORB 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 20 with ORB

use of com.arjuna.orbportability.ORB in project narayana by jbosstm.

the class ArjunaNestingTest method run.

@Test
public void run() 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);
    boolean doAbort = false;
    boolean registerSubtran = false;
    org.omg.CosTransactions.Current current = OTSManager.get_current();
    DemoArjunaResource sr = new DemoArjunaResource();
    try {
        current.begin();
        current.begin();
        current.begin();
    } catch (SystemException sysEx) {
        fail("Unexpected system exception:" + sysEx);
        sysEx.printStackTrace(System.err);
    } catch (UserException se) {
        fail("Unexpected user exception:" + se);
        se.printStackTrace(System.err);
    }
    try {
        sr.registerResource(registerSubtran);
    } catch (SystemException ex1) {
        fail("Unexpected system exception: " + ex1);
        ex1.printStackTrace(System.err);
    } catch (Exception e) {
        fail("call to registerSubtran failed: " + e);
        e.printStackTrace(System.err);
    }
    try {
        System.out.println("committing first nested transaction");
        current.commit(true);
        System.out.println("committing second nested transaction");
        current.commit(true);
        if (!doAbort) {
            System.out.println("committing top-level transaction");
            current.commit(true);
        } else {
            System.out.println("aborting top-level transaction");
            current.rollback();
        }
    } catch (Exception ex) {
        fail("Caught unexpected exception: " + ex);
        ex.printStackTrace(System.err);
    }
    myOA.shutdownObject(sr);
    myOA.destroy();
    myORB.shutdown();
}
Also used : DemoArjunaResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoArjunaResource) SystemException(org.omg.CORBA.SystemException) RootOA(com.arjuna.orbportability.RootOA) UserException(org.omg.CORBA.UserException) ORB(com.arjuna.orbportability.ORB) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) Test(org.junit.Test)

Aggregations

ORB (com.arjuna.orbportability.ORB)93 RootOA (com.arjuna.orbportability.RootOA)71 Test (org.junit.Test)57 OA (com.arjuna.orbportability.OA)20 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Control (org.omg.CosTransactions.Control)20 Services (com.arjuna.orbportability.Services)19 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 PerfTestInterface (org.jboss.jbossts.qa.performance.PerfTestInterface)7 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 Coordinator (org.omg.CosTransactions.Coordinator)6 UserException (org.omg.CORBA.UserException)5 Properties (java.util.Properties)4 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2