Search in sources :

Example 1 with Thing

use of org.mvel2.tests.core.res.Thing in project mvel by mikebrock.

the class WithTests method testWithAndEnumInPackageImport.

public void testWithAndEnumInPackageImport() {
    ParserConfiguration pconf = new ParserConfiguration();
    pconf.addPackageImport(MyEnum.class.getPackage().getName());
    ParserContext pCtx = new ParserContext(pconf);
    pCtx.setStrongTyping(true);
    pCtx.addInput("thing", Thing.class);
    Thing thing = new Thing("xxx");
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("thing", thing);
    ExecutableStatement stmt = (ExecutableStatement) MVEL.compileExpression("with( thing ) { myEnum = MyEnum.FULL_DOCUMENTATION }", pCtx);
    MVEL.executeExpression(stmt, null, vars);
    assertEquals(MyEnum.FULL_DOCUMENTATION, thing.getMyEnum());
}
Also used : ExecutableStatement(org.mvel2.compiler.ExecutableStatement) ParserContext(org.mvel2.ParserContext) Thing(org.mvel2.tests.core.res.Thing) ParserConfiguration(org.mvel2.ParserConfiguration)

Aggregations

ParserConfiguration (org.mvel2.ParserConfiguration)1 ParserContext (org.mvel2.ParserContext)1 ExecutableStatement (org.mvel2.compiler.ExecutableStatement)1 Thing (org.mvel2.tests.core.res.Thing)1