use of org.mvel2.tests.core.res.Base in project mvel by mikebrock.
the class PropertyHandlerTests method testListPropertyHandler2.
public void testListPropertyHandler2() {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
Serializable s = MVEL.compileSetExpression("list[0]");
Base b;
MVEL.executeSetExpression(s, new Base(), "hey you");
MVEL.executeSetExpression(s, b = new Base(), "hey you");
assertEquals("set", b.list.get(0));
}
use of org.mvel2.tests.core.res.Base in project mvel by mikebrock.
the class PropertyHandlerTests method testListPropertyHandler3.
public void testListPropertyHandler3() {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
OptimizerFactory.setDefaultOptimizer("ASM");
Serializable s = MVEL.compileSetExpression("list[0]");
Base b;
MVEL.executeSetExpression(s, new Base(), "hey you");
MVEL.executeSetExpression(s, b = new Base(), "hey you");
assertEquals("set", b.list.get(0));
}
use of org.mvel2.tests.core.res.Base in project mvel by mikebrock.
the class PropertyHandlerTests method testListPropertyHandler4.
public void testListPropertyHandler4() {
MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
OptimizerFactory.setDefaultOptimizer("ASM");
final String[] res = new String[1];
GlobalListenerFactory.registerGetListener(new Listener() {
public void onEvent(Object context, String contextName, VariableResolverFactory variableFactory, Object value) {
System.out.println("Listener Fired:" + contextName);
res[0] = contextName;
}
});
Serializable s = MVEL.compileSetExpression("list[0]");
Base b;
MVEL.executeSetExpression(s, new Base(), "hey you");
res[0] = null;
MVEL.executeSetExpression(s, b = new Base(), "hey you");
assertEquals("set", b.list.get(0));
assertEquals("list", res[0]);
}
use of org.mvel2.tests.core.res.Base in project mvel by mikebrock.
the class ProjectionsTests method testProjectionSupport3.
public void testProjectionSupport3() {
String ex = "(toUpperCase() in ['bar', 'foo'])[1]";
Map vars = createTestMap();
assertEquals("FOO", MVEL.eval(ex, new Base(), vars));
assertEquals("FOO", test("(toUpperCase() in ['bar', 'foo'])[1]"));
}
use of org.mvel2.tests.core.res.Base in project mvel by mikebrock.
the class TemplateTests method testInclusionOfNamedTemplate.
// public void testTemplateFile2() {
// String s = (String) TemplateRuntime.eval(new File("src/test/java/org/mvel2/tests/templates/templateDeclareTest.mv"),
// base, new MapVariableResolverFactory(map), null);
//
// System.out.println(s);
//
// }
public void testInclusionOfNamedTemplate() {
SimpleTemplateRegistry registry = new SimpleTemplateRegistry();
registry.addNamedTemplate("footemplate", compileTemplate("@{_foo_}@{_bar_}"));
registry.addNamedTemplate("bartemplate", compileTemplate("@{_bar_}@{_foo_}"));
String s = "@includeNamed{'footemplate'} :: @includeNamed{'bartemplate'}";
assertEquals("FooBar :: BarFoo", TemplateRuntime.eval(s, map, registry));
}
Aggregations