Search in sources :

Example 1 with TestResource

use of com.hp.mwtests.ts.jta.jts.common.TestResource in project narayana by jbosstm.

the class JTAOrder 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);
    boolean passed = false;
    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());
    try {
        javax.transaction.TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
        XAResource theResource = new TestResource();
        FirstXAResource first = new FirstXAResource();
        LastXAResource last = new LastXAResource();
        System.out.println("Starting top-level transaction.");
        tm.begin();
        javax.transaction.Transaction theTransaction = tm.getTransaction();
        theTransaction.enlistResource(theResource);
        theTransaction.enlistResource(last);
        theTransaction.enlistResource(first);
        System.err.println("Committing transaction.");
        tm.commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    myOA.destroy();
    myORB.shutdown();
}
Also used : FirstXAResource(com.hp.mwtests.ts.jta.jts.common.FirstXAResource) RootOA(com.arjuna.orbportability.RootOA) TestResource(com.hp.mwtests.ts.jta.jts.common.TestResource) XAResource(javax.transaction.xa.XAResource) FirstXAResource(com.hp.mwtests.ts.jta.jts.common.FirstXAResource) LastXAResource(com.hp.mwtests.ts.jta.jts.common.LastXAResource) LastXAResource(com.hp.mwtests.ts.jta.jts.common.LastXAResource) ORB(com.arjuna.orbportability.ORB) Test(org.junit.Test)

Example 2 with TestResource

use of com.hp.mwtests.ts.jta.jts.common.TestResource 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)2 RootOA (com.arjuna.orbportability.RootOA)2 TestResource (com.hp.mwtests.ts.jta.jts.common.TestResource)2 Test (org.junit.Test)2 FirstXAResource (com.hp.mwtests.ts.jta.jts.common.FirstXAResource)1 LastXAResource (com.hp.mwtests.ts.jta.jts.common.LastXAResource)1 Transaction (javax.transaction.Transaction)1 XAResource (javax.transaction.xa.XAResource)1