use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testWithInsideBlock.
public void testWithInsideBlock() {
String str = "Foo f = new Foo(); with(f) { setBoolTest( true ) }; f.isBoolTest()";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("this", Bar.class);
pctx.addImport(Foo.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
Bar ctx = new Bar();
Boolean result = (Boolean) MVEL.executeExpression(stmt, ctx, new HashMap());
assertTrue(result);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testMapAccessWithNestedMethodCall.
public void testMapAccessWithNestedMethodCall() {
String str = "map[aMethod(1)] == \"one\"";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("this", POJO.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
POJO ctx = new POJO();
ctx.getMap().put("1", "one");
Boolean result = (Boolean) MVEL.executeExpression(stmt, ctx);
assertTrue(result);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testEmptyOperatorOnBoolean.
public void testEmptyOperatorOnBoolean() {
ParserConfiguration conf = new ParserConfiguration();
ParserContext pctx = new ParserContext(conf);
pctx.setStrictTypeEnforcement(true);
pctx.setStrongTyping(true);
pctx.addInput("bNull", Boolean.class);
pctx.addInput("bTrue", Boolean.class);
pctx.addInput("bFalse", Boolean.class);
Map vars = new HashMap() {
{
put("bNull", null);
put("bTrue", true);
put("bFalse", false);
}
};
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("bNull == empty", pctx), vars));
assertEquals(false, MVEL.executeExpression(MVEL.compileExpression("bTrue == empty", pctx), vars));
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("bFalse == empty", pctx), vars));
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testMethodReturningPrimitiveTypeAnalysis.
public void testMethodReturningPrimitiveTypeAnalysis() {
String str = "value";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.addInput("this", MyObj.class);
pctx.setStrongTyping(true);
Class<?> returnType = MVEL.analyze(str, pctx);
assertEquals(long.class, returnType);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testJavaLangImport.
public void testJavaLangImport() throws Exception {
String s = "Exception e = null;";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
MVEL.compileExpression(s, pctx);
}
Aggregations