use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testMapsWithVariableAsKey.
public void testMapsWithVariableAsKey() {
String ex = "aMap[aKey] == 'aValue'";
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(false);
ExpressionCompiler compiler = new ExpressionCompiler(ex);
compiler.setVerifyOnly(true);
compiler.compile(ctx);
Set<String> requiredInputs = compiler.getParserContextState().getInputs().keySet();
assertTrue(requiredInputs.contains("aMap"));
assertTrue(requiredInputs.contains("aKey"));
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testDynamicImportsOnNestedExpressions.
public void testDynamicImportsOnNestedExpressions() {
ParserContext ctx = new ParserContext();
ctx.addPackageImport("org.mvel2.tests.core.res");
ExpressionCompiler compiler = new ExpressionCompiler("new Cheesery(\"bobbo\", new Cheese(\"cheddar\", 15))");
Cheesery p1 = new Cheesery("bobbo", new Cheese("cheddar", 15));
Cheesery p2 = (Cheesery) executeExpression(compiler.compile(ctx), new DefaultLocalVariableResolverFactory());
assertEquals(p1, p2);
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testDynamicImportsInList.
public void testDynamicImportsInList() {
ParserContext ctx = new ParserContext();
ctx.addPackageImport("org.mvel2.tests.core.res");
ExpressionCompiler compiler = new ExpressionCompiler("[ new User('Bobba', 'Feta') ]");
List list = (List) executeExpression(compiler.compile(ctx));
User user = (User) list.get(0);
assertEquals("Bobba", user.getFirstName());
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testDynamicImportsWithIdentifierSameAsClassWithDiffCase.
public void testDynamicImportsWithIdentifierSameAsClassWithDiffCase() {
ParserContext ctx = new ParserContext();
ctx.addPackageImport("org.mvel2.tests.core.res");
ctx.setStrictTypeEnforcement(false);
ExpressionCompiler compiler = new ExpressionCompiler("bar.add(\"hello\")");
compiler.compile(ctx);
}
use of org.mule.mvel2.compiler.ExpressionCompiler in project mvel by mikebrock.
the class CoreConfidenceTests method testParserErrorHandling.
public void testParserErrorHandling() {
final ParserContext ctx = new ParserContext();
ExpressionCompiler compiler = new ExpressionCompiler("a[");
try {
compiler.compile(ctx);
} catch (Exception e) {
return;
}
assertTrue(false);
}
Aggregations