Search in sources :

Example 16 with LoggingParticipant

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

the class ParticipantResourceTestCase method testGetTerminator.

@Test
@SuppressWarnings("rawtypes")
public void testGetTerminator() throws Exception {
    registerParticipant(participantId, new LoggingParticipant(new ReadOnly()));
    Response response = getParticipantTerminator(participantId);
    Assert.assertEquals(200, response.getStatus());
    Link link = response.getLink(TxLinkNames.TERMINATOR);
    Assert.assertNotNull(link);
    Assert.assertEquals(PARTICIPANT_URL + "/" + participantId, link.getUri().toString());
}
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) Link(javax.ws.rs.core.Link) Test(org.junit.Test)

Example 17 with LoggingParticipant

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

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

Example 19 with LoggingParticipant

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

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

the class BasicIntegrationTestCase method testReadOnly.

@Test
public void testReadOnly() {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new ReadOnly()), new LoggingParticipant(new Prepared()), new LoggingParticipant(new Prepared()) });
    for (LoggingParticipant p : participants) {
        ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    txSupport.commitTx();
    // One of the participants was only prepared, while other two were prepared and commited.
    Assert.assertEquals(5, participants.get(0).getInvocations().size() + participants.get(1).getInvocations().size() + participants.get(2).getInvocations().size());
    for (LoggingParticipant p : participants) {
        if (p.getInvocations().size() == 1) {
            Assert.assertEquals(Arrays.asList(new String[] { "prepare" }), p.getInvocations());
        } else {
            Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), p.getInvocations());
        }
    }
}
Also used : LoggingParticipant(org.jboss.narayana.rest.integration.test.common.LoggingParticipant) ReadOnly(org.jboss.narayana.rest.integration.api.ReadOnly) Prepared(org.jboss.narayana.rest.integration.api.Prepared) 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