use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class RecoveryIntegrationTestCase method testCrashAfterPrepare.
@Test
public void testCrashAfterPrepare() throws Exception {
startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashAfterPrepare"));
txSupport.startTx();
enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
enlistParticipant(txSupport.getDurableParticipantEnlistmentURI(), new Prepared());
Assert.assertEquals(2, txSupport.getTransactionInfo().getTwoPhaseAware().size());
try {
// JVM is killed here.
txSupport.commitTx();
} catch (HttpResponseException e) {
}
restartContainer(VM_ARGUMENTS);
registerDeserializer();
TransactionStatusElement status;
int cycles = 0;
JSONArray partricipantsInformation;
do {
Thread.sleep(RECOVERY_PERIOD * 2000);
partricipantsInformation = getParticipantsInformation();
} while (cycles++ < RECOVERY_WAIT_CYCLES && partricipantsInformation.length() > 0);
if (partricipantsInformation.length() > 0) {
Assert.fail("Recovery failed");
}
}
use of org.jboss.narayana.rest.integration.api.Prepared 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());
}
use of org.jboss.narayana.rest.integration.api.Prepared 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));
}
use of org.jboss.narayana.rest.integration.api.Prepared 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());
}
use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class ParticipantResourceTestCase method testRollback.
@Test
public void testRollback() throws Exception {
LoggingParticipant participant = new LoggingParticipant(new Prepared());
registerParticipant(participantId, participant);
ParticipantInformation participantInformation = ParticipantsContainer.getInstance().getParticipantInformation(participantId);
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));
}
Aggregations