Search in sources :

Example 6 with ServerORB

use of com.hp.mwtests.ts.jts.utils.ServerORB 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 7 with ServerORB

use of com.hp.mwtests.ts.jts.utils.ServerORB 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 8 with ServerORB

use of com.hp.mwtests.ts.jts.utils.ServerORB 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 9 with ServerORB

use of com.hp.mwtests.ts.jts.utils.ServerORB in project narayana by jbosstm.

the class SynchTest method test.

@Test
public void test() {
    org.omg.CosTransactions.Status status = Status.StatusUnknown;
    tranobject_i localObject = null;
    demosync sync = null;
    ORB myORB = null;
    RootOA myOA = null;
    try {
        ServerORB orb = new ServerORB();
        myORB = orb.getORB();
        myOA = orb.getOA();
        Control myControl = null;
        org.omg.CosTransactions.Current current = OTSManager.get_current();
        Coordinator coord = null;
        sync = new demosync();
        localObject = new tranobject_i();
        current.begin();
        myControl = current.get_control();
        coord = myControl.get_coordinator();
        coord.register_resource(localObject.getReference());
        coord.register_synchronization(sync.getReference());
        try {
            current.commit(true);
        } catch (TRANSACTION_ROLLEDBACK e1) {
            System.out.println("Transaction rolledback");
        }
        try {
            status = coord.get_status();
        } catch (SystemException ex) {
            // assume reference no longer valid!
            status = Status.StatusUnknown;
        }
    } catch (UserException e1) {
        fail("Caught UserException: " + e1);
        e1.printStackTrace();
    } catch (SystemException e2) {
        fail("Caught SystemException: " + e2);
        e2.printStackTrace();
    }
    System.out.print("Final action status: " + com.arjuna.ats.jts.utils.Utility.stringStatus(status));
    System.out.println("\nTest completed successfully.");
    myOA.shutdownObject(sync);
    myOA.shutdownObject(localObject);
    myOA.destroy();
    myORB.shutdown();
}
Also used : com.hp.mwtests.ts.jts.orbspecific.resources.tranobject_i(com.hp.mwtests.ts.jts.orbspecific.resources.tranobject_i) com.hp.mwtests.ts.jts.orbspecific.resources.demosync(com.hp.mwtests.ts.jts.orbspecific.resources.demosync) RootOA(com.arjuna.orbportability.RootOA) Coordinator(org.omg.CosTransactions.Coordinator) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) Status(org.omg.CosTransactions.Status) UserException(org.omg.CORBA.UserException) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 10 with ServerORB

use of com.hp.mwtests.ts.jts.utils.ServerORB in project narayana by jbosstm.

the class ImplicitClient 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];
    CurrentImple current = OTSImpleManager.current();
    // pointer the grid object that will be used.
    TranGrid TranGridVar = null;
    short h = 0, w = 0, v = 0;
    try {
        current.begin();
        Services serv = new Services(myORB);
        TranGridVar = TranGridHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(refFile)));
        try {
            h = TranGridVar.height();
            w = TranGridVar.width();
        } catch (Exception e) {
            TestUtility.fail("Invocation failed: " + e);
        }
        System.out.println("height is " + h);
        System.out.println("width  is " + w);
        try {
            System.out.println("calling set");
            TranGridVar.set((short) 2, (short) 4, (short) 123);
            System.out.println("calling get");
            v = TranGridVar.get((short) 2, (short) 4);
        } catch (Exception sysEx) {
            TestUtility.fail("Grid set/get failed: " + sysEx);
            sysEx.printStackTrace(System.err);
        }
        // no problem setting and getting the element:
        System.out.println("trangrid[2,4] is " + v);
        if (v != 123) {
            // oops - we didn't:
            current.rollback();
            TestUtility.fail("Result not as expected");
        } else {
            current.commit(true);
        }
    } catch (Exception e) {
        TestUtility.fail("Caught exception: " + e);
        e.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) 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) TranGrid(com.hp.mwtests.ts.jts.TestModule.TranGrid)

Aggregations

ORB (com.arjuna.orbportability.ORB)20 RootOA (com.arjuna.orbportability.RootOA)20 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)20 Services (com.arjuna.orbportability.Services)16 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)6 Control (org.omg.CosTransactions.Control)6 IntHolder (org.omg.CORBA.IntHolder)5 Test (org.junit.Test)4 SetGet (com.hp.mwtests.ts.jts.TestModule.SetGet)2 com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i (com.hp.mwtests.ts.jts.orbspecific.resources.trangrid_i)2 TRANSACTION_ROLLEDBACK (org.omg.CORBA.TRANSACTION_ROLLEDBACK)2 ExplicitStack (com.hp.mwtests.ts.jts.TestModule.ExplicitStack)1 ExplicitStackPOATie (com.hp.mwtests.ts.jts.TestModule.ExplicitStackPOATie)1 HammerPOATie (com.hp.mwtests.ts.jts.TestModule.HammerPOATie)1 TranGrid (com.hp.mwtests.ts.jts.TestModule.TranGrid)1 TestModule.grid (com.hp.mwtests.ts.jts.TestModule.grid)1 TestModule.stack (com.hp.mwtests.ts.jts.TestModule.stack)1 TestModule.stackPOATie (com.hp.mwtests.ts.jts.TestModule.stackPOATie)1 DHThreadObject2 (com.hp.mwtests.ts.jts.orbspecific.resources.DHThreadObject2)1 DHThreadObject3b (com.hp.mwtests.ts.jts.orbspecific.resources.DHThreadObject3b)1