Search in sources :

Example 1 with ParticipantInformation

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

the class TransactionalService method getParticipantInvocations.

@GET
public Response getParticipantInvocations(@QueryParam("participantId") final String participantId) {
    ParticipantInformation information = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    if (information == null) {
        return Response.status(404).build();
    }
    final JSONArray jsonArray = new JSONArray(((LoggingParticipant) information.getParticipant()).getInvocations());
    return Response.ok().entity(jsonArray.toString()).build();
}
Also used : JSONArray(org.codehaus.jettison.json.JSONArray) ParticipantInformation(org.jboss.narayana.rest.integration.ParticipantInformation) GET(javax.ws.rs.GET)

Example 2 with ParticipantInformation

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

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

the class RecoveryManagerTestCase method testRecoveryWithoutDeserializer.

@Test
public void testRecoveryWithoutDeserializer() {
    final String participantId = new Uid().toString();
    final LoggingParticipant loggingParticipantBefore = new LoggingParticipant(new Prepared());
    loggingParticipantBefore.commit();
    final ParticipantInformation participantInformationBefore = new ParticipantInformation(participantId, APPLICATION_ID + "1", "", loggingParticipantBefore, TxStatus.TransactionCommitted.name());
    ParticipantsContainer.getInstance().clear();
    ParticipantsManagerFactory.getInstance().setBaseUrl("");
    RecoveryManager.getInstance().persistParticipantInformation(participantInformationBefore);
    RecoveryManager.getInstance().registerDeserializer(APPLICATION_ID + "2", new TestParticipantDeserializer());
    final ParticipantInformation participantInformationAfter = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Assert.assertNull(participantInformationAfter);
}
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) TestParticipantDeserializer(org.jboss.narayana.rest.integration.test.common.TestParticipantDeserializer) Test(org.junit.Test)

Example 4 with ParticipantInformation

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

the class ParticipantResourceTestCase method testPreparePreparedTransaction.

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

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

the class ParticipantResourceTestCase method testCommitOnePhaseAfterPrepare.

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

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