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());
}
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));
}
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());
}
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))));
}
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());
}
}
}
Aggregations