Package org.mule.config.spring.parsers

Source Code of org.mule.config.spring.parsers.CustomTransactionManagerTestCase

/*
* 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.config.spring.parsers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.mule.tck.junit4.FunctionalTestCase;
import org.mule.tck.testmodels.mule.TestTransactionManagerFactory;

import java.lang.reflect.Proxy;
import java.util.Map;

import javax.transaction.TransactionManager;

import org.junit.Test;

public class CustomTransactionManagerTestCase extends FunctionalTestCase
{
    @Override
    public String getConfigFile()
    {
        return "test-custom-transaction-manager.xml";
    }

    @Test
    public void testCustomTransactionManager() throws Exception
    {
        TransactionManager transactionManager = muleContext.getTransactionManager();
        assertTrue(transactionManager instanceof Proxy);
        Proxy proxy = (Proxy) transactionManager;
        TestTransactionManagerFactory.InternalInvocationHandler ihandler =
                (TestTransactionManagerFactory.InternalInvocationHandler) Proxy.getInvocationHandler(proxy);
        TestTransactionManagerFactory factory = ihandler.getParent();
        Map<?, ?> properties = factory.getEnvironment();
        assertEquals(properties.size(), 2);
        assertEquals(properties.get("property1"), "true");
        assertEquals(properties.get("property2"), "Test");
    }


    /*
     * Attention: this test only runs successful when it's the only one. As soon
     * as the test above is added, muleContext contains more than one transaction
     * manager and all kinds of havoc happen here.

    @Test
    public void testWeblogicTransactionManager() throws Exception
    {
        TransactionManager transactionManager = muleContext.getTransactionManager();
        assertNotNull(transactionManager);
        transactionManager.begin();
        Transaction transaction = transactionManager.getTransaction();
        assertNotNull(transaction);
        transactionManager.rollback();
        assertNull(transactionManager.getTransaction());
    }
    */

TOP

Related Classes of org.mule.config.spring.parsers.CustomTransactionManagerTestCase

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.