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