Search in sources :

Example 6 with ParticipantInformation

use of org.jboss.narayana.rest.integration.ParticipantInformation in project narayana by jbosstm.

the class ParticipantResourceTestCase method testRollbackAfterPrepare.

@Test
public void testRollbackAfterPrepare() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    participantInformation.setStatus(TxStatus.TransactionPrepared.name());
    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 7 with ParticipantInformation

use of org.jboss.narayana.rest.integration.ParticipantInformation in project narayana by jbosstm.

the class ParticipantResourceTestCase method testCommitOnePhase.

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

use of org.jboss.narayana.rest.integration.ParticipantInformation in project narayana by jbosstm.

the class ParticipantResourceTestCase method registerParticipant.

private void registerParticipant(final String participantId, final Participant participant) throws MalformedURLException {
    ParticipantInformation participantInformation = new ParticipantInformation(participantId, APPLICATION_ID, "", participant);
    participantInformation.setStatus(TxStatus.TransactionActive.name());
    ParticipantsContainer.getInstance().addParticipantInformation(participantId, participantInformation);
}
Also used : ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation)

Example 9 with ParticipantInformation

use of org.jboss.narayana.rest.integration.ParticipantInformation in project narayana by jbosstm.

the class ParticipantResourceTestCase method testPrepareOutcomeReadOnly.

@Test
public void testPrepareOutcomeReadOnly() throws Exception {
    final LoggingParticipant participant = new LoggingParticipant(new ReadOnly());
    registerParticipant(participantId, participant);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Response stringResponse = prepareParticipant(participantId);
    Assert.assertEquals(200, stringResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionReadOnly.name(), TxSupport.getStatus(stringResponse.readEntity(String.class)));
    Assert.assertEquals(TxStatus.TransactionReadOnly.name(), participantInformation.getStatus());
    Assert.assertEquals(Arrays.asList(new String[] { "prepare" }), participant.getInvocations());
    Assert.assertNull(ParticipantsContainer.getInstance().getParticipantInformation(participantId));
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) ReadOnly(org.jboss.narayana.rest.integration.api.ReadOnly) Response(javax.ws.rs.core.Response) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) Test(org.junit.Test)

Example 10 with ParticipantInformation

use of org.jboss.narayana.rest.integration.ParticipantInformation in project narayana by jbosstm.

the class ParticipantResourceTestCase method testPrepareOutcomePrepared.

@Test
public void testPrepareOutcomePrepared() throws Exception {
    final LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    Response stringResponse = prepareParticipant(participantId);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Assert.assertEquals(200, stringResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionPrepared.name(), TxSupport.getStatus(stringResponse.readEntity(String.class)));
    Assert.assertEquals(TxStatus.TransactionPrepared.name(), participantInformation.getStatus());
    Assert.assertEquals(Arrays.asList(new String[] { "prepare" }), participant.getInvocations());
}
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

ParticipantInformation (org.jboss.narayana.rest.integration.ParticipantInformation)18 LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)15 Test (org.junit.Test)15 Response (javax.ws.rs.core.Response)13 Prepared (org.jboss.narayana.rest.integration.api.Prepared)12 Uid (com.arjuna.ats.arjuna.common.Uid)2 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)2 GET (javax.ws.rs.GET)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 Aborted (org.jboss.narayana.rest.integration.api.Aborted)1 TestParticipantDeserializer (org.jboss.narayana.rest.integration.test.common.TestParticipantDeserializer)1