use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.
the class BasicIntegrationTestCase method testHeuristicCommitAfterSuccessfullPrepare.
@Test
public void testHeuristicCommitAfterSuccessfullPrepare() {
txSupport.startTx();
LoggingParticipant loggingParticipant = new LoggingParticipant(new Prepared());
HeuristicParticipant heuristicParticipant = new HeuristicParticipant(HeuristicType.HEURISTIC_COMMIT, new Prepared());
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), loggingParticipant);
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), heuristicParticipant);
final String txStatus = TxSupport.getStatus(txSupport.commitTx());
Assert.assertEquals(TxStatus.TransactionCommitted.name(), txStatus);
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), loggingParticipant.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), heuristicParticipant.getInvocations());
}
use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.
the class BasicIntegrationTestCase method testRollback.
@Test
public void testRollback() {
txSupport.startTx();
LoggingParticipant participant1 = new LoggingParticipant(new Prepared());
LoggingParticipant participant2 = new LoggingParticipant(new Prepared());
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant1);
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant2);
txSupport.rollbackTx();
Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participant1.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participant2.getInvocations());
}
use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.
the class BasicIntegrationTestCase method testRollbackByParticipant.
@Test
public void testRollbackByParticipant() {
txSupport.startTx();
final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new Aborted()), new LoggingParticipant(new Aborted()) });
for (LoggingParticipant p : participants) {
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
}
txSupport.commitTx();
// One of the participants was prepared and then decided to rollback, the other was rolledback straight away.
Assert.assertEquals(3, participants.get(0).getInvocations().size() + participants.get(1).getInvocations().size());
for (LoggingParticipant p : participants) {
if (p.getInvocations().size() == 1) {
Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), p.getInvocations());
} else {
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), p.getInvocations());
}
}
}
use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.
the class BasicIntegrationTestCase method testCommitWithVolatileParticipant.
@Test
public void testCommitWithVolatileParticipant() {
txSupport.startTx();
LoggingParticipant loggingParticipant = new LoggingParticipant(new Prepared());
LoggingVolatileParticipant loggingVolatileParticipant = new LoggingVolatileParticipant();
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), loggingParticipant);
ParticipantsManagerFactory.getInstance().enlistVolatileParticipant(txSupport.getVolatileParticipantEnlistmentURI(), loggingVolatileParticipant);
final String txStatus = TxSupport.getStatus(txSupport.commitTx());
Assert.assertEquals(TxStatus.TransactionCommitted.name(), txStatus);
Assert.assertEquals(Arrays.asList(new String[] { "commitOnePhase" }), loggingParticipant.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "beforeCompletion", "afterCompletion" }), loggingVolatileParticipant.getInvocations());
Assert.assertEquals(TxStatus.TransactionCommitted, loggingVolatileParticipant.getTxStatus());
}
use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.
the class BasicIntegrationTestCase method testCommit.
@Test
public void testCommit() {
txSupport.startTx();
LoggingParticipant participant1 = new LoggingParticipant(new Prepared());
LoggingParticipant participant2 = new LoggingParticipant(new Prepared());
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant1);
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant2);
txSupport.commitTx();
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participant1.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participant2.getInvocations());
}
Aggregations