use of org.springframework.scripting.support.StaticScriptSource in project spring-framework by spring-projects.
the class GroovyScriptEvaluatorTests method testGroovyScriptWithCompilerConfiguration.
@Test
public void testGroovyScriptWithCompilerConfiguration() {
GroovyScriptEvaluator evaluator = new GroovyScriptEvaluator();
MyBytecodeProcessor processor = new MyBytecodeProcessor();
evaluator.getCompilerConfiguration().setBytecodePostprocessor(processor);
Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
assertThat(result).isEqualTo(6);
assertThat(processor.processed.contains("Script1")).isTrue();
}
use of org.springframework.scripting.support.StaticScriptSource 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);
assertThat(result).isEqualTo(6);
}
use of org.springframework.scripting.support.StaticScriptSource in project spring-framework by spring-projects.
the class BshScriptEvaluatorTests method testGroovyScriptWithArguments.
@Test
public void testGroovyScriptWithArguments() {
ScriptEvaluator evaluator = new BshScriptEvaluator();
Map<String, Object> arguments = new HashMap<>();
arguments.put("a", 3);
arguments.put("b", 2);
Object result = evaluator.evaluate(new StaticScriptSource("return a * b;"), arguments);
assertThat(result).isEqualTo(6);
}
Aggregations