use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testInlineWith3.
public void testInlineWith3() {
CompiledExpression expr = new ExpressionCompiler("foo.{name = 'poopy', aValue = 'bar', bar.{name = 'foobie'}, toUC('doopy')}").compile();
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
assertEquals("foobie", f.getBar().getName());
assertEquals("doopy", f.register);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testExecuteCoercionTwice.
public void testExecuteCoercionTwice() {
OptimizerFactory.setDefaultOptimizer("reflective");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("foo", new Foo());
vars.put("$value", new Long(5));
ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };");
ParserContext ctx = new ParserContext();
ctx.setSourceFile("test.mv");
ctx.setDebugSymbols(true);
CompiledExpression compiled = compiler.compile(ctx);
executeExpression(compiled, null, vars);
executeExpression(compiled, null, vars);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testExecuteCoercionTwice2.
public void testExecuteCoercionTwice2() {
OptimizerFactory.setDefaultOptimizer("ASM");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("foo", new Foo());
vars.put("$value", new Long(5));
ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };");
ParserContext ctx = new ParserContext();
ctx.setSourceFile("test.mv");
ctx.setDebugSymbols(true);
CompiledExpression compiled = compiler.compile(ctx);
executeExpression(compiled, null, vars);
executeExpression(compiled, null, vars);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class WithTests method testInlineWith5.
public void testInlineWith5() {
OptimizerFactory.setDefaultOptimizer("ASM");
ParserContext pCtx = new ParserContext();
pCtx.setStrongTyping(true);
pCtx.addInput("foo", Foo.class);
CompiledExpression expr = new ExpressionCompiler("foo.{name='poopy', aValue='bar'}").compile(pCtx);
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mikebrock.
the class MutationsTests method testDeepAssignment2.
public void testDeepAssignment2() {
Map map = createTestMap();
ExpressionCompiler compiler = new ExpressionCompiler("foo.bar.age = 21");
ParserContext ctx = new ParserContext();
ctx.addInput("foo", Foo.class);
ctx.setStrongTyping(true);
CompiledExpression ce = compiler.compile(ctx);
executeExpression(ce, map);
assertEquals(((Foo) map.get("foo")).getBar().getAge(), 21);
}
Aggregations