Search in sources :

Example 31 with Prepared

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");
    }
}
Also used : TransactionStatusElement(org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement) Prepared(org.jboss.narayana.rest.integration.api.Prepared) JSONArray(org.codehaus.jettison.json.JSONArray) HttpResponseException(org.jboss.jbossts.star.provider.HttpResponseException) Test(org.junit.Test)

Example 32 with Prepared

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());
}
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 33 with Prepared

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));
}
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 34 with Prepared

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());
}
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 35 with Prepared

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

Prepared (org.jboss.narayana.rest.integration.api.Prepared)36 Test (org.junit.Test)33 LoggingParticipant (org.jboss.narayana.rest.integration.test.common.LoggingParticipant)25 ParticipantInformation (org.jboss.narayana.rest.integration.ParticipantInformation)12 Response (javax.ws.rs.core.Response)10 LoggingParticipant (org.wildfly.test.extension.rts.common.LoggingParticipant)6 Aborted (org.jboss.narayana.rest.integration.api.Aborted)4 HeuristicParticipant (org.jboss.narayana.rest.integration.test.common.HeuristicParticipant)4 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)3 Vote (org.jboss.narayana.rest.integration.api.Vote)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 HttpResponseException (org.jboss.jbossts.star.provider.HttpResponseException)2 TransactionStatusElement (org.jboss.jbossts.star.util.media.txstatusext.TransactionStatusElement)2 LoggingVolatileParticipant (org.jboss.narayana.rest.integration.test.common.LoggingVolatileParticipant)2 JSONArray (org.codehaus.jettison.json.JSONArray)1 HeuristicException (org.jboss.narayana.rest.integration.api.HeuristicException)1 ParticipantException (org.jboss.narayana.rest.integration.api.ParticipantException)1 TestParticipantDeserializer (org.jboss.narayana.rest.integration.test.common.TestParticipantDeserializer)1