Search in sources :

Example 11 with ORB

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

the class ImplicitClient method test.

@Test
public void test() throws Exception {
    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());
    ORB orb = ORB.getInstance("implicitserver-orb");
    OA oa = OA.getRootOA(orb);
    orb.initORB(new String[] {}, null);
    oa.initPOA(new String[] {});
    File file = new File("server.ior");
    FileReader fileReader = new FileReader(file);
    BufferedReader br = new BufferedReader(fileReader);
    String ior = br.readLine();
    // TODO orb.orb().string_to_object(getService("TODO"));
    org.omg.CORBA.Object obj = orb.orb().string_to_object(ior);
    Example.test test = Example.testHelper.narrow(obj);
    TransactionManager.transactionManager().begin();
    test.invoke();
    TransactionManager.transactionManager().commit();
    oa.destroy();
    orb.destroy();
}
Also used : OA(com.arjuna.orbportability.OA) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 12 with ORB

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

the class TransactionManagerGetStatusDifferenceDemonstrator method test.

@Test
public void test() throws InvalidName, SystemException, NotSupportedException, javax.transaction.SystemException, IllegalStateException, RollbackException, IOException, SecurityException, HeuristicMixedException, HeuristicRollbackException, Unavailable, SynchronizationUnavailable, Inactive {
    String mode = "jts";
    TransactionManager transactionManager;
    if (mode.equals("jts")) {
        ORB myORB = ORB.getInstance("test");
        RootOA myOA = OA.getRootOA(myORB);
        myORB.initORB(new String[0], null);
        myOA.initOA();
        com.arjuna.ats.internal.jts.ORBManager.setORB(myORB);
        com.arjuna.ats.internal.jts.ORBManager.setPOA(myOA);
        RecoveryManager.manager().initialize();
        transactionManager = new com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple();
    } else {
        transactionManager = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple();
    }
    transactionManager.begin();
    GetStatusSync getStatusSync = new GetStatusSync(transactionManager);
    transactionManager.getTransaction().registerSynchronization(getStatusSync);
    transactionManager.commit();
    try {
        if (mode.equals("jts")) {
            String orbClassName = System.getProperty("OrbPortabilityEnvironmentBean.orbImpleClassName");
            System.out.printf("%s: orbClassName=%s%n", this.getClass().getName(), orbClassName);
            if ("com.arjuna.orbportability.internal.orbspecific.javaidl.orb.implementations.javaidl_1_4".equals(orbClassName) || "com.arjuna.orbportability.internal.orbspecific.ibmorb.orb.implementations.ibmorb_7_1".equals(orbClassName)) {
                assertTrue("Status: " + getStatusSync.getTransactionManagerGetStatus(), getStatusSync.getTransactionManagerGetStatus() == Status.STATUS_COMMITTED);
            } else {
                // com.arjuna.orbportability.internal.orbspecific.jacorb.orb.implementations.jacorb_2_0
                assertTrue("Status: " + getStatusSync.getTransactionManagerGetStatus(), getStatusSync.getTransactionManagerGetStatus() == Status.STATUS_NO_TRANSACTION);
            }
        } else {
            assertTrue("Status: " + getStatusSync.getTransactionManagerGetStatus(), getStatusSync.getTransactionManagerGetStatus() == Status.STATUS_COMMITTED);
        }
        assertTrue(getStatusSync.getAfterCompletionStatus() == Status.STATUS_COMMITTED);
    } finally {
        if (mode.equals("jts")) {
            RecoveryManager.manager().terminate();
            ORB myORB = ORB.getInstance("test");
            RootOA myOA = OA.getRootOA(myORB);
            myOA.destroy();
            myORB.shutdown();
        }
    }
}
Also used : TransactionManager(javax.transaction.TransactionManager) RootOA(com.arjuna.orbportability.RootOA) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 13 with ORB

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

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

the class AtomicObject1 method test.

