use of org.mule.runtime.module.extension.api.runtime.privileged.ExecutionContextAdapter in project mule by mulesoft.
the class ExtensionConnectionSupplierTestCase method xaTransaction.
@Test
public void xaTransaction() throws Exception {
muleContext.setTransactionManager(mock(TransactionManager.class, RETURNS_DEEP_STUBS));
XaTransaction transaction = spy(new XaTransaction(muleContext));
XATransactionalConnection connection = mock(XATransactionalConnection.class, RETURNS_DEEP_STUBS);
Object config = new Object();
ExecutionContextAdapter operationContext = mock(ExecutionContextAdapter.class, RETURNS_DEEP_STUBS);
ConnectionProvider connectionProvider = mock(ConnectionProvider.class);
ConfigurationInstance configurationInstance = mock(ConfigurationInstance.class);
when(configurationInstance.getConnectionProvider()).thenReturn(of(connectionProvider));
when(operationContext.getConfiguration()).thenReturn(of(configurationInstance));
when(configurationInstance.getValue()).thenReturn(config);
when(connectionProvider.connect()).thenReturn(connection);
TransactionConfig transactionConfig = mock(TransactionConfig.class);
when(transactionConfig.getAction()).thenReturn(ACTION_ALWAYS_JOIN);
when(transactionConfig.isTransacted()).thenReturn(true);
when(operationContext.getTransactionConfig()).thenReturn(of(transactionConfig));
connectionManager.bind(config, connectionProvider);
TransactionCoordination.getInstance().bindTransaction(transaction);
adapter.getConnection(operationContext);
verify(transaction).bindResource(any(), any(XAExtensionTransactionalResource.class));
}
Aggregations