Search in sources :

Example 1 with LoggingParticipant

use of org.wildfly.test.extension.rts.common.LoggingParticipant in project wildfly by wildfly.

the class ParticipantTestCase 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());
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 2 with LoggingParticipant

use of org.wildfly.test.extension.rts.common.LoggingParticipant in project wildfly by wildfly.

the class ParticipantTestCase method testHeuristicRollbackBeforePrepare.

@Test
public void testHeuristicRollbackBeforePrepare() throws JAXBException {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new Prepared()), new LoggingParticipant(new Prepared()) });
    String lastParticipantid = null;
    for (LoggingParticipant p : participants) {
        lastParticipantid = ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    ParticipantsManagerFactory.getInstance().reportHeuristic(lastParticipantid, HeuristicType.HEURISTIC_ROLLBACK);
    final String transactionStatus = TxSupport.getStatus(txSupport.commitTx());
    Assert.assertEquals(TxStatus.TransactionRolledBack.name(), transactionStatus);
    if (participants.get(0).getInvocations().size() == 1) {
        Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), participants.get(0).getInvocations());
    } else {
        Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), participants.get(0).getInvocations());
    }
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 3 with LoggingParticipant

use of org.wildfly.test.extension.rts.common.LoggingParticipant in project wildfly by wildfly.

the class ParticipantTestCase method testHeuristicCommitBeforePrepare.

@Test
public void testHeuristicCommitBeforePrepare() throws JAXBException {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new Prepared()), new LoggingParticipant(new Prepared()) });
    String lastParticipantid = null;
    for (LoggingParticipant p : participants) {
        lastParticipantid = ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    ParticipantsManagerFactory.getInstance().reportHeuristic(lastParticipantid, HeuristicType.HEURISTIC_COMMIT);
    final String transactionStatus = TxSupport.getStatus(txSupport.commitTx());
    Assert.assertEquals(TxStatus.TransactionCommitted.name(), transactionStatus);
    Assert.assertEquals(Arrays.asList(new String[] { "prepare", "commit" }), participants.get(0).getInvocations());
    Assert.assertEquals(Collections.EMPTY_LIST, participants.get(1).getInvocations());
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 4 with LoggingParticipant

use of org.wildfly.test.extension.rts.common.LoggingParticipant in project wildfly by wildfly.

the class ParticipantTestCase 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());
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Example 5 with LoggingParticipant

use of org.wildfly.test.extension.rts.common.LoggingParticipant in project wildfly by wildfly.

the class ParticipantTestCase method testCommitOnePhase.

@Test
public void testCommitOnePhase() {
    txSupport.startTx();
    LoggingParticipant participant = new LoggingParticipant(new Prepared());
    ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), participant);
    txSupport.commitTx();
    Assert.assertEquals(Arrays.asList(new String[] { "commitOnePhase" }), participant.getInvocations());
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Prepared(org.jboss.narayana.rest.integration.api.Prepared) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 LoggingParticipant (org.wildfly.test.extension.rts.common.LoggingParticipant)7 Prepared (org.jboss.narayana.rest.integration.api.Prepared)6 Aborted (org.jboss.narayana.rest.integration.api.Aborted)1 ReadOnly (org.jboss.narayana.rest.integration.api.ReadOnly)1