Examples of UserTransaction


Examples of javax.transaction.UserTransaction

     * Verifies if the transaction in the client side is active.
     * @return true if the transaction is active, false otherwise.
     * @throws Exception id a lookup error occurs
     */
    protected boolean transactionIsActive() throws Exception {
        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

     * @input -
     * @output an exception when the method verifies if the table exists.
     * @throws Exception if an error occurs during the tests.
     */
    public void testSetRollbackOnlyWithUserTransaction() throws Exception {
        UserTransaction utx = getUserTransaction();
        utx.begin();
        try {
            ItfContainerTransaction sfsbContainerTransaction = getBean();
            // calls the setRollbackOnly
            try {
                sfsbContainerTransaction.setRollbackOnly(DATABASE_1, DATABASE_2);
            } catch (TransactionException e) {
                throw e.getParentException();
            }
            // tries to commit the transaction
            try {
                utx.commit();
                fail("The transaction is marked as rollback. The client cannot make the commit.");
            } catch (Exception e) {
                logger.debug("Expected exception {0}", e);
            }
        } finally {
View Full Code Here

Examples of javax.transaction.UserTransaction

     * @input -
     * @output the method execution without error.
     * @throws Exception if an error occurs during the tests.
     */
    public void testGetRollbackOnlyWithUserTransaction() throws Exception {
        UserTransaction utx = getUserTransaction();

        utx.begin();
        testGetRollbackOnly();
        utx.commit();
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     * @see org.ow2.easybeans.tests.common.interfaces.ItfTestContainerManaged#testGetUserTransactionWithEJBContext()
     * @throws Exception if an error occurs during the tests.
     */
    @Override
    public void testGetUserTransactionWithEJBContext() throws Exception {
        UserTransaction utx = getUserTransaction();
        utx.begin();
        try {
            super.testGetUserTransactionWithEJBContext();
        } finally {
            utx.rollback();
        }
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     * @see org.ow2.easybeans.tests.common.interfaces.ItfTestContainerManaged#testGetUserTransactionWithLookup()
     * @throws Exception if an error occurs during the tests.
     */
    @Override
    public void testGetUserTransactionWithLookup() throws Exception {
        UserTransaction utx = getUserTransaction();
        utx.begin();
        try {
            super.testGetUserTransactionWithLookup();
        } finally {
            utx.rollback();
        }
    }
View Full Code Here

Examples of javax.transaction.UserTransaction

     * @input -
     * @output the method execution without error
     * @throws Exception if an error during the tests occurs.
     */
    public void testCallOtherBeanNotSupWithTrans() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();

        try {
            getRuntimeBean().insertTablesUsingAuxBeanNotSup(DATABASE_1, DATABASE_2);
            fail("The container did not throw the EJBTransactionRolledbackException.");
        } catch (EJBTransactionRolledbackException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the container discarded the instance.
        if (!ExceptionHandleUtil.isDiscarded(getRuntimeBean())) {
            fail("The bean was not discarded.");
        }

        // tries to commit the transaction
        try {
            utx.commit();
            fail("The transaction is marked as rollback. The client cannot make the commit.");
        } catch (Exception e) {
            logger.debug("Expected exception {0}", e);
        }

View Full Code Here

Examples of javax.transaction.UserTransaction

     * @input -
     * @output the method execution without error
     * @throws Exception if an error during the tests occurs.
     */
    public void testCallOtherBeanReqWithTrans() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            getRuntimeBean().insertTablesUsingAuxBeanReq(DATABASE_1, DATABASE_2);
            fail("The container did not throw the EJBTransactionRolledbackException.");
        } catch (EJBTransactionRolledbackException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the container discarded the instance.
        if (!ExceptionHandleUtil.isDiscarded(getRuntimeBean())) {
            fail("The bean was not discarded.");
        }
        // tries to commit the transaction
        try {
            utx.commit();
            fail("The transaction is marked as rollback. The client cannot make the commit.");
        } catch (Exception e) {
            logger.debug("Expected exception {0}", e);
        }

View Full Code Here

Examples of javax.transaction.UserTransaction

     * @output the execution without errors.
     * @throws Exception if an error during the tests occurs.
     */
    @Override
    public void testCallOtherBeanNotSup() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            getRuntimeBean().insertTablesUsingAuxBeanNotSup(DATABASE_1, DATABASE_2);
            fail("The container did not throw the EJBTransactionRolledbackException.");
        } catch (EJBTransactionRolledbackException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the container discarded the instance.
        if (!ExceptionHandleUtil.isDiscarded(getRuntimeBean())) {
            fail("The bean was not discarded.");
        }

        // TODO - verifies if the container log the error.

        // tries to commit the transaction
        try {
            utx.commit();
            fail("The transaction is marked as rollback. The client cannot make the commit.");
        } catch (Exception e) {
            logger.debug("Expected exception {0}", e);
        }

View Full Code Here

Examples of javax.transaction.UserTransaction

     * @output the method execution without fails
     * @throws Exception if an error during the tests occurs.
     */
    @Override
    public void testCallOtherBeanReq() throws Exception {
        UserTransaction utx = ExceptionHandleUtil.getUserTransaction();
        utx.begin();
        try {
            getRuntimeBean().insertTablesUsingAuxBeanReq(DATABASE_1, DATABASE_2);
            fail("The container did not throw the EJBException.");
        } catch (EJBTransactionRolledbackException e) {
            logger.debug("The bean threw an expected error during the execution {0}", e);
        }
        // verifies if the container discarded the instance.
        if (!ExceptionHandleUtil.isDiscarded(getRuntimeBean())) {
            fail("The bean was not discarded.");
        }
        // tries to commit the transaction
        try {
            utx.commit();
            fail("The transaction is marked as rollback. The client cannot make the commit.");
        } catch (Exception e) {
            logger.debug("Expected exception {0}", e);
        }
        // verifies if the transaction in the bean was rolled back.
View Full Code Here

Examples of javax.transaction.UserTransaction

    @Test
    public void testUsingClientTransaction() throws Exception {
        // calls a method that starts a transaction
        sfsbBeanManagedTransaction.insertTableWithoutCommitTransaction();
        // gets the transaction
        UserTransaction utx = TransactionHelper.getInternalUserTransaction();
        // starts the transaction
        utx.begin();
        // makes a rollback in the bean transaction, the container
        // must to resume the user transaction and execute the
        // bean transaction in other transaction
        sfsbBeanManagedTransaction.setRollback();
        // tries to commit the transaction to avoid a nested transaction
        try {
            utx.commit();
        } catch (Exception e) {
            logger.debug("Error when the transaction made a rollback {0}", e);
        }
        Integer[] expected = {new Integer(Status.STATUS_COMMITTED), new Integer(Status.STATUS_NO_TRANSACTION) };

        // the user transaction must be active yet.
        Assert.assertEquals(new Integer(utx.getStatus()), expected,
                "After the commit the transaction must be commited or not_transaction");

    }
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.