Search in sources :

Example 96 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class Client03 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        boolean correct = true;
        Control control = transactionFactory.create(4);
        Thread.sleep(8000);
        correct = correct && (control.get_coordinator().get_status() == Status.StatusRolledBack);
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
        // This test creates a transaction with timeout period of 4 seconds then
        // sleeps for 8 seconds.
        // When the timeout goes off at the transaction service, the transaction is
        // rolled back and destroyed.
        // The subsequent call to get-status on the transaction results in an
        // org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
        // The JTS specification appears to be quite vague in this area, however our
        // implementation is compliant with this vagueness.
        // Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
        // does not indicate a failure - BD 20/06/01
        System.out.println("Passed");
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client03.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client03.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory)

Example 97 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class Client07 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        int numberOfControls = Integer.parseInt(args[args.length - 1]);
        boolean correct = true;
        for (int index = 0; correct && (index < numberOfControls); index++) {
            Control control = transactionFactory.create(0);
            correct = correct && (control.get_coordinator().get_status() == Status.StatusActive);
            control.get_terminator().commit(true);
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client07.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client07.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory)

Example 98 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class Client09 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        int numberOfControls = Integer.parseInt(args[args.length - 1]);
        boolean correct = true;
        for (int index = 0; correct && (index < numberOfControls); index++) {
            Control control = transactionFactory.create(0);
            correct = correct && (control.get_coordinator().get_status() == Status.StatusActive);
            control.get_terminator().rollback();
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client09.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client09.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory)

Example 99 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class Client02 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        boolean correct = true;
        Control control = transactionFactory.create(0);
        correct = correct && (control.get_coordinator().get_status() == Status.StatusActive);
        control.get_terminator().rollback();
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client02.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client02.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) TransactionFactory(org.omg.CosTransactions.TransactionFactory)

Example 100 with Control

use of org.omg.CosTransactions.Control in project narayana by jbosstm.

the class Client04 method main.

public static void main(String[] args) {
    try {
        ORBInterface.initORB(args, null);
        OAInterface.initOA();
        TransactionFactory transactionFactory = null;
        String[] transactionFactoryParams = new String[1];
        transactionFactoryParams[0] = ORBServices.otsKind;
        transactionFactory = TransactionFactoryHelper.narrow(ORBServices.getService(ORBServices.transactionService, transactionFactoryParams));
        boolean correct;
        Control control = transactionFactory.create(4);
        Thread.sleep(8000);
        try {
            control.get_terminator().commit(true);
            correct = false;
        } catch (INVALID_TRANSACTION invalidTransaction) {
            correct = true;
        } catch (BAD_OPERATION badOperation) {
            correct = true;
        } catch (org.omg.CORBA.OBJECT_NOT_EXIST object_not_exist_exception) {
            // This test creates a transaction with timeout period of 4 seconds then
            // sleeps for 8 seconds.
            // When the timeout goes off at the transaction service, the transaction is
            // rolled back and destroyed.
            // The subsequent call to commit on the transaction results in an
            // org.omg.CORBA.OBJECT_NOT_EXIST exception being thrown.
            // The JTS specification appears to be quite vague in this area, however our
            // implementation is compliant with this vagueness.
            // Hence, For the purposes of this test, org.omg.CORBA.OBJECT_NOT_EXIST being thrown
            // does not indicate a failure - BD 20/06/01
            correct = true;
        } catch (Exception exception) {
            System.err.println("Client04.main: commit exception = " + exception);
            correct = false;
        }
        if (correct) {
            System.out.println("Passed");
        } else {
            System.out.println("Failed");
        }
    } catch (Exception exception) {
        System.out.println("Failed");
        System.err.println("Client04.main: " + exception);
        exception.printStackTrace(System.err);
    }
    try {
        OAInterface.shutdownOA();
        ORBInterface.shutdownORB();
    } catch (Exception exception) {
        System.err.println("Client04.main: " + exception);
        exception.printStackTrace(System.err);
    }
}
Also used : Control(org.omg.CosTransactions.Control) INVALID_TRANSACTION(org.omg.CORBA.INVALID_TRANSACTION) TransactionFactory(org.omg.CosTransactions.TransactionFactory) BAD_OPERATION(org.omg.CORBA.BAD_OPERATION)

Aggregations

Control (org.omg.CosTransactions.Control)103 Test (org.junit.Test)40 ControlImple (com.arjuna.ats.internal.jts.orbspecific.ControlImple)24 ArjunaTransactionImple (com.arjuna.ats.internal.jts.orbspecific.coordinator.ArjunaTransactionImple)20 ServerControl (com.arjuna.ats.internal.jts.orbspecific.interposition.ServerControl)20 ORB (com.arjuna.orbportability.ORB)20 RootOA (com.arjuna.orbportability.RootOA)18 TransactionFactory (org.omg.CosTransactions.TransactionFactory)16 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)14 INVALID_TRANSACTION (org.omg.CORBA.INVALID_TRANSACTION)13 Coordinator (org.omg.CosTransactions.Coordinator)13 SystemException (org.omg.CORBA.SystemException)11 IntHolder (org.omg.CORBA.IntHolder)10 Current (org.omg.CosTransactions.Current)9 ControlWrapper (com.arjuna.ats.internal.jts.ControlWrapper)6 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)6 Services (com.arjuna.orbportability.Services)6 PropagationContext (org.omg.CosTransactions.PropagationContext)6 ActionControl (com.arjuna.ArjunaOTS.ActionControl)5 ServerORB (com.hp.mwtests.ts.jts.utils.ServerORB)5