Search in sources :

Example 1 with DemoBusinessParticipant

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

the class CloseBeforeCompletedTest method test.

@Test
public void test() throws Exception {
    ParticipantCompletionCoordinatorCloseBeforeCompletedRules.setParticipantCount(1);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1235");
    try {
        uba.begin();
        bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, p.identifier());
        bpm.completed();
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
            einner.printStackTrace();
        }
        throw eouter;
    }
    boolean caughtTransactionRolledBackException = false;
    try {
        uba.close();
    } catch (TransactionRolledBackException e) {
        caughtTransactionRolledBackException = true;
    }
    assertTrue(caughtTransactionRolledBackException);
}
Also used : DemoBusinessParticipant(com.arjuna.wstx.tests.common.DemoBusinessParticipant) BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) UserBusinessActivity(com.arjuna.mw.wst11.UserBusinessActivity) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) Test(org.junit.Test)

Example 2 with DemoBusinessParticipant

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

the class ExitTest method testExit.

@Test
public void testExit() throws Exception {
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.EXIT, "1238");
    try {
        uba.begin();
        bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, "1238");
        bpm.exit();
    } 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) Test(org.junit.Test)

Example 3 with DemoBusinessParticipant

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

the class CloseTest method testClose.

@Test
public void testClose() throws Exception {
    ParticipantCompletionCoordinatorRules.setParticipantCount(1);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm = null;
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.CLOSE, "1235");
    try {
        uba.begin();
        bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, p.identifier());
        bpm.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) Test(org.junit.Test)

Example 4 with DemoBusinessParticipant

use of com.arjuna.wstx.tests.common.DemoBusinessParticipant 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 5 with DemoBusinessParticipant

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

the class CompensateTest method testCompensate.

@Test
public void testCompensate() throws Exception {
    ParticipantCompletionCoordinatorRules.setParticipantCount(1);
    UserBusinessActivity uba = UserBusinessActivity.getUserBusinessActivity();
    BusinessActivityManager bam = BusinessActivityManager.getBusinessActivityManager();
    com.arjuna.wst11.BAParticipantManager bpm = null;
    String participantId = "1236";
    DemoBusinessParticipant p = new DemoBusinessParticipant(DemoBusinessParticipant.COMPENSATE, participantId);
    try {
        uba.begin();
        bpm = bam.enlistForBusinessAgreementWithParticipantCompletion(p, participantId);
        bpm.completed();
    } catch (Exception eouter) {
        try {
            uba.cancel();
        } catch (Exception einner) {
        }
        throw eouter;
    }
    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) Test(org.junit.Test)

Aggregations

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