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);
}
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);
}
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();
}
}
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();
}
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();
}
Aggregations