Search in sources :

Example 1 with MuleConfiguration

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

the class DefaultFlowBuilderTestCase method setUp.

@Before
public void setUp() throws Exception {
    MuleConfiguration muleConfiguration = mock(MuleConfiguration.class);
    when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
    when(muleConfiguration.getDefaultProcessingStrategyFactory()).thenReturn(defaultProcessingStrategyFactory);
    when(defaultProcessingStrategyFactory.create(any(), any())).thenReturn(processingStrategy);
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) Before(org.junit.Before)

Example 2 with MuleConfiguration

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

the class DefaultExpressionManagerTestCase method doNotRegistersMelWhenCompatibilityPluginIsNotInstalled.

@Test
public void doNotRegistersMelWhenCompatibilityPluginIsNotInstalled() throws Exception {
    Registry registry = mock(Registry.class);
    when(registry.lookupByType(DefaultExpressionLanguageFactoryService.class)).thenReturn(of(mock(DefaultExpressionLanguageFactoryService.class, RETURNS_DEEP_STUBS)));
    when(registry.lookupByName(COMPATIBILITY_PLUGIN_INSTALLED)).thenReturn(empty());
    final MuleContextWithRegistries mockMuleContext = MuleContextUtils.mockMuleContext();
    MuleConfiguration config = mockMuleContext.getConfiguration();
    doReturn(true).when(config).isValidateExpressions();
    expressionManager = new DefaultExpressionManager();
    ((DefaultExpressionManager) expressionManager).setRegistry(registry);
    ((DefaultExpressionManager) expressionManager).setMuleContext(mockMuleContext);
    initialiseIfNeeded(expressionManager, false, mockMuleContext);
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("There is no expression language registered for 'mel'");
    expressionManager.isValid("mel:'Hello'");
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) Registry(org.mule.runtime.api.artifact.Registry) Test(org.junit.Test)

Example 3 with MuleConfiguration

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

the class FlowProcessingStrategyTestCase method processingStrategySetBySystemPropertyOverridesDefault.

@Test
public void processingStrategySetBySystemPropertyOverridesDefault() throws Exception {
    testWithSystemProperty(ProcessingStrategyFactory.class.getName(), TestProcessingStrategyFactory.class.getName(), () -> {
        MuleConfiguration muleConfiguration = new DefaultMuleConfiguration();
        when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
        createFlow(null);
        assertEquals(flow.getProcessingStrategy().getClass(), TestProcessingStrategy.class);
    });
}
Also used : DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) ProcessingStrategyFactory(org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 4 with MuleConfiguration

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

the class DefaultMessageProcessorChainTestCase method before.

@Before
public void before() throws MuleException {
    nonBlockingProcessorsExecuted.set(0);
    muleContext = spy(super.muleContext);
    ErrorTypeLocator errorTypeLocator = mock(ErrorTypeLocator.class);
    ErrorType errorType = mock(ErrorType.class);
    ExceptionContextProvider exceptionContextProvider = mock(ExceptionContextProvider.class);
    MuleConfiguration muleConfiguration = mock(MuleConfiguration.class);
    when(muleConfiguration.isContainerMode()).thenReturn(false);
    when(muleConfiguration.getId()).thenReturn(randomNumeric(3));
    when(muleConfiguration.getShutdownTimeout()).thenReturn(1000L);
    when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
    when(((PrivilegedMuleContext) muleContext).getErrorTypeLocator()).thenReturn(errorTypeLocator);
    when(muleContext.getExceptionContextProviders()).thenReturn(singletonList(exceptionContextProvider));
    when(errorTypeLocator.lookupErrorType((Exception) any())).thenReturn(errorType);
    flow = builder("flow", muleContext).processingStrategyFactory(processingStrategyFactory).build();
    flow.initialise();
    flow.start();
}
Also used : ExceptionContextProvider(org.mule.runtime.core.api.execution.ExceptionContextProvider) MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) ErrorType(org.mule.runtime.api.message.ErrorType) ErrorTypeLocator(org.mule.runtime.core.privileged.exception.ErrorTypeLocator) PrivilegedMuleContext(org.mule.runtime.core.privileged.PrivilegedMuleContext) Before(org.junit.Before)

Example 5 with MuleConfiguration

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

the class MuleObjectStoreManagerTestCase method setup.

@Before
public void setup() {
    schedulerService = new SimpleUnitTestSupportSchedulerService();
    muleContext = mock(MuleContextWithRegistries.class);
    MuleConfiguration muleConfiguration = mock(MuleConfiguration.class);
    when(muleConfiguration.getWorkingDirectory()).thenReturn(tempWorkDir.getRoot().getAbsolutePath());
    when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
    Registry registry = mock(Registry.class);
    createRegistryAndBaseStore(muleContext, registry);
    when(muleContext.getSchedulerBaseConfig()).thenReturn(config().withPrefix(MuleObjectStoreManagerTestCase.class.getName() + "#" + name.getMethodName()));
    storeManager = new MuleObjectStoreManager();
    storeManager.setSchedulerService(schedulerService);
    storeManager.setRegistry(registry);
    storeManager.setMuleContext(muleContext);
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) Registry(org.mule.runtime.api.artifact.Registry) SimpleUnitTestSupportSchedulerService(org.mule.tck.SimpleUnitTestSupportSchedulerService) Before(org.junit.Before)

Aggregations

MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)11 Before (org.junit.Before)4 Test (org.junit.Test)4 DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)4 SmallTest (org.mule.tck.size.SmallTest)3 Registry (org.mule.runtime.api.artifact.Registry)2 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)2 AfterClass (org.junit.AfterClass)1 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)1 ErrorType (org.mule.runtime.api.message.ErrorType)1 Message (org.mule.runtime.api.message.Message)1 DataType (org.mule.runtime.api.metadata.DataType)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1 ExceptionContextProvider (org.mule.runtime.core.api.execution.ExceptionContextProvider)1 ProcessingStrategyFactory (org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory)1 Transformer (org.mule.runtime.core.api.transformer.Transformer)1 DefaultQueueConfiguration (org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration)1 DefaultMuleContext (org.mule.runtime.core.internal.context.DefaultMuleContext)1