Search in sources :

Example 1 with LoggingVolatileParticipant

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

the class VolatileParticipantResourceTestCase method testBeforeCompletion.

@Test
public void testBeforeCompletion() throws Exception {
    LoggingVolatileParticipant participant = new LoggingVolatileParticipant();
    registerParticipant(participantId, participant);
    Response response = beforeCompletion(participantId);
    Assert.assertEquals(200, response.getStatus());
    List<String> invocations = participant.getInvocations();
    Assert.assertEquals(1, invocations.size());
    Assert.assertEquals("beforeCompletion", invocations.get(0));
}
Also used : Response(javax.ws.rs.core.Response) LoggingVolatileParticipant(org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant) Test(org.junit.Test)

Example 2 with LoggingVolatileParticipant

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

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

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

the class VolatileParticipantResourceTestCase method testAfterCompletion.

@Test
public void testAfterCompletion() throws Exception {
    LoggingVolatileParticipant participant = new LoggingVolatileParticipant();
    registerParticipant(participantId, participant);
    Response response = afterCompletion(participantId, TxStatus.TransactionCommitted);
    Assert.assertEquals(200, response.getStatus());
    List<String> invocations = participant.getInvocations();
    Assert.assertEquals(1, invocations.size());
    Assert.assertEquals("afterCompletion", invocations.get(0));
    Assert.assertEquals(TxStatus.TransactionCommitted, participant.getTxStatus());
    response = beforeCompletion(participantId);
    Assert.assertEquals(404, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LoggingVolatileParticipant(org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant) Test(org.junit.Test)

Aggregations

LoggingVolatileParticipant (org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant)4 Test (org.junit.Test)4 Response (javax.ws.rs.core.Response)2 Prepared (org.jboss.narayana.rest.integration.api.Prepared)2 LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)2