use of org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationWithExpressionInTargetParameter.
@Test
public void operationWithExpressionInTargetParameter() throws Exception {
String flowName = FLOW_NAME;
expectedException.expect(IllegalOperationException.class);
expectedException.expectMessage(format(INVALID_TARGET_MESSAGE, flowName, operationModel.getName(), "an expression", TARGET_PARAMETER_NAME));
target = "#[mel:someExpression]";
messageProcessor = createOperationMessageProcessor();
registerIntoMockContext(context, OBJECT_EXPRESSION_LANGUAGE, new MVELExpressionLanguage(context));
registerIntoMockContext(context, DefaultExpressionLanguageFactoryService.class, new WeaveDefaultExpressionLanguageFactoryService());
doReturn(new DefaultExpressionManager()).when(context).getExpressionManager();
FlowConstruct flowConstruct = mock(FlowConstruct.class);
when(flowConstruct.getName()).thenReturn(flowName);
messageProcessor.setMuleContext(context);
messageProcessor.initialise();
}
use of org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService 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.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService 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));
}
}
Aggregations