Search in sources :

Example 6 with WeaveDefaultExpressionLanguageFactoryService

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();
}
Also used : WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) DefaultExpressionManager(org.mule.runtime.core.internal.el.DefaultExpressionManager) FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) MVELExpressionLanguage(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 7 with WeaveDefaultExpressionLanguageFactoryService

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);
}
Also used : WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) DefaultExpressionLanguageFactoryService(org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService) WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) Service(org.mule.runtime.api.service.Service) DefaultExpressionLanguageFactoryService(org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService) WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) MuleException(org.mule.runtime.api.exception.MuleException)

Example 8 with WeaveDefaultExpressionLanguageFactoryService

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));
    }
}
Also used : WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) HttpService(org.mule.runtime.http.api.HttpService) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) DefaultExpressionLanguageFactoryService(org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService) WeaveDefaultExpressionLanguageFactoryService(org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService) ExpressionLanguage(org.mule.runtime.api.el.ExpressionLanguage)

Aggregations

WeaveDefaultExpressionLanguageFactoryService (org.mule.weave.v2.el.WeaveDefaultExpressionLanguageFactoryService)8 Test (org.junit.Test)4 DefaultExpressionLanguageFactoryService (org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService)3 Registry (org.mule.runtime.api.artifact.Registry)2 Message (org.mule.runtime.api.message.Message)2 TypedValue (org.mule.runtime.api.metadata.TypedValue)2 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)2 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)2 DefaultExpressionManager (org.mule.runtime.core.internal.el.DefaultExpressionManager)2 ExpressionLanguageAdaptor (org.mule.runtime.core.internal.el.ExpressionLanguageAdaptor)2 DataWeaveExpressionLanguageAdaptor (org.mule.runtime.core.internal.el.dataweave.DataWeaveExpressionLanguageAdaptor)2 MVELExpressionLanguage (org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguage)2 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)2 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)2 SmallTest (org.mule.tck.size.SmallTest)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 ExpressionLanguage (org.mule.runtime.api.el.ExpressionLanguage)1 MuleException (org.mule.runtime.api.exception.MuleException)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1