Examples of UserTransaction


Examples of javax.transaction.UserTransaction

     * @throws NamingException if a problem to get the transaction occurs.
     * @throws NotSupportedException if the bean is already associated with a transaction.
     * @throws SystemException if an unexpected error occurs during the transaction.
     */
    public void openTransaction() throws NamingException, NotSupportedException, SystemException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

    /**
     * Makes a rollback in the transaction that is active.
     * @throws Exception if an error occurs during the rollback.
     */
    public static void cleanTransaction() throws Exception {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        try {
            if (transactionIsActive()) {
                utx.rollback();
            }
        } catch (Exception e) {
            throw new Exception("Cannot clean the transaction. The test cannot be started", e);
        }
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     *         relevant update was commited and others rolled back.
     * @throws TransactionException if a rollback was made.
     */
    public void verifyBMT() throws IllegalStateException, SecurityException, HeuristicMixedException,
            HeuristicRollbackException, RollbackException, SystemException, NotSupportedException, NamingException {
        UserTransaction utx = TransactionHelper.getUserTransaction();
        utx.begin();
        utx.commit();
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     * @return true if the transaction is active, false otherwise.
     * @throws SystemException if a transaction exception occurs.
     * @throws NamingException if a lookup error occurs.
     */
    public static boolean transactionIsActive() throws SystemException, NamingException {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        boolean bolResult = false;
        if (utx != null) {
            if (utx.getStatus() == Status.STATUS_ACTIVE) {
                bolResult = true;
            }
        }
        return bolResult;
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     * Gets a new transaction.
     * @throws NamingException if a lookup error occurs.
     * @return the class UserTransaction.
     */
    public static UserTransaction getUserTransaction() throws NamingException {
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        return utx;
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

            cTest.test("tmpTable" + cTest.hashCode());

        } else if (ic.getMethod().toString().contains("accessEntityManager")) {

            //EntityManager Access
            UserTransaction utx;
            try{
                utx = ctx.getUserTransaction();
                utx.begin();
            }catch(Exception e){
                utx = null;
            }

            checkInstance(eManager, EntityManagerTester.NAME);

            if (utx != null){
                utx.commit();
            }


        } else if (ic.getMethod().toString().contains("accessEntityManagerFactory")) {
View Full Code Here

Examples of javax.transaction.UserTransaction

     *        Never). False if the container must mark the transaction for
     *        rollback(transaction attribute:Required, Mandatory and Supports).
     * @throws Exception if an error during the tests occurs.
     */
    public void testUsingClientTransWithAppRollbackException(final boolean canCommit) throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            sfsbContainerTransactionRollback.insertCorrectFirstErrorSecond(DATABASE_1, DATABASE_2);
            fail("The container did not re-throw the application exception.");
        } catch (RollbackApplicationException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // tries to commit
        try {
            utx.commit();
            if (!canCommit) {
                fail("The transaction was marked as rolled back, the client cannot make the commit.");
            }
        } catch (Exception e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
View Full Code Here

Examples of javax.transaction.UserTransaction

     * extends Exception(with rollback = false) and does not do the rollback in
     * this case.This test uses a client transaction.
     * @throws Exception if an error during the tests occurs.
     */
    public void testUsingClientTransWithAppException() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            sfsbContainerTransactionApp.insertCorrectFirstErrorSecond(DATABASE_1, DATABASE_2);
            fail("The container did not re-throw the application exception.");
        } catch (AppException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // tries to commit
        try {
            utx.commit();
        } catch (Exception e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the table was created in the DATABASE_1
        ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE);
View Full Code Here

Examples of javax.transaction.UserTransaction

     *        transaction. The client is able to commit when the bean does not
     *        use the client transaction.
     * @throws Exception if an error during the tests occurs.
     */
    public void testUsingClientTransWithAppRuntimeRollbackException(final boolean canCommit) throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            sfsbContainerTransactionApp02.insertCorrectFirstErrorSecond(DATABASE_1, DATABASE_2);
            fail("The container did not re-throw the application exception.");
        } catch (RollbackAppRuntimeException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // tries to commit
        try {
            utx.commit();
            if (!canCommit) {
                fail("The transaction was marked as rolled back, the client cannot make the commit.");
            }
        } catch (Exception e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
View Full Code Here

Examples of javax.transaction.UserTransaction

     * extends a runtime exception (with rollback = false) and does not do the
     * rollback in this case. The test uses a client transaction.
     * @throws Exception if an error during the tests occurs.
     */
    public void testUsingClientTransWithAppRuntimeException() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            sfsbContainerTransactionApp01.insertCorrectFirstErrorSecond(DATABASE_1, DATABASE_2);
            fail("The container did not re-throw the application exception.");
        } catch (AppRuntimeException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // tries to commit
        try {
            utx.commit();
        } catch (Exception e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the table was created in the DATABASE_1
        ExceptionHandleUtil.verifyTable(DATABASE_1, ItfContainerTransaction.TABLE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.