Search in sources :

Example 1 with FailureBusinessParticipant

use of com.arjuna.wstx.tests.common.FailureBusinessParticipant in project narayana by jbosstm.

the class MultiCloseTest method testMultiClose.

@Test
public void testMultiClose() throws Exception {
    ParticipantCompletionCoordinatorRules.setParticipantCount(2);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm1 = null;
    com.arjuna.wst11.BAParticipantManager bpm2 = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1240");
    FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CLOSE, "5679");
    try {
        uba.begin();
        bpm1 = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1240");
        bpm2 = bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5679");
        bpm1.completed();
        bpm2.completed();
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
        }
        throw eouter;
    }
    uba.close();
    assertTrue(p.passed());
}
Also used : DemoBusinessParticipant(com.arjuna.wstx.tests.common.DemoBusinessParticipant) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) FailureBusinessParticipant(com.arjuna.wstx.tests.common.FailureBusinessParticipant) Test(org.junit.Test)

Example 2 with FailureBusinessParticipant

use of com.arjuna.wstx.tests.common.FailureBusinessParticipant in project narayana by jbosstm.

the class MultiCancelTest method testMultiCancel.

@Test
public void testMultiCancel() throws Exception {
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CANCEL, "1239");
    FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_CANCEL, "5678");
    try {
        uba.begin();
        bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1239");
        bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5678");
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
        }
        throw eouter;
    }
    try {
        uba.cancel();
    } catch (SystemException ex) {
        // failure will result in heuristic hazard warning message but wil not throw an exception
        throw ex;
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
        }
        throw eouter;
    }
    assertTrue(p.passed());
}
Also used : DemoBusinessParticipant(com.arjuna.wstx.tests.common.DemoBusinessParticipant) SystemException(com.arjuna.wst.SystemException) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) FailureBusinessParticipant(com.arjuna.wstx.tests.common.FailureBusinessParticipant) SystemException(com.arjuna.wst.SystemException) Test(org.junit.Test)

Example 3 with FailureBusinessParticipant

use of com.arjuna.wstx.tests.common.FailureBusinessParticipant in project narayana by jbosstm.

the class MultiCompensateTest method testMultiCompensate.

@Test
public void testMultiCompensate() throws Exception {
    ParticipantCompletionCoordinatorRules.setParticipantCount(2);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm1 = null;
    com.arjuna.wst11.BAParticipantManager bpm2 = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.COMPENSATE, "1241");
    FailureBusinessParticipant fp = new FailureBusinessParticipant(FailureBusinessParticipant.FAIL_IN_COMPENSATE, "5680");
    try {
        uba.begin();
        bpm1 = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1241");
        bpm2 = bam.enlistForBusinessAgreementWithParticipantCompletion(fp, "5680");
        bpm1.completed();
        bpm2.completed();
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
        }
        throw eouter;
    }
    // the cancel/compensate should succeed even though the participant fails to compensate
    uba.cancel();
    assertTrue(p.passed());
}
Also used : DemoBusinessParticipant(com.arjuna.wstx.tests.common.DemoBusinessParticipant) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) FailureBusinessParticipant(com.arjuna.wstx.tests.common.FailureBusinessParticipant) Test(org.junit.Test)

Aggregations

BusinessActivityManager (com.arjuna.mw.wst11.BusinessActivityManager)3 UserBusinessActivity (com.arjuna.mw.wst11.UserBusinessActivity)3 DemoBusinessParticipant (com.arjuna.wstx.tests.common.DemoBusinessParticipant)3 FailureBusinessParticipant (com.arjuna.wstx.tests.common.FailureBusinessParticipant)3 Test (org.junit.Test)3 SystemException (com.arjuna.wst.SystemException)1