Search in sources :

Example 1 with SagasParticipant

use of com.arjuna.wscf.tests.SagasParticipant in project narayana by jbosstm.

the class AddParticipantTest method testAddParticipant.

@Test
public void testAddParticipant() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        cm.begin("Sagas11HLS");
        cm.enlistParticipant(new SagasParticipant(null));
        System.out.println("Started: " + cm.identifier() + "\n");
        cm.complete();
        cm.close();
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : SagasParticipant(com.arjuna.wscf.tests.SagasParticipant) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Example 2 with SagasParticipant

use of com.arjuna.wscf.tests.SagasParticipant in project narayana by jbosstm.

the class ParticipantExitedCloseTest method testParticipantExitedClose.

@Test
public void testParticipantExitedClose() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        String id = "1235";
        cm.begin("Sagas11HLS");
        SagasParticipant participant = new SagasParticipant(id);
        cm.enlistParticipant(participant);
        cm.delistParticipant(id);
        System.out.println("Started: " + cm.identifier() + "\n");
        cm.close();
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : SagasParticipant(com.arjuna.wscf.tests.SagasParticipant) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Example 3 with SagasParticipant

use of com.arjuna.wscf.tests.SagasParticipant in project narayana by jbosstm.

the class ParticipantCannotCompleteCloseTest method testParticipantCannotCompleteClose.

@Test
public void testParticipantCannotCompleteClose() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        String id = "1234";
        cm.begin("Sagas11HLS");
        SagasParticipant participant = new SagasParticipant(id);
        cm.enlistParticipant(participant);
        cm.participantCannotComplete(id);
        System.out.println("Started: " + cm.identifier() + "\n");
        cm.close();
        fail("Close succeeded after participantFaulted");
    } catch (CoordinatorCancelledException ex) {
        WSCF11TestUtils.cleanup(cm);
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : CoordinatorCancelledException(com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException) SagasParticipant(com.arjuna.wscf.tests.SagasParticipant) CoordinatorCancelledException(com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Example 4 with SagasParticipant

use of com.arjuna.wscf.tests.SagasParticipant in project narayana by jbosstm.

the class ParticipantFaultedCloseTest method testParticipantFaultedClose.

@Test
public void testParticipantFaultedClose() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        String id = "1236";
        cm.begin("Sagas11HLS");
        SagasParticipant participant = new SagasParticipant(id);
        cm.enlistParticipant(participant);
        cm.participantFaulted(id);
        System.out.println("Started: " + cm.identifier() + "\n");
        cm.close();
        fail("Close succeeded after participantFaulted");
    } catch (CoordinatorCancelledException ex) {
        WSCF11TestUtils.cleanup(cm);
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : CoordinatorCancelledException(com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException) SagasParticipant(com.arjuna.wscf.tests.SagasParticipant) CoordinatorCancelledException(com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Example 5 with SagasParticipant

use of com.arjuna.wscf.tests.SagasParticipant in project narayana by jbosstm.

the class SuspendResumeMultiParticipantTest method testSuspendResumeMultiParticipant.

@Test
public void testSuspendResumeMultiParticipant() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    CoordinatorManager cm = CoordinatorManagerFactory.coordinatorManager();
    try {
        cm.begin("Sagas11HLS");
        cm.enlistParticipant(new SagasParticipant("p1"));
        cm.enlistParticipant(new SagasParticipant("p2"));
        System.out.println("Started: " + cm.identifier() + "\n");
        ActivityHierarchy hier = cm.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (cm.currentActivity() != null) {
            WSCF11TestUtils.cleanup(cm);
            fail("Hierarchy still active.");
        }
        cm.resume(hier);
        System.out.println("Resumed: " + hier + "\n");
        cm.close();
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(cm);
        throw ex;
    }
}
Also used : SagasParticipant(com.arjuna.wscf.tests.SagasParticipant) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Aggregations

CoordinatorManager (com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager)5 SagasParticipant (com.arjuna.wscf.tests.SagasParticipant)5 Test (org.junit.Test)5 CoordinatorCancelledException (com.arjuna.mw.wscf.model.sagas.exceptions.CoordinatorCancelledException)2 ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)1