Package javax.transaction

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


     * @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

     * @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

     * @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

     * @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

     * @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

    @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

     * @throws Exception if invocation fails
     */
    @SuppressWarnings("unused")
    @AroundInvoke
    protected Object intercept(final InvocationContext ic) throws Exception {
        UserTransaction utx;
        try{
            utx = ctx.getUserTransaction();
            utx.begin();
        }catch(Exception e){
            utx = null;
        }

        super.access00();

        if (utx != null){
            utx.commit();
        }
        return ic.proceed();
    }
View Full Code Here

    /**
     * Verifies the EntityManager reference.
     * @throws Exception if a problem occurs.
     */
    private void access() throws Exception {
        UserTransaction utx;

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

        super.access00();

        if (utx != null) {
            utx.commit();
        }
    }
View Full Code Here

     * Test Equals java:comp and java:module.
     * @throws NamingException if lookup fails
     */
    @Test(dependsOnMethods = "testCompEqualsModule")
    public void testCompModuleContent() throws NamingException {
        UserTransaction userTransactionComp = (UserTransaction) this.initialContext.lookup("java:comp/UserTransaction");
        UserTransaction userTransactionModule = (UserTransaction) this.initialContext.lookup("java:module/UserTransaction");

        Assert.assertEquals(userTransactionComp, userTransactionModule);
    }
View Full Code Here

TOP

Related Classes of javax.transaction.UserTransaction

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.