Search in sources :

Example 11 with ParticipantInformation

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

the class ParticipantResourceTestCase method testGetStatus.

@Test
public void testGetStatus() throws Exception {
    registerParticipant(participantId, new LoggingParticipant(new ReadOnly()));
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    participantInformation.setStatus(TxStatus.TransactionPrepared.name());
    Response response = getParticipantStatus(participantId);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertTrue(TxStatus.isPrepare(TxSupport.getStatus(response.readEntity(String.class))));
    participantInformation.setStatus(TxStatus.TransactionCommitted.name());
    response = ClientBuilder.newClient().target(PARTICIPANT_URL + "/" + participantId).request().get();
    Assert.assertTrue(TxStatus.isCommit(TxSupport.getStatus(response.readEntity(String.class))));
}
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 12 with ParticipantInformation

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

the class ParticipantsManagerTestCase 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 13 with ParticipantInformation

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

the class ParticipantResourceTestCase method testForgetHeuristicWithoutHeuristic.

@Test
@SuppressWarnings("rawtypes")
public void testForgetHeuristicWithoutHeuristic() throws Exception {
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    registerParticipant(participantId, participant);
    Response simpleResponse = forgetParticipantHeuristic(participantId);
    ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
    Assert.assertEquals(412, simpleResponse.getStatus());
    Assert.assertEquals(TxStatus.TransactionActive.name(), participantInformation.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 14 with ParticipantInformation

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

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

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