Search in sources :

Example 1 with LoggingParticipant

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

the class ParticipantsManagerTestCase method testReportHeuristic.

@Test
public void testReportHeuristic() throws MalformedURLException {
    final String participantId = new Uid().toString();
    registerParticipant(participantId, new LoggingParticipant(new Prepared()));
    final ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    participantInformation.setStatus(TxStatus.TransactionPrepared.name());
    participantsManager.reportHeuristic(participantId, HeuristicType.HEURISTIC_ROLLBACK);
    Assert.assertEquals(TxStatus.TransactionHeuristicRollback.name(), participantInformation.getStatus());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Uid(com.arjuna.ats.arjuna.common.Uid) Prepared(org.jboss.narayana.rest.integration.api.Prepared) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) Test(org.junit.Test)

Example 2 with LoggingParticipant

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

the class BasicIntegrationTestCase method testHeuristicRollbackAfterUnsuccessfullPrepare.

@Test
public void testHeuristicRollbackAfterUnsuccessfullPrepare() {
    txSupport.startTx();
    LoggingParticipant loggingParticipant = new LoggingParticipant(new Aborted());
    HeuristicParticipant heuristicParticipant = new HeuristicParticipant(HeuristicType.HEURISTIC_ROLLBACK, 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.TransactionRolledBack.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 3 with LoggingParticipant

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

the class BasicIntegrationTestCase method testSecondParticipantHeuristicCommitWithFirstParticipantSuccessfullPrepare.

@Test
public void testSecondParticipantHeuristicCommitWithFirstParticipantSuccessfullPrepare() 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_COMMIT);
    final String txStatus = TxSupport.getStatus(txSupport.commitTx());
    Assert.assertEquals(TxStatus.TransactionCommitted.name(), txStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participants.get(0).getInvocations());
    Assert.assertEquals(Collections.EMPTY_LIST, participants.get(1).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 4 with LoggingParticipant

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

the class BasicIntegrationTestCase method testRollbackWithVolatileParticipant.

@Test
public void testRollbackWithVolatileParticipant() {
    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.rollbackTx());
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), txStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), loggingParticipant.getInvocations());
    Assert.assertEquals(Arrays.asList(new String[] { "afterCompletion" }), loggingVolatileParticipant.getInvocations());
    Assert.assertEquals(TxStatus.TransactionRolledBack, loggingVolatileParticipant.getTxStatus());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) LoggingVolatileParticipant(org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant) Test(org.junit.Test)

Example 5 with LoggingParticipant

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

the class BasicIntegrationTestCase method testHeuristicRollbackAfterSuccessfullPrepare.

@Test
public void testHeuristicRollbackAfterSuccessfullPrepare() {
    txSupport.startTx();
    LoggingParticipant loggingParticipant = new LoggingParticipant(new Prepared());
    HeuristicParticipant heuristicParticipant = new HeuristicParticipant(HeuristicType.HEURISTIC_ROLLBACK, 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.TransactionHeuristicMixed.name(), txStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), loggingParticipant.getInvocations());
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), 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) 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