Package com.arjuna.mw.wst11

Examples of com.arjuna.mw.wst11.TransactionManager


    public static void testSuspendResumeCommitTransaction()
            throws Exception
    {
      UserTransaction ut = UserTransaction.getUserTransaction();
      TransactionManager tm = TransactionManager.getTransactionManager();

      ut.begin();

      TxContext ctx = tm.suspend();

      System.out.println("Suspended: "+ctx);

      tm.resume(ctx);

      System.out.println("\nResumed");

      ut.commit();
    }
View Full Code Here


            throws Exception
    {
        UserTransaction ut = UserTransaction.getUserTransaction();
  try
  {
      TransactionManager tm = TransactionManager.getTransactionManager();
      FailureParticipant p1 = new FailureParticipant(FailureParticipant.FAIL_IN_PREPARE, FailureParticipant.NONE);
      DemoDurableParticipant p2 = new DemoDurableParticipant();

      ut.begin();

      tm.enlistForDurableTwoPhase(p1, "failure");
      tm.enlistForDurableTwoPhase(p2, p2.identifier());
    catch (Exception eouter) {
        try {
            ut.rollback();
        } catch(Exception einner) {
        }
View Full Code Here

    public static void testSubTransactionCommitRollbackInPrepare()
            throws Exception
    {
        final UserTransaction ut = UserTransactionFactory.userTransaction();
        final UserTransaction ust = UserTransactionFactory.userSubordinateTransaction();
        final TransactionManager tm = TransactionManager.getTransactionManager();

        final DemoDurableParticipant p1 = new DemoDurableParticipant();
        final DemoVolatileParticipant p2 = new DemoVolatileParticipant();
        final FailureParticipant p3 = new FailureParticipant(FailureParticipant.FAIL_IN_PREPARE, FailureParticipant.NONE);
        final DemoVolatileParticipant p4 = new DemoVolatileParticipant();

        ut.begin();
        final TxContext tx = tm.suspend();
        tm.resume(tx);
        tm.enlistForDurableTwoPhase(p1, p1.identifier());
        tm.enlistForVolatileTwoPhase(p2, p2.identifier());
        ust.begin();
        final TxContext stx = tm.suspend();
        tm.resume(stx);
        tm.enlistForDurableTwoPhase(p3, "failure in prepare");
        tm.enlistForVolatileTwoPhase(p4, p4.identifier());

        tm.resume(tx);
        try {
        ut.commit();
            fail("expecting TransactionRolledBackException");
        } catch (TransactionRolledBackException trbe) {
            // expect this
View Full Code Here

    public static void testSuspendCommitTransaction()
            throws Exception
    {
        UserTransaction ut = UserTransaction.getUserTransaction();
      TransactionManager tm = TransactionManager.getTransactionManager();

      ut.begin();

    try {
      TxContext ctx = tm.suspend();

      System.out.println("Suspended: "+ctx);
    catch (Exception eouter) {
        try {
            ut.rollback();
View Full Code Here

    public static void testSubTransactionCommit()
            throws Exception
    {
        final UserTransaction ut = UserTransactionFactory.userTransaction();
        final UserTransaction ust = UserTransactionFactory.userSubordinateTransaction();
        final TransactionManager tm = TransactionManager.getTransactionManager();

        final DemoDurableParticipant p1 = new DemoDurableParticipant();
        final DemoVolatileParticipant p2 = new DemoVolatileParticipant();
        final DemoDurableParticipant p3 = new DemoDurableParticipant();
        final DemoVolatileParticipant p4 = new DemoVolatileParticipant();

        ut.begin();
        final TxContext tx = tm.suspend();
        tm.resume(tx);
        tm.enlistForDurableTwoPhase(p1, p1.identifier());
        tm.enlistForVolatileTwoPhase(p2, p2.identifier());
        ust.begin();
        final TxContext stx = tm.suspend();
        tm.resume(stx);
        tm.enlistForDurableTwoPhase(p3, p3.identifier());
        tm.enlistForVolatileTwoPhase(p4, p4.identifier());

        tm.resume(tx);
        ut.commit();
        assertTrue(p1.prepared() && p1.resolved() && p1.passed());
        assertTrue(p2.prepared() && p2.resolved() && p2.passed());
        assertTrue(p3.prepared() && p3.resolved() && p3.passed());
        assertTrue(p4.prepared() && p4.resolved() && p4.passed());
View Full Code Here

    @Test
    public void testSuccess() throws Exception {
        System.out
                .println("\n\nStarting 'testSuccess'. This test invokes a WS within a BA. The BA is later closed, which causes the WS call to complete successfully.");
        System.out.println("[CLIENT] Creating a new Business Activity");
        UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
        try {
            String value = "1";

            System.out
                    .println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)");
            uba.begin();

            System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
            client.addValueToSet(value);

            System.out.println("[CLIENT] Closing Business Activity (This will cause the BA to complete successfully)");
            uba.close();

            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value));
        } finally {
            cancelIfActive(uba);
            client.clear();
View Full Code Here

    @Test
    public void testCancel() throws Exception {
        System.out
                .println("\n\nStarting 'testCancel'. This test invokes a WS within a BA. The BA is later cancelled, which causes these WS call to be compensated.");
        System.out.println("[CLIENT] Creating a new Business Activity");
        UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
        try {
            String value = "1";

            System.out
                    .println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA will be included in this activity)");
            uba.begin();

            System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
            client.addValueToSet(value);

            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value));

            System.out.println("[CLIENT] Cancelling Business Activity (This will cause the work to be compensated)");
            uba.cancel();

            Assert.assertTrue("Expected value to not be in the set, but it was", !client.isInSet(value));

        } finally {
            cancelIfActive(uba);
View Full Code Here

    public void testSuccess() throws Exception {

        System.out
                .println("\n\nStarting 'testSuccess'. This test invokes a WS twice within a BA. The BA is later closes, which causes these WS calls to complete successfully.");
        System.out.println("[CLIENT] Creating a new Business Activity");
        UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
        try {
            String value1 = "1";
            String value2 = "2";

            System.out
                    .println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)");
            uba.begin();

            System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
            client.addValueToSet(value1);
            System.out.println("[CLIENT] invoking addValueToSet(2) on WS");
            client.addValueToSet(value2);

            System.out.println("[CLIENT] Closing Business Activity (This will cause the BA to complete successfully)");
            uba.close();

            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value1));
            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value2));

        } finally {
View Full Code Here

    public void testCancel() throws Exception {

        System.out
                .println("\n\nStarting 'testCancel'. This test invokes a WS twice within a BA. The BA is later cancelled, which causes these WS calls to be compensated.");
        System.out.println("[CLIENT] Creating a new Business Activity");
        UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
        try {
            String value1 = "1";
            String value2 = "2";

            System.out
                    .println("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA will be included in this activity)");
            uba.begin();

            System.out.println("[CLIENT] invoking addValueToSet(1) on WS");
            client.addValueToSet(value1);
            System.out.println("[CLIENT] invoking addValueToSet(2) on WS");
            client.addValueToSet(value2);

            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value1));
            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value2));

            System.out.println("[CLIENT] Cancelling Business Activity (This will cause the work to be compensated)");
            uba.cancel();

            Assert.assertTrue("Expected value to not be in the set, but it was", !client.isInSet(value1));
            Assert.assertTrue("Expected value to not be in the set, but it was", !client.isInSet(value2));

        } finally {
View Full Code Here

     * @throws Exception if something goes wrong.
     */
    @Test
    public void testSuccess() throws Exception {
        log.info("[CLIENT] Creating a new Business Activity");
        UserBusinessActivity uba = UserBusinessActivityFactory.userBusinessActivity();
        try {
            String value = "1";

            log.info("[CLIENT] Beginning Business Activity (All calls to Web services that support WS-BA wil be included in this activity)");
            uba.begin();

            log.info("[CLIENT] invoking addValueToSet(1) on WS");
            client.addValueToSet(value);

            log.info("[CLIENT] Closing Business Activity (This will cause the BA to complete successfully)");
            uba.close();

            Assert.assertTrue("Expected value to be in the set, but it wasn't", client.isInSet(value));
        } finally {
            cancelIfActive(uba);
        }
View Full Code Here

TOP

Related Classes of com.arjuna.mw.wst11.TransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.