Search in sources :

Example 31 with RootOA

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

the class ExplicitInterClient method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    CurrentImple current = OTSImpleManager.current();
    Control theControl = null;
    String objectReference = args[0];
    SetGet SetGetVar = null;
    short h = 0;
    try {
        current.begin();
        current.begin();
        current.begin();
    } catch (Exception e) {
        TestUtility.fail("Caught exception during begin: " + e);
        e.printStackTrace(System.err);
    }
    try {
        Services serv = new Services(myORB);
        SetGetVar = SetGetHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(objectReference)));
    } catch (Exception ex) {
        TestUtility.fail("Failed to bind to setget server: " + ex);
        ex.printStackTrace(System.err);
    }
    try {
        theControl = current.get_control();
        SetGetVar.set((short) 2, theControl);
        // SetGetVar.set((short) 2, theControl);
        theControl = null;
        System.out.println("Set value.");
    } catch (Exception ex1) {
        TestUtility.fail("Unexpected system exception during set: " + ex1);
        ex1.printStackTrace(System.err);
    }
    try {
        System.out.println("committing first nested action");
        current.commit(true);
        // SetGetVar.set((short) 4, current.get_control());
        System.out.println("committing second nested action");
        current.commit(true);
    } catch (Exception sysEx) {
        TestUtility.fail("Caught unexpected exception during commit: " + sysEx);
        sysEx.printStackTrace(System.err);
    }
    try {
        theControl = current.get_control();
        h = SetGetVar.get(theControl);
        theControl = null;
        System.out.println("Got value.");
    } catch (Exception ex2) {
        TestUtility.fail("Unexpected system exception during get: " + ex2);
        ex2.printStackTrace(System.err);
    }
    try {
        current.commit(true);
        System.out.println("committed top-level action");
    } catch (Exception ep) {
        TestUtility.fail("Caught commit exception for top-level action: " + ep);
        ep.printStackTrace(System.err);
    }
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) Control(org.omg.CosTransactions.Control) SetGet(com.hp.mwtests.ts.jts.TestModule.SetGet) RootOA(com.arjuna.orbportability.RootOA) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 32 with RootOA

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

the class DistributedHammer1 method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String server1 = args[0];
    String server2 = args[1];
    try {
        Services serv = new Services(myORB);
        DistributedHammerWorker1.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
        DistributedHammerWorker1.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
        TestUtility.assertTrue(DistributedHammerWorker1.hammerObject_1.set(START_VALUE_1, null));
        TestUtility.assertTrue(DistributedHammerWorker1.hammerObject_2.set(START_VALUE_2, null));
        DistributedHammerWorker1.get12('m', 0);
        DistributedHammerWorker1.get21('m', 0);
    } catch (Exception e) {
        TestUtility.fail("DistributedHammer1: " + e);
        e.printStackTrace(System.err);
    }
    for (int i = 0; i < 100; i++) DistributedHammerWorker1.randomOperation('1', 0);
    DistributedHammerWorker1.get12('m', 0);
    DistributedHammerWorker1.get21('m', 0);
    IntHolder value1 = new IntHolder(0);
    IntHolder value2 = new IntHolder(0);
    TestUtility.assertTrue(DistributedHammerWorker1.get1(value1) | DistributedHammerWorker1.get2(value2));
    TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) IntHolder(org.omg.CORBA.IntHolder) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 33 with RootOA

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

the class DistributedHammer3 method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String server1 = args[0];
    String server2 = args[1];
    try {
        Services serv = new Services(myORB);
        DistributedHammerWorker3.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
        DistributedHammerWorker3.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
        TestUtility.assertTrue(DistributedHammerWorker3.hammerObject_1.set(START_VALUE_1, null));
        TestUtility.assertTrue(DistributedHammerWorker3.hammerObject_2.set(START_VALUE_2, null));
        DistributedHammerWorker3.get12(0, 0);
        DistributedHammerWorker3.get21(0, 0);
    } catch (Exception e) {
        TestUtility.fail("DistributedHammer3: " + e);
        e.printStackTrace(System.err);
    }
    DHThreadObject3b thr1 = new DHThreadObject3b(1);
    DHThreadObject3b thr2 = new DHThreadObject3b(2);
    thr1.start();
    thr2.start();
    try {
        thr1.join();
        thr2.join();
    } catch (InterruptedException e) {
        System.err.println(e);
    }
    DistributedHammerWorker3.get12(0, 0);
    DistributedHammerWorker3.get21(0, 0);
    IntHolder value1 = new IntHolder(0);
    IntHolder value2 = new IntHolder(0);
    TestUtility.assertTrue(DistributedHammerWorker3.get1(value1) | DistributedHammerWorker3.get2(value2));
    TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
    myOA.destroy();
    myORB.shutdown();
    System.out.println("Passed");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) DHThreadObject3b(com.hp.mwtests.ts.jts.orbspecific.resources.DHThreadObject3b) IntHolder(org.omg.CORBA.IntHolder) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 34 with RootOA

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

the class ImplGridServer method main.

public static void main(String[] args) throws Exception {
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    String refFile = args[0];
    trangrid_i gridI = new trangrid_i((short) 100, (short) 100);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(gridI.getReference()));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        TestUtility.fail("ImplGrid server caught exception: " + e);
    }
    myOA.shutdownObject(gridI);
    System.out.println("**ImplGrid server exiting**");
}
Also used : com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i(com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 35 with RootOA

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

the class SimpleTest 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);
    jtaPropertyManager.getJTAEnvironmentBean().setTransactionManagerClassName(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple.class.getName());
    jtaPropertyManager.getJTAEnvironmentBean().setUserTransactionClassName(com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple.class.getName());
    javax.transaction.TransactionManager transactionManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
    transactionManager.begin();
    Transaction currentTrans = transactionManager.getTransaction();
    TestResource res1, res2;
    currentTrans.enlistResource(res1 = new TestResource());
    currentTrans.enlistResource(res2 = new TestResource());
    currentTrans.delistResource(res2, XAResource.TMSUCCESS);
    currentTrans.delistResource(res1, XAResource.TMSUCCESS);
    transactionManager.commit();
    myOA.destroy();
    myORB.shutdown();
}
Also used : Transaction(javax.transaction.Transaction) RootOA(com.arjuna.orbportability.RootOA) TestResource(com.hp.mwtests.ts.jta.jts.common.TestResource) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

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