Search in sources :

Example 1 with FailureXAResource

use of com.hp.mwtests.ts.jta.tools.FailureXAResource in project narayana by jbosstm.

the class ObjStoreBrowserTest method testMBeanHeuristic.

/**
 * Test that resources that generate heuristics are instrumented correctly
 * @throws Exception
 */
@Test
public void testMBeanHeuristic() throws Exception {
    // generates a heuristic on commit
    FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
    getHeuristicMBean(osb, new TransactionImple(), failureXAResource);
}
Also used : FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) Test(org.junit.Test)

Example 2 with FailureXAResource

use of com.hp.mwtests.ts.jta.tools.FailureXAResource in project narayana by jbosstm.

the class ObjStoreBrowserTest method getHeuristic.

private HeuristicTestData getHeuristic() throws Exception {
    // generates a heuristic on commit
    FailureXAResource failureXAResource = new FailureXAResource(FailureXAResource.FailLocation.commit);
    TransactionImple tx = new TransactionImple();
    XAResourceRecordBeanMBean resourceBean = getHeuristicMBean(osb, tx, failureXAResource);
    JTAActionBean txnMBean = getTransactionBean(osb, tx, true);
    Set<ObjectName> participants;
    String resourceBeanName;
    String txnBeanName;
    assertNotNull(txnMBean);
    assertNotNull(resourceBean);
    txnBeanName = String.format("jboss.jta:type=ObjectStore,itype=%s,uid=%s", txnMBean.type(), txnMBean.getId().replace(':', '_'));
    resourceBeanName = String.format("%s,puid=%s", txnBeanName, resourceBean.getId().replace(':', '_'));
    participants = JMXServer.getAgent().queryNames(resourceBeanName, null);
    assertEquals(1, participants.size());
    return new HeuristicTestData(tx, failureXAResource, txnMBean, resourceBean, participants.iterator().next(), txnBeanName, resourceBeanName);
}
Also used : XAResourceRecordBeanMBean(com.arjuna.ats.internal.jta.tools.osb.mbean.jts.XAResourceRecordBeanMBean) FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) TransactionImple(com.arjuna.ats.internal.jta.transaction.jts.TransactionImple) JTAActionBean(com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean) ObjectName(javax.management.ObjectName)

Example 3 with FailureXAResource

use of com.hp.mwtests.ts.jta.tools.FailureXAResource in project narayana by jbosstm.

the class ObjStoreBrowserTest method generateHeuristic.

private TransactionImple generateHeuristic(TransactionImple tx, FailureXAResource failureXAResource) throws Exception {
    ThreadActionData.purgeActions();
    XAResource[] resources = { new DummyXA(false), failureXAResource };
    // enlist the XA resources into the transaction
    for (XAResource resource : resources) tx.enlistResource(resource);
    try {
        tx.commit();
        fail("Expected a mixed heuristic");
    } catch (final HeuristicMixedException expected) {
    }
    return tx;
}
Also used : FailureXAResource(com.hp.mwtests.ts.jta.tools.FailureXAResource) XAResource(javax.transaction.xa.XAResource) DummyXA(com.hp.mwtests.ts.jta.common.DummyXA) HeuristicMixedException(javax.transaction.HeuristicMixedException)

Aggregations

FailureXAResource (com.hp.mwtests.ts.jta.tools.FailureXAResource)3 TransactionImple (com.arjuna.ats.internal.jta.transaction.jts.TransactionImple)2 JTAActionBean (com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean)1 XAResourceRecordBeanMBean (com.arjuna.ats.internal.jta.tools.osb.mbean.jts.XAResourceRecordBeanMBean)1 DummyXA (com.hp.mwtests.ts.jta.common.DummyXA)1 ObjectName (javax.management.ObjectName)1 HeuristicMixedException (javax.transaction.HeuristicMixedException)1 XAResource (javax.transaction.xa.XAResource)1 Test (org.junit.Test)1