Search in sources :

Example 1 with Registry

use of org.mule.runtime.api.artifact.Registry 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 2 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class CompositeDeploymentListenerTestCase method testNotifiesMuleContextInitialised.

@Test
public void testNotifiesMuleContextInitialised() throws Exception {
    Registry registry = mock(Registry.class);
    compositeDeploymentListener.onArtifactInitialised(APP_NAME, registry);
    verify(listener1, times(1)).onArtifactInitialised(APP_NAME, registry);
    verify(listener2, times(1)).onArtifactInitialised(APP_NAME, registry);
}
Also used : Registry(org.mule.runtime.api.artifact.Registry) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 3 with Registry

use of org.mule.runtime.api.artifact.Registry 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)

Example 4 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class ServerNotificationManagerConfiguratorTestCase method before.

@Before
public void before() {
    registry = mock(Registry.class);
    notificationManager = mock(ServerNotificationManager.class);
    context = mock(MuleContext.class);
    doReturn(notificationManager).when(context).getNotificationManager();
    configurator = new ServerNotificationManagerConfigurator();
    configurator.setMuleContext(context);
    configurator.setRegistry(registry);
    final ApplicationContext springContext = mock(ApplicationContext.class);
    doReturn(new String[0]).when(springContext).getBeanNamesForType(NotificationListener.class, false, true);
    configurator.setApplicationContext(springContext);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) ApplicationContext(org.springframework.context.ApplicationContext) Registry(org.mule.runtime.api.artifact.Registry) ServerNotificationManager(org.mule.runtime.core.api.context.notification.ServerNotificationManager) ServerNotificationManagerConfigurator(org.mule.runtime.config.internal.ServerNotificationManagerConfigurator) Before(org.junit.Before)

Example 5 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class DefaultExpressionManagerTestCase method managedCursor.

@Test
public void managedCursor() throws Exception {
    final DefaultExpressionLanguageFactoryService mockFactory = mock(DefaultExpressionLanguageFactoryService.class, RETURNS_DEEP_STUBS);
    final ExpressionLanguage expressionLanguage = mock(ExpressionLanguage.class, RETURNS_DEEP_STUBS);
    final CursorProvider cursorProvider = mock(CursorProvider.class);
    Registry registry = mock(Registry.class);
    when(registry.lookupByType(DefaultExpressionLanguageFactoryService.class)).thenReturn(of(mockFactory));
    when(registry.lookupByName(OBJECT_EXPRESSION_LANGUAGE)).thenReturn(of(mock(MVELExpressionLanguage.class, RETURNS_DEEP_STUBS)));
    when(registry.lookupByName(COMPATIBILITY_PLUGIN_INSTALLED)).thenReturn(empty());
    TypedValue value = new TypedValue(cursorProvider, BYTE_ARRAY);
    when(expressionLanguage.evaluate(anyString(), any())).thenReturn(value);
    when(expressionLanguage.evaluate(anyString(), any(), any())).thenReturn(value);
    when(mockFactory.create()).thenReturn(expressionLanguage);
    expressionManager = new DefaultExpressionManager();
    ((DefaultExpressionManager) expressionManager).setRegistry(registry);
    ((DefaultExpressionManager) expressionManager).setStreamingManager(streamingManager);
    initialiseIfNeeded(expressionManager, false, muleContext);
    final CoreEvent event = testEvent();
    when(streamingManager.manage(cursorProvider, event)).thenReturn(cursorProvider);
    expressionManager.evaluate("someExpression", event);
    verify(streamingManager).manage(cursorProvider, event);
}
Also used : CursorProvider(org.mule.runtime.api.streaming.CursorProvider) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DefaultExpressionLanguageFactoryService(org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService) Registry(org.mule.runtime.api.artifact.Registry) MVELExpressionLanguage(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage) ExpressionLanguage(org.mule.runtime.api.el.ExpressionLanguage) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Aggregations

Registry (org.mule.runtime.api.artifact.Registry)10 Test (org.junit.Test)4 Before (org.junit.Before)3 MuleContext (org.mule.runtime.core.api.MuleContext)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Optional (java.util.Optional)2 TypedValue (org.mule.runtime.api.metadata.TypedValue)2 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)2 IOUtils (org.mule.runtime.core.api.util.IOUtils)2 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Issue (io.qameta.allure.Issue)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Thread.currentThread (java.lang.Thread.currentThread)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1