@Test
public void test() throws Exception {
    ORB myORB = null;
    RootOA myOA = null;
    myORB = ORB.getInstance("test");
    myOA = OA.getRootOA(myORB);
    ORBManager.setORB(myORB);
    ORBManager.setPOA(myOA);
    myORB.initORB(new String[] {}, null);
    myOA.initOA();
    AtomicWorker1.init();
    AtomicWorker1.atomicObject_1 = new AtomicObject();
    AtomicWorker1.atomicObject_2 = new AtomicObject();
    System.out.println(AtomicWorker1.atomicObject_1.get_uid());
    System.out.println(AtomicWorker1.atomicObject_2.get_uid());
    assertTrue(AtomicWorker1.atomicObject_1.set(START_VALUE_1));
    assertTrue(AtomicWorker1.atomicObject_2.set(START_VALUE_2));
    AtomicWorker1.get12('m', 0);
    AtomicWorker1.get21('m', 0);
    for (int i = 0; i < 100; i++) AtomicWorker1.randomOperation('1', 0);
    AtomicWorker1.get12('m', 0);
    AtomicWorker1.get21('m', 0);
    try {
        int value1 = AtomicWorker1.get1();
        int value2 = AtomicWorker1.get2();
        assertEquals(EXPECTED_VALUE, (value1 + value2));
    } catch (Exception e) {
        e.printStackTrace(System.err);
        fail();
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : RootOA(com.arjuna.orbportability.RootOA) AtomicObject(com.hp.mwtests.ts.jts.orbspecific.resources.AtomicObject) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 15 with ORB

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

the class HeuristicTest method test.

@Test
public void test() throws Exception {
    boolean shouldCommit = true;
    boolean heuristicPrepare = false;
    Coordinator coord = null;
    ORB myORB = null;
    RootOA myOA = null;
    heuristic hImpl = null;
    try {
        myORB = ORB.getInstance("test");
        myOA = OA.getRootOA(myORB);
        myORB.initORB(new String[] {}, null);
        myOA.initOA();
        ORBManager.setORB(myORB);
        ORBManager.setPOA(myOA);
        Current current = OTSManager.get_current();
        hImpl = new heuristic(heuristicPrepare);
        Resource heuristicObject = hImpl.getReference();
        AtomicResource aImpl = new AtomicResource(shouldCommit);
        Resource atomicObject = aImpl.getReference();
        System.out.println("beginning top-level transaction.");
        current.begin();
        Control myControl = current.get_control();
        assertNotNull(myControl);
        System.out.println("getting coordinator");
        coord = myControl.get_coordinator();
        myControl = null;
        System.out.println("registering resources.");
        try {
            coord.register_resource(heuristicObject);
            coord.register_resource(atomicObject);
        } catch (Exception ex) {
            fail("Failed to register resources: " + ex);
            ex.printStackTrace(System.err);
        }
        System.out.println("committing top-level transaction.");
        current.commit(true);
    } catch (TRANSACTION_ROLLEDBACK e1) {
        System.out.println("\nTransaction RolledBack exception");
    } catch (HeuristicMixed e2) {
        System.out.println("\nTransaction HeuristicMixed exception");
    } catch (HeuristicHazard e3) {
        System.out.println("\nTransaction HeuristicHazard exception");
    } catch (Exception e4) {
        fail("Caught unexpected exception: " + e4);
        e4.printStackTrace(System.err);
    }
    System.out.println("Trying to determing final transaction outcome.");
    org.omg.CosTransactions.Status status = Status.StatusUnknown;
    try {
        if (coord != null) {
            status = coord.get_status();
            coord = null;
        } else {
            fail("\nCould not determine action status.");
        }
    } catch (SystemException ex1) {
    // assume invalid reference - tx may have been garbage collected
    } catch (Exception e5) {
        fail("Caught unexpected exception:" + e5);
        e5.printStackTrace(System.err);
    }
    System.out.println("\nFinal action status: " + Utility.stringStatus(status));
    System.out.println("Test completed successfully.");
    ResourceTrace trace = hImpl.getTrace();
    if ((!heuristicPrepare) && (shouldCommit) && (trace.getTrace() == ResourceTrace.ResourceTracePrepareCommitHeurisiticRollbackForget)) {
    // assertSuccess();
    } else {
        if ((!heuristicPrepare) && (!shouldCommit) && (trace.getTrace() == ResourceTrace.ResourceTracePrepareRollback)) {
        // assertSuccess();
        } else {
            if ((heuristicPrepare) && (shouldCommit) && (trace.getTrace() == ResourceTrace.ResourceTracePrepareHeuristicHazardForget)) {
            // assertSuccess();
            } else {
                fail();
            }
        }
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : AtomicResource(com.hp.mwtests.ts.jts.orbspecific.resources.AtomicResource) Resource(org.omg.CosTransactions.Resource) RootOA(com.arjuna.orbportability.RootOA) com.hp.mwtests.ts.jts.orbspecific.resources.heuristic(com.hp.mwtests.ts.jts.orbspecific.resources.heuristic) AtomicResource(com.hp.mwtests.ts.jts.orbspecific.resources.AtomicResource) Coordinator(org.omg.CosTransactions.Coordinator) SystemException(org.omg.CORBA.SystemException) HeuristicHazard(org.omg.CosTransactions.HeuristicHazard) ResourceTrace(com.hp.mwtests.ts.jts.utils.ResourceTrace) Control(org.omg.CosTransactions.Control) SystemException(org.omg.CORBA.SystemException) Status(org.omg.CosTransactions.Status) Current(org.omg.CosTransactions.Current) TRANSACTION_ROLLEDBACK(org.omg.CORBA.TRANSACTION_ROLLEDBACK) HeuristicMixed(org.omg.CosTransactions.HeuristicMixed) ORB(com.arjuna.orbportability.ORB) 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