use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testInstanceofOnInnerClass.
public void testInstanceofOnInnerClass() {
ParserConfiguration conf = new ParserConfiguration();
conf.addImport(ARef.class);
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 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 testEmptyOperatorOnInteger.
public void testEmptyOperatorOnInteger() {
ParserConfiguration conf = new ParserConfiguration();
ParserContext pctx = new ParserContext(conf);
pctx.setStrictTypeEnforcement(true);
pctx.setStrongTyping(true);
pctx.addInput("nullInt", Integer.class);
pctx.addInput("zero", Integer.class);
pctx.addInput("nonZero", Integer.class);
Map vars = new HashMap() {
{
put("nullInt", null);
put("zero", 0);
put("nonZero", 42);
}
};
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("nullInt == empty", pctx), vars));
assertEquals(true, MVEL.executeExpression(MVEL.compileExpression("zero == empty", pctx), vars));
assertEquals(false, MVEL.executeExpression(MVEL.compileExpression("nonZero == empty", pctx), vars));
}
use of org.mule.mvel2.ParserConfiguration in project mvel by mvel.
the class CoreConfidenceTests method testStaticMethodsInvocationWithNullArg.
public void testStaticMethodsInvocationWithNullArg() {
String str = "org.mvel2.tests.core.CoreConfidenceTests$MyObj.doSomething(null, \"abc\")";
ParserConfiguration pconf = new ParserConfiguration();
ParserContext pctx = new ParserContext(pconf);
pctx.setStrongTyping(true);
assertEquals(null + "abc", MVEL.executeExpression(MVEL.compileExpression(str, pctx)));
}
Aggregations