Search in sources :

Example 6 with Aborted

use of org.jboss.narayana.rest.integration.api.Aborted in project narayana by jbosstm.

the class BasicIntegrationTestCase method testHeuristicCommitAfterUnsuccessfullPrepare.

@Test
public void testHeuristicCommitAfterUnsuccessfullPrepare() {
    txSupport.startTx();
    LoggingParticipant loggingParticipant = new LoggingParticipant(new Aborted());
    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.TransactionHeuristicCommit.name(), txStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), loggingParticipant.getInvocations());
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), heuristicParticipant.getInvocations());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) HeuristicParticipant(org.jboss.narayana.rest.integration.test.common.HeuristicParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Aborted(org.jboss.narayana.rest.integration.api.Aborted) Test(org.junit.Test)

Example 7 with Aborted

use of org.jboss.narayana.rest.integration.api.Aborted in project narayana by jbosstm.

the class ParticipantResourceTestCase method testPrepareOutcomeAborted.

@Test
public void testPrepareOutcomeAborted() throws Exception {
    final LoggingParticipant participant = new LoggingParticipant(new Aborted());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Response stringResponse = prepareParticipant(participantId);
    Assert.assertEquals(409, stringResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), TxSupport.getStatus(stringResponse.readEntity(String.class)));
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), participantInformation.getStatus());
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), participant.getInvocations());
    Assert.assertNull(ParticipantsContainer.getInstance().getParticipantInformation(participantId));
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Response(javax.ws.rs.core.Response) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) Aborted(org.jboss.narayana.rest.integration.api.Aborted) Test(org.junit.Test)

Aggregations

Aborted (org.jboss.narayana.rest.integration.api.Aborted)7 Test (org.junit.Test)6 LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)5 Prepared (org.jboss.narayana.rest.integration.api.Prepared)4 HeuristicParticipant (org.jboss.narayana.rest.integration.test.common.HeuristicParticipant)2 Response (javax.ws.rs.core.Response)1 ParticipantInformation (org.jboss.narayana.rest.integration.ParticipantInformation)1 ParticipantException (org.jboss.narayana.rest.integration.api.ParticipantException)1 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)1 Vote (org.jboss.narayana.rest.integration.api.Vote)1 LoggingParticipant (org.wildfly.test.extension.rts.common.LoggingParticipant)1