Search in sources :

Example 6 with LoggingParticipant

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

Example 7 with LoggingParticipant

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());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 8 with LoggingParticipant

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());
        }
    }
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) Aborted(org.jboss.narayana.rest.integration.api.Aborted) Test(org.junit.Test)

Example 9 with LoggingParticipant

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());
}
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 10 with LoggingParticipant

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());
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) 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