Search in sources :

Example 1 with MuleBaseVariableResolverFactory

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

the class MVELExpressionLanguageContextTestCase method testGetVariableResolver.

@Test
public void testGetVariableResolver() {
    MuleBaseVariableResolverFactory resoverFactory = new MVELExpressionLanguageContext(parserConfig, muleContext);
    resoverFactory.addResolver("foo", new SimpleValueResolver("val"));
    assertNotNull(resoverFactory.getVariableResolver("foo"));
    assertEquals("val", resoverFactory.getVariableResolver("foo").getValue());
    assertNull(resoverFactory.getVariableResolver("bar"));
}
Also used : MuleBaseVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.MuleBaseVariableResolverFactory) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) SimpleValueResolver(org.mule.mvel2.integration.impl.SimpleValueResolver) Test(org.junit.Test)

Example 2 with MuleBaseVariableResolverFactory

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

the class MVELExpressionLanguageContextTestCase method testGetVariableResolverNextFactory.

@Test
public void testGetVariableResolverNextFactory() {
    parserConfig.addImport(String.class);
    MuleBaseVariableResolverFactory resoverFactory = new MVELExpressionLanguageContext(parserConfig, muleContext);
    resoverFactory.setNextFactory(new MapVariableResolverFactory(Collections.singletonMap("foo", "val")));
    assertNotNull(resoverFactory.getVariableResolver("foo"));
    assertEquals("val", resoverFactory.getVariableResolver("foo").getValue());
    assertNull(resoverFactory.getVariableResolver("bar"));
}
Also used : MuleBaseVariableResolverFactory(org.mule.runtime.core.internal.el.mvel.MuleBaseVariableResolverFactory) MVELExpressionLanguageContext(org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext) MapVariableResolverFactory(org.mule.mvel2.integration.impl.MapVariableResolverFactory) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MVELExpressionLanguageContext (org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext)2 MuleBaseVariableResolverFactory (org.mule.runtime.core.internal.el.mvel.MuleBaseVariableResolverFactory)2 MapVariableResolverFactory (org.mule.mvel2.integration.impl.MapVariableResolverFactory)1 SimpleValueResolver (org.mule.mvel2.integration.impl.SimpleValueResolver)1