Search in sources :

Example 66 with RootOA

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

the class MultipleORBInstances method test.

@Test
public void test() {
    ORB[] orbInstance = new ORB[NUMBER_OF_ORBOAS];
    RootOA[] oaInstance = new RootOA[NUMBER_OF_ORBOAS];
    for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
        System.out.println("Creating ORB and OA #" + count);
        orbInstance[count] = ORB.getInstance("orb_" + count);
        oaInstance[count] = RootOA.getRootOA(orbInstance[count]);
        assertTrue(initialiseORBandOA(new String[] {}, orbInstance[count], oaInstance[count]));
    }
    assertTrue(ensureAllORBReferencesAreUnique(orbInstance, oaInstance));
    System.out.println("Retrieving all ORBs and OAs");
    for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
        System.out.println("Retrieving ORB and OA #" + count);
        ORB orb = ORB.getInstance("orb_" + count);
        assertNotNull(orb);
        assertNotNull(OA.getRootOA(orb));
    }
    System.out.println("Destroying all ORBs and OAs");
    for (int count = 0; count < NUMBER_OF_ORBOAS; count++) {
        orbInstance[count].destroy();
        oaInstance[count].destroy();
    }
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 67 with RootOA

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

the class OAPrePostShutdownTest method testOAShutdownCalled.

@Test
public void testOAShutdownCalled() throws Exception {
    ORB orb = ORB.getInstance("main_orb");
    RootOA oa = RootOA.getRootOA(orb);
    System.out.println("Initialising ORB and OA");
    orb.initORB(new String[] {}, null);
    oa.initOA();
    _currentState = NONE;
    /**
     * Register pre and post shutdown handlers
     */
    oa.addPreShutdown(new TestPreShutdown("PreShutdown", this));
    oa.addPostShutdown(new TestPostShutdown("PostShutdown", this));
    System.out.println("Shutting down ORB (expecting OA to also be destroyed)");
    orb.shutdown();
    /*
       * Ensure final state is correct
       */
    System.out.println("Final state: " + PrettyPrintState(_currentState));
    assertEquals(POSTSHUTDOWN, _currentState);
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 68 with RootOA

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

the class OAPrePostShutdownTest method test.

@Test
public void test() throws Exception {
    ORB orb = ORB.getInstance("main_orb");
    RootOA oa = RootOA.getRootOA(orb);
    System.out.println("Initialising ORB and OA");
    orb.initORB(new String[] {}, null);
    oa.initOA();
    _currentState = NONE;
    /**
     * Register pre and post shutdown handlers
     */
    oa.addPreShutdown(new TestPreShutdown("PreShutdown", this));
    oa.addPostShutdown(new TestPostShutdown("PostShutdown", this));
    System.out.println("Shutting down ORB and OA");
    oa.destroy();
    orb.shutdown();
    /*
       * Ensure final state is correct
       */
    System.out.println("Final state: " + PrettyPrintState(_currentState));
    assertEquals(POSTSHUTDOWN, _currentState);
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 69 with RootOA

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

the class ORBInitialisationTest method test.

@Test
public void test() {
    ORB orb = ORB.getInstance("main_orb");
    RootOA oa = RootOA.getRootOA(orb);
    try {
        _currentState = NONE;
        /*
            * Registering attributes with ORB
            */
        orb.addAttribute(new PreTestAttribute(this));
        orb.addAttribute(new PostTestAttribute(this));
        /*
	         * Initialise the ORB and OA
	         */
        System.out.println("Initialising ORB and OA");
        orb.initORB(new String[] {}, null);
        oa.initOA();
        assertEquals(POSTINIT, _currentState);
    } catch (Exception e) {
        fail("Initialisation failed: " + e);
    }
    oa.destroy();
    orb.shutdown();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 70 with RootOA

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

the class Client01 method main.

public static void main(String[] args) {
    int crashIn = Resource01.NOCRASH;
    ;
    if (args.length >= 1) {
        if (args[0].startsWith("p") || args[0].startsWith("P")) {
            crashIn = Resource01.PREPARE;
        }
        if (args[0].startsWith("c") || args[0].startsWith("C")) {
            crashIn = Resource01.COMMIT;
        }
        if (args[0].startsWith("r") || args[0].startsWith("R")) {
            crashIn = Resource01.ROLLBACK;
        }
    }
    if (args.length >= 2) {
        resultsFile = args[1];
    }
    try {
        ORB myORB = ORB.getInstance("Client01");
        RootOA myOA = OA.getRootOA(myORB);
        myORB.initORB(args, null);
        myOA.initOA();
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed");
    }
    System.out.println("Ready");
    try {
        UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
        ut.begin();
        TransactionImple txImple = (TransactionImple) TransactionManager.transactionManager().getTransaction();
        txImple.enlistResource(new Resource01(crashIn, resultsFile));
        txImple.enlistResource(new Resource02());
        ut.commit();
        System.out.println("Passed");
    } catch (javax.transaction.RollbackException rbx) {
        System.out.println("Passed");
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("Failed");
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) Resource01(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource01) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) RootOA(com.arjuna.orbportability.RootOA) Resource02(org.jboss.jbossts.qa.CrashRecovery12Resources.Resource02) ORB(com.arjuna.orbportability.ORB)

Aggregations

ORB (com.arjuna.orbportability.ORB)70 RootOA (com.arjuna.orbportability.RootOA)70 Test (org.junit.Test)49 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Services (com.arjuna.orbportability.Services)18 Control (org.omg.CosTransactions.Control)18 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)9 SystemException (org.omg.CORBA.SystemException)7 IntHolder (org.omg.CORBA.IntHolder)6 UserException (org.omg.CORBA.UserException)5 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)4 Terminator (org.omg.CosTransactions.Terminator)4 AtomicObject (com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject)3 Coordinator (org.omg.CosTransactions.Coordinator)3 Status (org.omg.CosTransactions.Status)3 TransactionFactory (org.omg.CosTransactions.TransactionFactory)3 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)2 TestResource (com.hp.mwtests.ts.jta.jts.common.TestResource)2 XACreator (com.hp.mwtests.ts.jta.jts.common.XACreator)2 SetGet (com.hp.mwtests.ts.jts.TestModule.SetGet)2