Search in sources :

Example 1 with TransactionManagerImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple in project narayana by jbosstm.

the class TransactionManagerImpleUnitTest method test.

@Test
public void test() throws Exception {
    TransactionManagerImple tmi = new TransactionManagerImple();
    assertEquals(tmi.getTransaction(), null);
    assertEquals(tmi.getObjectInstance(null, null, null, null), tmi);
    tmi.setTransactionTimeout(10);
    assertEquals(tmi.getTimeout(), 10);
}
Also used : TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple) Test(org.junit.Test)

Example 2 with TransactionManagerImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple in project narayana by jbosstm.

the class JTSXARTest method injectCommitException.

void injectCommitException(String exceptionType) throws Exception {
    XAFailureSpec fault = new XAFailureSpec("JTSXARTest", XAFailureMode.XAEXCEPTION, XAFailureType.XARES_COMMIT, exceptionType, 0);
    XAException xae = XAFailureResource.getXAExceptionType(exceptionType);
    int expectedXAE = xae == null ? HeuristicStatus.UNKNOWN_XA_ERROR_CODE : xae.errorCode;
    TransactionManagerImple tm = new TransactionManagerImple();
    Uid txUid;
    TransactionImple txn;
    // clean the thread that will create the transaction
    ThreadActionData.purgeActions();
    // begin a transaction
    tm.begin();
    txn = (TransactionImple) tm.getTransaction();
    txUid = txn.get_uid();
    // enlist two XA resources
    tm.getTransaction().enlistResource(new XAFailureResource());
    tm.getTransaction().enlistResource(new XAFailureResource(fault));
    // commit the transaction and check for any expected exceptions
    try {
        tm.commit();
    } catch (HeuristicRollbackException e) {
        if (!XAFailureSpec.compatibleHeuristics(XAException.XA_HEURRB, expectedXAE))
            throw e;
    } catch (RollbackException e) {
        if (!XAFailureSpec.compatibleHeuristics(XAException.XA_RBROLLBACK, expectedXAE))
            throw e;
    } catch (HeuristicMixedException e) {
        if (!XAFailureSpec.compatibleHeuristics(XAException.XA_HEURMIX, expectedXAE))
            throw e;
    } catch (SystemException e) {
        if (!XAFailureSpec.compatibleHeuristics(XAException.XAER_RMFAIL, expectedXAE))
            throw e;
    }
    // Validate that the correct MBeans were created to instrument the transaction and participants
    // and validate they have the correct heuristic status
    ObjStoreBrowser osb = createObjStoreBrowser(true);
    UidWrapper w = osb.findUid(txUid);
    assertNotNull(w);
    Set<UidWrapper> wrappers = validateChildBeans(osb, w.getName(), 1, expectedXAE);
    assertTrue(wrappers.size() > 0);
}
Also used : XAException(javax.transaction.xa.XAException) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) ObjStoreBrowser(com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser) Uid(com.arjuna.ats.arjuna.common.Uid) TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple) UidWrapper(com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper)

Example 3 with TransactionManagerImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple in project narayana by jbosstm.

the class LastResourceDisallowTestCase method testDisallowed.

@Test
public void testDisallowed() throws SystemException, NotSupportedException, RollbackException {
    final LastOnePhaseResource firstResource = new LastOnePhaseResource();
    final LastOnePhaseResource secondResource = new LastOnePhaseResource();
    final TransactionManager tm = new TransactionManagerImple();
    tm.begin();
    try {
        final Transaction tx = tm.getTransaction();
        assertTrue("First resource enlisted", tx.enlistResource(firstResource));
        assertFalse("Second resource enlisted", tx.enlistResource(secondResource));
    } finally {
        tm.rollback();
    }
}
Also used : TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple) Transaction(javax.transaction.Transaction) TransactionManager(javax.transaction.TransactionManager) Test(org.junit.Test)

Example 4 with TransactionManagerImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple in project narayana by jbosstm.

the class TransactionManagerImpleUnitTest method testNested.

@Test
public void testNested() throws Exception {
    TransactionManagerImple tmi = new TransactionManagerImple();
    tmi.begin();
    try {
        tmi.begin();
    } catch (final Throwable ex) {
    }
    tmi.rollback();
}
Also used : TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple) Test(org.junit.Test)

Example 5 with TransactionManagerImple

use of com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple in project narayana by jbosstm.

the class ResourceManagerFailureUnitTest method before.

@Before
public void before() throws Exception {
    final Map<String, String> orbInitializationProperties = new HashMap<String, String>();
    orbInitializationProperties.put("com.arjuna.orbportability.orb.PreInit1", "com.arjuna.ats.internal.jts.recovery.RecoveryInit");
    opPropertyManager.getOrbPortabilityEnvironmentBean().setOrbInitializationProperties(orbInitializationProperties);
    final Properties initORBProperties = new Properties();
    initORBProperties.setProperty("com.sun.CORBA.POA.ORBServerId", "1");
    initORBProperties.setProperty("com.sun.CORBA.POA.ORBPersistentServerPort", "" + jtsPropertyManager.getJTSEnvironmentBean().getRecoveryManagerPort());
    testORB = ORB.getInstance("test");
    testOA = OA.getRootOA(testORB);
    testORB.initORB(new String[] {}, initORBProperties);
    testOA.initOA();
    ORBManager.setORB(testORB);
    ORBManager.setPOA(testOA);
    final List<String> recoveryExtensions = new ArrayList<String>();
    recoveryExtensions.add(XARecoveryModule.class.getName());
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryModuleClassNames(recoveryExtensions);
    final List<String> recoveryActivatorClassNames = new ArrayList<String>();
    recoveryActivatorClassNames.add(RecoveryEnablement.class.getName());
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryActivatorClassNames(recoveryActivatorClassNames);
    recoveryManager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    recoveryManager.initialize();
    transactionManager = new TransactionManagerImple();
}
Also used : TransactionManagerImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple) HashMap(java.util.HashMap) RecoveryEnablement(com.arjuna.ats.internal.jts.orbspecific.recovery.RecoveryEnablement) ArrayList(java.util.ArrayList) Properties(java.util.Properties) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule) Before(org.junit.Before)

Aggregations

TransactionManagerImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple)6 Test (org.junit.Test)4 Transaction (javax.transaction.Transaction)2 TransactionManager (javax.transaction.TransactionManager)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 ObjStoreBrowser (com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser)1 UidWrapper (com.arjuna.ats.arjuna.tools.osb.mbean.UidWrapper)1 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)1 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)1 RecoveryEnablement (com.arjuna.ats.internal.jts.orbspecific.recovery.RecoveryEnablement)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 XAException (javax.transaction.xa.XAException)1 Before (org.junit.Before)1