use of org.mvel2.integration.impl.ClassImportResolverFactory in project mvel by mvel.
the class CoreConfidenceTests method testCheeseConstructor.
// public void testClassImportViaFactory() {
// MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
// ClassImportResolverFactory classes = new ClassImportResolverFactory();
// classes.addClass(HashMap.class);
//
// ResolverTools.appendFactory(mvf, classes);
//
// assertTrue(executeExpression(compileExpression("HashMap map = new HashMap()",
// classes.getImportedClasses()),
// mvf) instanceof HashMap);
// }
//
// public void testSataticClassImportViaFactory() {
// MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
// ClassImportResolverFactory classes = new ClassImportResolverFactory();
// classes.addClass(Person.class);
//
// ResolverTools.appendFactory(mvf,
// classes);
//
// assertEquals("tom",
// executeExpression(compileExpression("p = new Person('tom'); return p.name;",
// classes.getImportedClasses()),
// mvf));
// }
public void testCheeseConstructor() {
MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
ClassImportResolverFactory classes = new ClassImportResolverFactory(null, null, false);
classes.addClass(Cheese.class);
ResolverTools.appendFactory(mvf, classes);
assertTrue(executeExpression(compileExpression("cheese = new Cheese(\"cheddar\", 15);", classes.getImportedClasses()), mvf) instanceof Cheese);
}
use of org.mvel2.integration.impl.ClassImportResolverFactory in project mvel by mvel.
the class WithTests method testSataticClassImportViaFactoryAndWithModification.
public void testSataticClassImportViaFactoryAndWithModification() {
OptimizerFactory.setDefaultOptimizer("ASM");
MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
ClassImportResolverFactory classes = new ClassImportResolverFactory(null, null, false);
classes.addClass(Person.class);
ResolverTools.appendFactory(mvf, classes);
assertEquals(21, executeExpression(compileExpression("p = new Person('tom'); p.age = 20; " + "with( p ) { age = p.age + 1 }; return p.age;", classes.getImportedClasses()), mvf));
}
use of org.mvel2.integration.impl.ClassImportResolverFactory in project mvel by mikebrock.
the class CoreConfidenceTests method testCheeseConstructor.
// public void testClassImportViaFactory() {
// MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
// ClassImportResolverFactory classes = new ClassImportResolverFactory();
// classes.addClass(HashMap.class);
//
// ResolverTools.appendFactory(mvf, classes);
//
// assertTrue(executeExpression(compileExpression("HashMap map = new HashMap()",
// classes.getImportedClasses()),
// mvf) instanceof HashMap);
// }
//
// public void testSataticClassImportViaFactory() {
// MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
// ClassImportResolverFactory classes = new ClassImportResolverFactory();
// classes.addClass(Person.class);
//
// ResolverTools.appendFactory(mvf,
// classes);
//
// assertEquals("tom",
// executeExpression(compileExpression("p = new Person('tom'); return p.name;",
// classes.getImportedClasses()),
// mvf));
// }
public void testCheeseConstructor() {
MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
ClassImportResolverFactory classes = new ClassImportResolverFactory();
classes.addClass(Cheese.class);
ResolverTools.appendFactory(mvf, classes);
assertTrue(executeExpression(compileExpression("cheese = new Cheese(\"cheddar\", 15);", classes.getImportedClasses()), mvf) instanceof Cheese);
}
use of org.mvel2.integration.impl.ClassImportResolverFactory in project mvel by mikebrock.
the class WithTests method testSataticClassImportViaFactoryAndWithModification.
public void testSataticClassImportViaFactoryAndWithModification() {
OptimizerFactory.setDefaultOptimizer("ASM");
MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
ClassImportResolverFactory classes = new ClassImportResolverFactory();
classes.addClass(Person.class);
ResolverTools.appendFactory(mvf, classes);
assertEquals(21, executeExpression(compileExpression("p = new Person('tom'); p.age = 20; " + "with( p ) { age = p.age + 1 }; return p.age;", classes.getImportedClasses()), mvf));
}
Aggregations