use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class BasicIntegrationTestCase method testRollback.
@Test
public void testRollback() {
txSupport.startTx();
LoggingParticipant participant1 = new LoggingParticipant(new Prepared());
LoggingParticipant participant2 = new LoggingParticipant(new Prepared());
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant1);
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant2);
txSupport.rollbackTx();
Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participant1.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participant2.getInvocations());
}
use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class BasicIntegrationTestCase method testCommitWithVolatileParticipant.
@Test
public void testCommitWithVolatileParticipant() {
txSupport.startTx();
LoggingParticipant loggingParticipant = new LoggingParticipant(new Prepared());
LoggingVolatileParticipant loggingVolatileParticipant = new LoggingVolatileParticipant();
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), loggingParticipant);
ParticipantsManagerFactory.getInstance().enlistVolatileParticipant(txSupport.getVolatileParticipantEnlistmentURI(), loggingVolatileParticipant);
final String txStatus = TxSupport.getStatus(txSupport.commitTx());
Assert.assertEquals(TxStatus.TransactionCommitted.name(), txStatus);
Assert.assertEquals(Arrays.asList(new String[] { "commitOnePhase" }), loggingParticipant.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "beforeCompletion", "afterCompletion" }), loggingVolatileParticipant.getInvocations());
Assert.assertEquals(TxStatus.TransactionCommitted, loggingVolatileParticipant.getTxStatus());
}
use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class BasicIntegrationTestCase method testCommit.
@Test
public void testCommit() {
txSupport.startTx();
LoggingParticipant participant1 = new LoggingParticipant(new Prepared());
LoggingParticipant participant2 = new LoggingParticipant(new Prepared());
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant1);
ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant2);
txSupport.commitTx();
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participant1.getInvocations());
Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participant2.getInvocations());
}
use of org.jboss.narayana.rest.integration.api.Prepared in project narayana by jbosstm.
the class RecoveryIntegrationTestCase method testCrashBeforeCommit.
@Test
public void testCrashBeforeCommit() throws Exception {
startContainer(VM_ARGUMENTS + " " + BYTEMAN_ARGUMENTS.replace("@BMScript@", "CrashBeforeCommit"));
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;
do {
Thread.sleep(RECOVERY_PERIOD * 2000);
status = null;
try {
// Updates coordinator's active transactions list
txSupport.getTransactions();
// After successful recovery transaction is removed and 404 is returned.
status = txSupport.getTransactionInfo().getStatus();
} catch (HttpResponseException e) {
}
} while (status != null && cycles++ < RECOVERY_WAIT_CYCLES);
if (status != null) {
Assert.fail("Recovery failed unexpected status " + status);
}
}
use of org.jboss.narayana.rest.integration.api.Prepared 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);
}
Aggregations