use of org.mule.mvel2.integration.impl.MapVariableResolverFactory in project mvel by mikebrock.
the class CoreConfidenceTests method testSysoutNullVariable.
public void testSysoutNullVariable() {
// Create our root Map object
Map<String, String> map = new HashMap<String, String>();
map.put("foo", null);
VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
factory.createVariable("this", map);
org.mvel2.MVEL.executeExpression(org.mvel2.MVEL.compileExpression("System.out.println(foo);"), map, factory);
}
use of org.mule.mvel2.integration.impl.MapVariableResolverFactory in project mvel by mikebrock.
the class CoreConfidenceTests method testMVEL187.
public void testMVEL187() {
ParserContext context = new ParserContext();
context.addPackageImport("test");
context.addInput("outer", Outer.class);
Object compiled = MVEL.compileExpression("outer.getInner().getValue()", context);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("outer", new Outer());
VariableResolverFactory varsResolver = new MapVariableResolverFactory(vars);
assertEquals(2, executeExpression(compiled, varsResolver));
}
use of org.mule.mvel2.integration.impl.MapVariableResolverFactory in project mvel by mikebrock.
the class CoreConfidenceTests method testThisReferenceMapVirtualObjects1.
// compiled - reflective
public void testThisReferenceMapVirtualObjects1() {
// Create our root Map object
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
VariableResolverFactory factory = new MapVariableResolverFactory(new HashMap<String, Object>());
factory.createVariable("this", map);
OptimizerFactory.setDefaultOptimizer("reflective");
// Run test
assertEquals(true, executeExpression(compileExpression("this.foo == 'bar'"), map, factory));
}
use of org.mule.mvel2.integration.impl.MapVariableResolverFactory in project mvel by mikebrock.
the class CoreConfidenceTests method testTestIntToLong.
public void testTestIntToLong() {
String s = "1+(long)a";
ParserContext pc = new ParserContext();
pc.addInput("a", Integer.class);
ExpressionCompiler compiler = new ExpressionCompiler(s, pc);
CompiledExpression expr = compiler.compile();
Map vars = new HashMap();
vars.put("a", 1);
Object r = ((ExecutableStatement) expr).getValue(null, new MapVariableResolverFactory(vars));
assertEquals(new Long(2), r);
}
use of org.mule.mvel2.integration.impl.MapVariableResolverFactory in project mvel by mikebrock.
the class CompiledPerformanceTests method testQuickSort.
public void testQuickSort() throws IOException {
Serializable s = MVEL.compileExpression(new String(ParseTools.loadFromFile(new File("samples/scripts/fquicksort.mvel"))));
HashMap map = new HashMap();
MapVariableResolverFactory mvrf = new MapVariableResolverFactory(map);
for (int i = 0; i < 1000000; i++) {
MVEL.executeExpression(s, mvrf);
mvrf.clear();
}
// for (int x = 0; x < 4; x++) {
// Serializable s = MVEL.compileSetExpression("tak.bar.name");
// long time = System.currentTimeMillis();
//
// for (int i = 0; i < ITERATIONS; i++) {
// MVEL.executeSetExpression(s, map, "foobie");
// }
//
// System.out.println("SET PERFORMANCE: " + (System.currentTimeMillis() - time));
//
// time = System.currentTimeMillis();
//
// s = MVEL.compileExpression("tak.bar.name");
//
// for (int i = 0; i < ITERATIONS; i++) {
// MVEL.executeExpression(s, map);
// }
//
// System.out.println("GET PERFORMANCE: " + (System.currentTimeMillis() - time));
//
// }
}
Aggregations