use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testMinusOperatorWithoutSpace.
public void testMinusOperatorWithoutSpace() {
String str = "length == $c.length -1";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
Column col1 = new Column("x", 0);
Column col2 = new Column("x", 0);
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("$c", col2);
Boolean result = (Boolean) MVEL.executeExpression(stmt, col1, vars);
assertFalse(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 testEmptyConstructorWithSpace.
public void testEmptyConstructorWithSpace() throws Exception {
ParserConfiguration pconf = new ParserConfiguration();
pconf.addImport("getString", StaticClassWithStaticMethod.class.getMethod("getString", null));
String text = "getString( )";
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.setStrictTypeEnforcement(true);
MVEL.compileExpression(text, pctx);
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testGenericsMap.
public void testGenericsMap() throws Exception {
try {
String str = "triangle.deliveries[0].containsKey( \"x\" )";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
pctx.addInput("triangle", Triangle.class);
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
} catch (Exception e) {
// it should not raise CCE
e.printStackTrace();
throw e;
}
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testStrTriangleEqualsEquals.
public void testStrTriangleEqualsEquals() {
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
try {
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.addInput("this", Triangle.class);
pctx.setStrongTyping(true);
String str = "this.strLabel == this";
try {
ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression(str, pctx);
fail("should have failed");
} catch (CompileException e) {
System.out.println();
return;
}
} finally {
MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = false;
}
}
Aggregations