use of org.springframework.scripting.support.StandardScriptEvaluator in project spring-framework by spring-projects.
the class GroovyScriptEvaluatorTests method testGroovyScriptFromStringUsingJsr223.
@Test
public void testGroovyScriptFromStringUsingJsr223() {
StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
evaluator.setLanguage("Groovy");
Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
assertEquals(6, result);
}
use of org.springframework.scripting.support.StandardScriptEvaluator in project spring-framework by spring-projects.
the class GroovyScriptEvaluatorTests method testGroovyScriptFromFileUsingJsr223.
@Test
public void testGroovyScriptFromFileUsingJsr223() {
ScriptEvaluator evaluator = new StandardScriptEvaluator();
Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
assertEquals(6, result);
}
use of org.springframework.scripting.support.StandardScriptEvaluator in project spring-framework by spring-projects.
the class GroovyScriptEvaluatorTests method testGroovyScriptWithArgumentsUsingJsr223.
@Test
public void testGroovyScriptWithArgumentsUsingJsr223() {
StandardScriptEvaluator evaluator = new StandardScriptEvaluator();
evaluator.setLanguage("Groovy");
Map<String, Object> arguments = new HashMap<>();
arguments.put("a", 3);
arguments.put("b", 2);
Object result = evaluator.evaluate(new StaticScriptSource("return a * b"), arguments);
assertEquals(6, result);
}
Aggregations