use of org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method payloadExpressionShouldNotBeEvaluate.
@Test
public void payloadExpressionShouldNotBeEvaluate() throws MuleException {
BindingContext bindingContext = BindingContext.builder().build();
MuleContext muleContext = mock(MuleContext.class);
DefaultExpressionLanguageFactoryService languageFactory = mock(DefaultExpressionLanguageFactoryService.class);
ExpressionLanguage expressionLanguage = spy(ExpressionLanguage.class);
when(languageFactory.create()).thenReturn(expressionLanguage);
CoreEvent event = testEvent();
new DataWeaveExpressionLanguageAdaptor(muleContext, registry, languageFactory).evaluate("#[payload]", event, bindingContext);
verify(expressionLanguage, never()).evaluate(eq("payload"), any(BindingContext.class));
}
use of org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService in project mule by mulesoft.
the class GlobalBindingContextProviderTestCase method getStartUpRegistryObjects.
@Override
protected Map<String, Object> getStartUpRegistryObjects() {
Map<String, Object> objects = new HashMap<>();
DefaultExpressionLanguageFactoryService weaveExpressionExecutor = new WeaveDefaultExpressionLanguageFactoryService();
objects.put(weaveExpressionExecutor.getName(), weaveExpressionExecutor);
objects.put(KEY, new TestGlobalBindingContextProvider());
return objects;
}
use of org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService in project mule by mulesoft.
the class BasicRuntimeServicesConfigurationBuilder method doConfigure.
@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
new SpiServiceRegistry().lookupProviders(Service.class, BasicRuntimeServicesConfigurationBuilder.class.getClassLoader()).forEach(service -> {
try {
startIfNeeded(service);
registerObject(muleContext, service.getName(), service);
} catch (MuleException e) {
throw new MuleRuntimeException(e);
}
});
DefaultExpressionLanguageFactoryService weaveExpressionExecutor = new WeaveDefaultExpressionLanguageFactoryService();
registerObject(muleContext, weaveExpressionExecutor.getName(), weaveExpressionExecutor);
}
use of org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService in project mule by mulesoft.
the class TestServicesConfigurationBuilder method doConfigure.
@Override
public void doConfigure(MuleContext muleContext) throws Exception {
MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
registry.registerObject(schedulerService.getName(), spy(schedulerService));
registry.registerObject(OBJECT_SCHEDULER_BASE_CONFIG, config());
if (mockExpressionExecutor) {
DefaultExpressionLanguageFactoryService expressionExecutor = mock(DefaultExpressionLanguageFactoryService.class, RETURNS_DEEP_STUBS);
registry.registerObject(MOCK_EXPR_EXECUTOR, expressionExecutor);
} else {
// Avoid doing the DW warm-up for every test, reusing the ExpressionLanguage implementation
if (cachedExprLanguageFactory == null) {
final DefaultExpressionLanguageFactoryService exprExecutor = new WeaveDefaultExpressionLanguageFactoryService();
ExpressionLanguage exprLanguage = exprExecutor.create();
// Force initialization of internal DataWeave stuff
// This way we avoid doing some heavy initialization on the test itself,
// which may cause trouble when evaluation expressions in places with small timeouts
exprLanguage.evaluate("{dataWeave: 'is'} ++ {mule: 'default EL'}", NULL_BINDING_CONTEXT);
cachedExprLanguageFactory = new DefaultExpressionLanguageFactoryService() {
@Override
public ExpressionLanguage create() {
return exprLanguage;
}
@Override
public String getName() {
return exprExecutor.getName();
}
};
}
registry.registerObject(cachedExprLanguageFactory.getName(), cachedExprLanguageFactory);
}
if (mockHttpService) {
registry.registerObject(MOCK_HTTP_SERVICE, mock(HttpService.class));
}
}
use of org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService 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