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'");
}
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);
}
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);
}
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);
}
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);
}
Aggregations