Search in sources :

Example 16 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class HierarchyTest method testComparision.

@Test
public void testComparision() throws Exception {
    CoordinatorManager cm1 = CoordinatorManagerFactory.coordinatorManager();
    CoordinatorManager cm2 = CoordinatorManagerFactory.coordinatorManager();
    cm1.begin("Sagas11HLS");
    ActivityHierarchy hierarchy1 = cm1.suspend();
    cm2.begin("Sagas11HLS");
    ActivityHierarchy hierarchy2 = cm2.suspend();
    try {
        Assert.assertFalse(hierarchy1.equals(hierarchy2));
    } finally {
        cm1.resume(hierarchy1);
        cm1.close();
        cm2.resume(hierarchy2);
        cm2.close();
    }
}
Also used : ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) CoordinatorManager(com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager) Test(org.junit.Test)

Example 17 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class HierarchyTest method testHierarchy.

@Test
public void testHierarchy() throws Exception {
    UserActivity ua = UserActivityFactory.userActivity();
    try {
        ua.start("dummy");
        System.out.println("Started: " + ua.activityName());
        ua.start("dummy");
        System.out.println("Started: " + ua.activityName());
        ActivityHierarchy ctx = ua.currentActivity();
        System.out.println("\nHierarchy: " + ctx);
        if (ctx == null) {
            fail("current activity should not be null");
        } else {
            ua.end();
            System.out.println("\nCurrent: " + ua.activityName());
            ua.end();
            try {
                if (ua.activityName() != null) {
                    fail("activity name should be null but is " + ua.activityName());
                }
            } catch (NoActivityException ex) {
            // ok if we get here
            }
        }
    } catch (Exception ex) {
        WSASTestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserActivity(com.arjuna.mw.wsas.UserActivity) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) NoActivityException(com.arjuna.mw.wsas.exceptions.NoActivityException) Test(org.junit.Test)

Example 18 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy 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)

Example 19 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class SuspendResumeTest method testSuspendResume.

@Test
public void testSuspendResume() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    UserCoordinator ua = UserCoordinatorFactory.userCoordinator();
    try {
        ua.begin("Sagas11HLS");
        System.out.println("Started: " + ua.identifier() + "\n");
        ActivityHierarchy hier = ua.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (ua.currentActivity() != null) {
            WSCF11TestUtils.cleanup(ua);
            fail("Hierarchy still active");
        } else {
            ua.resume(hier);
            System.out.println("Resumed: " + hier + "\n");
            ua.cancel();
            System.out.println("Cancelled");
        }
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserCoordinator(com.arjuna.mw.wscf.model.sagas.api.UserCoordinator) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) Test(org.junit.Test)

Example 20 with ActivityHierarchy

use of com.arjuna.mw.wsas.activity.ActivityHierarchy in project narayana by jbosstm.

the class SuspendTest method testSuspend.

@Test
public void testSuspend() throws Exception {
    System.out.println("Running test : " + this.getClass().getName());
    UserCoordinator ua = UserCoordinatorFactory.userCoordinator();
    try {
        ua.begin("TwoPhase11HLS");
        System.out.println("Started: " + ua.identifier() + "\n");
        ActivityHierarchy hier = ua.suspend();
        System.out.println("Suspended: " + hier + "\n");
        if (ua.currentActivity() != null) {
            WSCF11TestUtils.cleanup(ua);
            fail("Hierarchy still active.");
        }
    } catch (NoCoordinatorException ex) {
    // why is it ok to get here?
    } catch (Exception ex) {
        WSCF11TestUtils.cleanup(ua);
        throw ex;
    }
}
Also used : UserCoordinator(com.arjuna.mw.wscf.model.twophase.api.UserCoordinator) NoCoordinatorException(com.arjuna.mw.wscf.exceptions.NoCoordinatorException) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) NoCoordinatorException(com.arjuna.mw.wscf.exceptions.NoCoordinatorException) Test(org.junit.Test)

Aggregations

ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)20 Test (org.junit.Test)12 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)6 NoCoordinatorException (com.arjuna.mw.wscf.exceptions.NoCoordinatorException)4 UserActivity (com.arjuna.mw.wsas.UserActivity)3 NoActivityException (com.arjuna.mw.wsas.exceptions.NoActivityException)3 UserCoordinator (com.arjuna.mw.wscf.model.sagas.api.UserCoordinator)3 UserCoordinator (com.arjuna.mw.wscf.model.twophase.api.UserCoordinator)3 Uid (com.arjuna.ats.arjuna.common.Uid)2 ActionHierarchy (com.arjuna.ats.arjuna.coordinator.ActionHierarchy)2 ProtocolViolationException (com.arjuna.mw.wsas.exceptions.ProtocolViolationException)2 WrongStateException (com.arjuna.mw.wsas.exceptions.WrongStateException)2 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)2 CoordinatorManager (com.arjuna.mw.wscf.model.sagas.api.CoordinatorManager)2 ActivityHandleImple (com.arjuna.mwlabs.wsas.activity.ActivityHandleImple)2 SubordinateBACoordinator (com.arjuna.mwlabs.wscf.model.sagas.arjunacore.subordinate.SubordinateBACoordinator)2 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)2 GlobalId (com.arjuna.mw.wsas.common.GlobalId)1 DuplicateParticipantException (com.arjuna.mw.wscf.exceptions.DuplicateParticipantException)1 CoordinatorManager (com.arjuna.mw.wscf.model.twophase.api.CoordinatorManager)1