Search in sources :

Example 6 with MVELExpressionLanguageContext

use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.

the class RegexExpressionLanguageFunctionTestCase method setup.

@Before
public void setup() throws InitialisationException {
    ParserConfiguration parserConfiguration = new ParserConfiguration();
    expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
    muleContext = mock(MuleContext.class);
    context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    regexFuntion = new RegexExpressionLanguageFuntion();
    context.declareFunction("regex", regexFuntion);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) MVELExpressionExecutor(org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserConfiguration(org.mule.mvel2.ParserConfiguration) Before(org.junit.Before)

Example 7 with MVELExpressionLanguageContext

use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.

the class WildcardExpressionLanguageFunctionTestCase method setup.

@Before
public void setup() throws InitialisationException {
    ParserConfiguration parserConfiguration = new ParserConfiguration();
    expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
    muleContext = mock(MuleContext.class);
    context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    wildcardFunction = new WildcardExpressionLanguageFuntion();
    context.declareFunction("wildcard", wildcardFunction);
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) MVELExpressionExecutor(org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserConfiguration(org.mule.mvel2.ParserConfiguration) Before(org.junit.Before)

Example 8 with MVELExpressionLanguageContext

use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.

the class AbstractVarAssignmentDataTypePropagatorTestCase method compileMelExpression.

private CompiledExpression compileMelExpression(String expression, PrivilegedEvent testEvent, PrivilegedEvent.Builder builder) {
    final ParserConfiguration parserConfiguration = MVELExpressionLanguage.createParserConfiguration(Collections.EMPTY_MAP);
    final MVELExpressionLanguageContext context = createMvelExpressionLanguageContext(testEvent, builder, parserConfiguration);
    CompiledExpression compiledExpression = (CompiledExpression) compileExpression(expression, new ParserContext(parserConfiguration));
    // Expression must be executed, otherwise the variable accessor is not properly configured
    MVEL.executeExpression(compiledExpression, context);
    return compiledExpression;
}
Also used : MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) ParserContext(org.mule.mvel2.ParserContext) CompiledExpression(org.mule.mvel2.compiler.CompiledExpression) ParserConfiguration(org.mule.mvel2.ParserConfiguration)

Example 9 with MVELExpressionLanguageContext

use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.

the class AbstractVarExpressionDataTypeResolverTestCase method createMvelExpressionLanguageContext.

protected MVELExpressionLanguageContext createMvelExpressionLanguageContext(PrivilegedEvent testEvent, ParserConfiguration parserConfiguration) {
    final MVELExpressionLanguageContext context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
    final StaticVariableResolverFactory staticContext = new StaticVariableResolverFactory(parserConfiguration, muleContext);
    final GlobalVariableResolverFactory globalContext = new GlobalVariableResolverFactory(Collections.EMPTY_MAP, Collections.EMPTY_MAP, parserConfiguration, muleContext);
    final DelegateVariableResolverFactory innerDelegate = new DelegateVariableResolverFactory(globalContext, new VariableVariableResolverFactory(parserConfiguration, muleContext, testEvent, PrivilegedEvent.builder(testEvent)));
    final DelegateVariableResolverFactory delegate = new DelegateVariableResolverFactory(staticContext, new MessageVariableResolverFactory(parserConfiguration, muleContext, testEvent, PrivilegedEvent.builder(testEvent), innerDelegate));
    context.setNextFactory(new CachedMapVariableResolverFactory(Collections.EMPTY_MAP, delegate));
    return context;
}
Also used : DelegateVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.DelegateVariableResolverFactory) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) GlobalVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.GlobalVariableResolverFactory) MessageVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.MessageVariableResolverFactory) CachedMapVariableResolverFactory(org.mule.mvel2.integration.impl.CachedMapVariableResolverFactory) StaticVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.StaticVariableResolverFactory) VariableVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.VariableVariableResolverFactory)

Aggregations

MVELExpressionLanguageContext (org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext)9 ParserConfiguration (org.mule.mvel2.ParserConfiguration)5 Before (org.junit.Before)3 MVELExpressionExecutor (org.mule.runtime.core.internal.el.mvel.MVELExpressionExecutor)3 Test (org.junit.Test)2 ParserContext (org.mule.mvel2.ParserContext)2 CompiledExpression (org.mule.mvel2.compiler.CompiledExpression)2 CachedMapVariableResolverFactory (org.mule.mvel2.integration.impl.CachedMapVariableResolverFactory)2 MuleContext (org.mule.runtime.core.api.MuleContext)2 DelegateVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.DelegateVariableResolverFactory)2 GlobalVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.GlobalVariableResolverFactory)2 MessageVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.MessageVariableResolverFactory)2 MuleBaseVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.MuleBaseVariableResolverFactory)2 StaticVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.StaticVariableResolverFactory)2 VariableVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.VariableVariableResolverFactory)2 MapVariableResolverFactory (org.mule.mvel2.integration.impl.MapVariableResolverFactory)1 SimpleValueResolver (org.mule.mvel2.integration.impl.SimpleValueResolver)1 DataType (org.mule.runtime.api.metadata.DataType)1 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)1