Search in sources :

Example 6 with LoggingParticipant

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

the class ParticipantTestCase method testRollbackByParticipant.

@Test
public void testRollbackByParticipant() {
    txSupport.startTx();
    final List<LoggingParticipant> participants = Arrays.asList(new LoggingParticipant[] { new LoggingParticipant(new Aborted()), new LoggingParticipant(new Aborted()) });
    for (LoggingParticipant p : participants) {
        ParticipantsManagerFactory.getInstance().enlist(APPLICATION_ID, txSupport.getDurableParticipantEnlistmentURI(), p);
    }
    txSupport.commitTx();
    // One of the participants was prepared and then decided to rollback, the other was rolledback straight away.
    Assert.assertEquals(3, participants.get(0).getInvocations().size() + participants.get(1).getInvocations().size());
    for (LoggingParticipant p : participants) {
        if (p.getInvocations().size() == 1) {
            Assert.assertEquals(Arrays.asList(new String[] { "rollback" }), p.getInvocations());
        } else {
            Assert.assertEquals(Arrays.asList(new String[] { "prepare", "rollback" }), p.getInvocations());
        }
    }
}
Also used : LoggingParticipant(org.wildfly.test.extension.rts.common.LoggingParticipant) Aborted(org.jboss.narayana.rest.integration.api.Aborted) Test(org.junit.Test)

Example 7 with LoggingParticipant

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

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