Package org.mule.test.integration.spring.transaction

Source Code of org.mule.test.integration.spring.transaction.SpringTransactionFactoryTestCase

/*
* $Id: SpringTransactionFactoryTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
* --------------------------------------------------------------------------------------
* Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
*
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/

package org.mule.test.integration.spring.transaction;

import org.mule.api.transaction.Transaction;
import org.mule.tck.AbstractMuleTestCase;
import org.mule.transaction.TransactionCoordination;

public class SpringTransactionFactoryTestCase extends AbstractMuleTestCase
{

    @Override
    protected void doTearDown() throws Exception
    {
        Transaction tx = TransactionCoordination.getInstance().getTransaction();
        if (tx != null)
        {
            TransactionCoordination.getInstance().unbindTransaction(tx);
        }
    }

    public void testTransactionFactoryBinding() throws Exception
    {
        // Init a data source
//        DriverManagerDataSource ds = new DriverManagerDataSource();
//        ds.setDriverClassName("org.hsqldb.jdbcDriver");
//        ds.setUrl("jdbc:hsqldb:mem:db");
//        ds.setUsername("sa");
//        // Init hibernate
//        LocalSessionFactoryBean sfactory = new LocalSessionFactoryBean();
//        sfactory.setDataSource(ds);
//        sfactory.afterPropertiesSet();
//        // Init hibernate transaction manager
//        HibernateTransactionManager tm = new HibernateTransactionManager();
//        tm.setDataSource(ds);
//        SessionFactory sessionFactory = (SessionFactory)sfactory.getObject();
//        tm.setSessionFactory(sessionFactory);
//        // Init spring transaction factory
//        SpringTransactionFactory factory = new SpringTransactionFactory();
//        factory.setManager(tm);
//
//        // Create a new transaction
//        Transaction tx = factory.beginTransaction();
//        TransactionCoordination.getInstance().bindTransaction(tx);
//        // Check that the jdbc connection is enlisted
//        assertTrue(tx.hasResource(ds));
//        // Check that the hibernate session is enlisted
//        assertTrue(tx.hasResource(sessionFactory));

     //   TransactionCoordination.getInstance().unbindTransaction(tx);
    }

}
TOP

Related Classes of org.mule.test.integration.spring.transaction.SpringTransactionFactoryTestCase

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.