use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testContextObjMethodCall.
public void testContextObjMethodCall() {
String str = "getName() == \"bob\"";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("this", Bar.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
Bar ctx = new Bar();
ctx.setName("bob");
Boolean result = (Boolean) MVEL.executeExpression(stmt, ctx);
assertTrue(result);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testInstanceofWithPackageImportAndInnerClass.
public void testInstanceofWithPackageImportAndInnerClass() {
ParserConfiguration conf = new ParserConfiguration();
conf.addPackageImport("org.mvel2.tests.core.CoreConfidenceTests");
ParserContext pctx = new ParserContext(conf);
pctx.setStrictTypeEnforcement(true);
pctx.setStrongTyping(true);
pctx.addInput("value", Object.class);
Map vars = new HashMap() {
{
put("value", new ARef());
}
};
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("value instanceof ARef", pctx), vars));
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("value instanceof " + ARef.class.getCanonicalName(), pctx), vars));
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testFullyQualifiedEnums.
public void testFullyQualifiedEnums() {
String str = "System.out.println( STATIC_ENUM.FOO ); \n" + "System.out.println( org.mvel2.tests.core.res.MyInterface$STATIC_ENUM.BAR );\n" + "System.out.println( org.mvel2.tests.core.res.MyInterface.MyInnerInterface.INNER_STATIC_ENUM.BAR );\n" + "System.out.println( RoundingMode.UP );\n" + "System.out.println( java.math.RoundingMode.DOWN );";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("this", MyInterface.class);
pctx.addImport(MyInterface.STATIC_ENUM.class);
pctx.addImport(java.math.RoundingMode.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
}
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);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class ArithmeticTests method testMathCeil.
public void testMathCeil() {
String str = "Math.ceil( x/3.0 ) == 2";
ParserConfiguration pconf = new ParserConfiguration();
pconf.addImport("Math", Math.class);
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("x", int.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
Map vars = new HashMap();
vars.put("x", 4);
Boolean result = (Boolean) MVEL.executeExpression(stmt, vars);
assertTrue(result);
}
Aggregations