Search in sources :

Example 46 with MuleContext

use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.

the class XaTransactionFactoryTestCase method setsTransactionTimeout.

@Test
public void setsTransactionTimeout() throws Exception {
    final int timeout = 1000;
    final XaTransactionFactory transactionFactory = new XaTransactionFactory();
    transactionFactory.setTimeout(timeout);
    final MuleContext muleContext = mockContextWithServices();
    final TransactionManager transactionManager = mock(TransactionManager.class);
    when(muleContext.getTransactionManager()).thenReturn(transactionManager);
    final Transaction transaction = transactionFactory.beginTransaction(muleContext);
    assertThat(transaction.getTimeout(), equalTo(timeout));
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) Transaction(org.mule.runtime.core.api.transaction.Transaction) TransactionManager(javax.transaction.TransactionManager) XaTransactionFactory(org.mule.runtime.core.privileged.transaction.xa.XaTransactionFactory) Test(org.junit.Test)

Aggregations

MuleContext (org.mule.runtime.core.api.MuleContext)46 Test (org.junit.Test)17 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Before (org.junit.Before)8 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)8 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)8 MuleException (org.mule.runtime.api.exception.MuleException)7 LifecycleUtils.initialiseIfNeeded (org.mule.runtime.core.api.lifecycle.LifecycleUtils.initialiseIfNeeded)7 Map (java.util.Map)6 Optional (java.util.Optional)6 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)6 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)5 ConfigurationBuilder (org.mule.runtime.core.api.config.ConfigurationBuilder)5 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)5 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Optional.ofNullable (java.util.Optional.ofNullable)4 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)4