Search in sources :

Example 1 with ServerORB

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

the class AsyncTest method test.

@Test
public void test() throws Exception {
    boolean errorp = false;
    boolean errorc = false;
    ServerORB orb = new ServerORB();
    ORB myORB = orb.getORB();
    RootOA myOA = orb.getOA();
    try {
        Current current = OTSManager.get_current();
        DemoResource.printThread = true;
        current.begin();
        for (int j = 0; j < 100; j++) {
            if ((j == 10) && (errorp || errorc)) {
                boolean heuristicPrepare = errorp;
                heuristic h = new heuristic(heuristicPrepare);
                current.get_control().get_coordinator().register_resource(h.getReference());
                h = null;
            }
            DemoResource r = new DemoResource();
            r.registerResource();
            r = null;
        }
        System.out.println("committing top-level transaction");
        current.commit(false);
        System.out.println("Test completed.");
    } catch (org.omg.CORBA.TRANSACTION_ROLLEDBACK e) {
        System.out.println("Caught exception: " + e);
        assertTrue(errorp || errorc);
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : DemoResource(com.hp.mwtests.ts.jts.orbspecific.resources.DemoResource) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) RootOA(com.arjuna.orbportability.RootOA) com.hp.mwtests.ts.jts.orbspecific.resources.heuristic(com.hp.mwtests.ts.jts.orbspecific.resources.heuristic) Current(org.omg.CosTransactions.Current) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 2 with ServerORB

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

the class ExplicitStackServer 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];
    ExplicitStackPOATie theObject = new ExplicitStackPOATie(new ExplicitStackImple());
    myOA.objectIsReady(theObject);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(myOA.corbaReference(theObject)));
        System.out.println("Ready");
        myOA.run();
    } catch (Exception e) {
        e.printStackTrace();
    }
    myOA.shutdownObject(theObject);
    System.out.println("**ExplicitStackServer exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ExplicitStackImple(com.hp.mwtests.ts.jts.orbspecific.resources.ExplicitStackImple) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) ExplicitStackPOATie(com.hp.mwtests.ts.jts.TestModule.ExplicitStackPOATie) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 3 with ServerORB

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

the class HammerServer 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];
    HammerPOATie theObject = new HammerPOATie(new HammerObject());
    myOA.objectIsReady(theObject);
    Services serv = new Services(myORB);
    try {
        TestUtility.registerService(refFile, myORB.orb().object_to_string(HammerHelper.narrow(myOA.corbaReference(theObject))));
        System.out.println("\nIOR file: " + refFile);
        System.out.println("Ready");
        // assertReady();
        myOA.run();
    } catch (Exception e) {
        // fail("HammerServer caught exception: "+e);
        e.printStackTrace(System.err);
    }
    myOA.shutdownObject(theObject);
    System.out.println("**HammerServer exiting**");
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) RootOA(com.arjuna.orbportability.RootOA) HammerPOATie(com.hp.mwtests.ts.jts.TestModule.HammerPOATie) HammerObject(com.hp.mwtests.ts.jts.orbspecific.resources.HammerObject) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 4 with ServerORB

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

the class DistributedHammer2 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);
        DistributedHammerWorker2.hammerObject_1 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server1)));
        DistributedHammerWorker2.hammerObject_2 = HammerHelper.narrow(myORB.orb().string_to_object(TestUtility.getService(server2)));
        TestUtility.assertTrue(DistributedHammerWorker2.hammerObject_1.set(START_VALUE_1, null));
        TestUtility.assertTrue(DistributedHammerWorker2.hammerObject_2.set(START_VALUE_2, null));
        DistributedHammerWorker2.get12('m', 0);
        DistributedHammerWorker2.get21('m', 0);
    } catch (Exception e) {
        TestUtility.fail("DistributedHammer2: " + e);
        e.printStackTrace(System.err);
    }
    TaskProgress progress1 = TaskMonitor.INSTANCE.monitorProgress("DistributedHammer2", "DistributedHammer2", 60000L);
    TaskProgress progress2 = TaskMonitor.INSTANCE.monitorProgress("DistributedHammer2", "DistributedHammer2", 60000L);
    DHThreadObject2 thr1 = new DHThreadObject2(progress1, '1');
    DHThreadObject2 thr2 = new DHThreadObject2(progress2, '2');
    thr1.start();
    thr2.start();
    try {
        thr1.join();
        thr2.join();
    } catch (InterruptedException e) {
        TestUtility.fail("DistributedHammer2: " + e);
        e.printStackTrace(System.err);
    }
    DistributedHammerWorker2.get12('m', 0);
    DistributedHammerWorker2.get21('m', 0);
    IntHolder value1 = new IntHolder(0);
    IntHolder value2 = new IntHolder(0);
    boolean assert1 = DistributedHammerWorker2.get1(value1) | DistributedHammerWorker2.get2(value2);
    boolean assert2 = EXPECTED_RESULT == (value1.value + value2.value);
    TestUtility.assertTrue(DistributedHammerWorker2.get1(value1) | DistributedHammerWorker2.get2(value2));
    TestUtility.assertEquals(EXPECTED_RESULT, (value1.value + value2.value));
    myOA.destroy();
    myORB.shutdown();
    int res = assert1 && assert2 && progress1.isFinished() && progress2.isFinished() ? 0 : 1;
    System.out.printf("%s%n", (res == 0 ? "Passed" : "Failed"));
    System.exit(res);
}
Also used : ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) Services(com.arjuna.orbportability.Services) DHThreadObject2(com.hp.mwtests.ts.jts.orbspecific.resources.DHThreadObject2) IntHolder(org.omg.CORBA.IntHolder) RootOA(com.arjuna.orbportability.RootOA) TaskProgress(com.hp.mwtests.ts.jts.utils.TaskProgress) ServerORB(com.hp.mwtests.ts.jts.utils.ServerORB) ORB(com.arjuna.orbportability.ORB)

Example 5 with ServerORB

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

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