Search in sources :

Example 26 with LoggingParticipant

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

the class ParticipantResourceTestCase method testForgetHeuristic.

@Test
@SuppressWarnings("rawtypes")
public void testForgetHeuristic() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    participantInformation.setStatus(TxStatus.TransactionHeuristicRollback.name());
    Response simpleResponse = forgetParticipantHeuristic(participantId);
    Assert.assertEquals(200, simpleResponse.getStatus());
    Assert.assertNull(ParticipantsContainer.getInstance().getParticipantInformation(participantId));
}
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)

Example 27 with LoggingParticipant

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

the class ParticipantResourceTestCase method testCommitWithoutPrepare.

@Test
public void testCommitWithoutPrepare() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Response stringResponse = commitParticipant(participantInformation.getId());
    Assert.assertEquals(412, stringResponse.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)

Example 28 with LoggingParticipant

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

Example 29 with LoggingParticipant

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

the class ParticipantResourceTestCase method testRollback.

@Test
public void testRollback() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Response stringResponse = rollbackParticipant(participantInformation.getId());
    Assert.assertEquals(200, stringResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), participantInformation.getStatus());
    Assert.assertEquals(Arrays.asList(new String[] { "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) Prepared(org.jboss.narayana.rest.integration.api.Prepared) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) Test(org.junit.Test)

Example 30 with LoggingParticipant

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

the class ParticipantResourceTestCase method testCommit.

@Test
public void testCommit() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    participantInformation.setStatus(TxStatus.TransactionPrepared.name());
    Response stringResponse = commitParticipant(participantInformation.getId());
    Assert.assertEquals(200, stringResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionCommitted.name(), participantInformation.getStatus());
    Assert.assertEquals(Arrays.asList(new String[] { "commit" }), 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) 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