Search in sources :

Example 21 with LoggingParticipant

use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.

the class BasicIntegrationTestCase method testCommitOnePhase.

@Test
public void testCommitOnePhase() {
    txSupport.startTx();
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant);
    txSupport.commitTx();
    Assert.assertEquals(Arrays.asList(new String[] { "commitOnePhase" }), participant.getInvocations());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 22 with LoggingParticipant

use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.

the class BasicIntegrationTestCase method testHeuristicRollbackBeforePrepare.

@Test
public void testHeuristicRollbackBeforePrepare() throws JAXBException {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new Prepared()), new LoggingParticipant(new Prepared()) });
    String lastParticipantid = null;
    for (LoggingParticipant p : participants) {
        lastParticipantid = ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    ParticipantsManagerFactory.getInstance().reportHeuristic(lastParticipantid, HeuristicType.HEURISTIC_ROLLBACK);
    final String txStatus = TxSupport.getStatus(txSupport.commitTx());
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), txStatus);
    if (participants.get(0).getInvocations().size() == 1) {
        Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participants.get(0).getInvocations());
    } else {
        Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), participants.get(0).getInvocations());
    }
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 23 with LoggingParticipant

use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.

the class BasicIntegrationTestCase method testSecondParticipantHeuristicCommitWithFirstParticipantUnsuccessfullPrepare.

@Test
public void testSecondParticipantHeuristicCommitWithFirstParticipantUnsuccessfullPrepare() throws JAXBException {
    txSupport.startTx();
    LoggingParticipant loggingParticipant1 = new LoggingParticipant(new Aborted());
    LoggingParticipant loggingParticipant2 = new LoggingParticipant(new Prepared());
    ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), loggingParticipant1);
    String lastParticipantid = ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), loggingParticipant2);
    ParticipantsManagerFactory.getInstance().reportHeuristic(lastParticipantid, HeuristicType.HEURISTIC_COMMIT);
    System.out.println(ParticipantsContainer.getInstance().getParticipantInformation(lastParticipantid).getStatus());
    final String txStatus = TxSupport.getStatus(txSupport.commitTx());
    Assert.assertEquals(TxStatus.TransactionHeuristicCommit.name(), txStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), loggingParticipant1.getInvocations());
    Assert.assertEquals(Collections.EMPTY_LIST, loggingParticipant2.getInvocations());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Aborted(org.jboss.narayana.rest.integration.api.Aborted) Test(org.junit.Test)

Example 24 with LoggingParticipant

use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant 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 25 with LoggingParticipant

use of org.jboss.narayana.rest.integration.test.common.LoggingParticipant in project narayana by jbosstm.

the class ParticipantResourceTestCase method testForgetHeuristicWithoutHeuristic.

@Test
@SuppressWarnings("rawtypes")
public void testForgetHeuristicWithoutHeuristic() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    Response simpleResponse = forgetParticipantHeuristic(participantId);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Assert.assertEquals(412, simpleResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionActive.name(), participantInformation.getStatus());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Response(javax.ws.rs.core.Response) Prepared(org.jboss.narayana.rest.integration.api.Prepared) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) Test(org.junit.Test)

Aggregations

LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)30 Test (org.junit.Test)30 Prepared (org.jboss.narayana.rest.integration.api.Prepared)25 ParticipantInformation (org.jboss.narayana.rest.integration.ParticipantInformation)15 Response (javax.ws.rs.core.Response)14 Aborted (org.jboss.narayana.rest.integration.api.Aborted)5 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)4 HeuristicParticipant (org.jboss.narayana.rest.integration.test.common.HeuristicParticipant)4 Uid (com.arjuna.ats.arjuna.common.Uid)2 LoggingVolatileParticipant (org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant)2 Link (javax.ws.rs.core.Link)1 TestParticipantDeserializer (org.jboss.narayana.rest.integration.test.common.TestParticipantDeserializer)1