use of org.springframework.scripting.support.StaticScriptSource in project spring-integration by spring-projects.
the class PythonScriptExecutorTests method testLiteral.
@Test
public void testLiteral() {
Object obj = executor.executeScript(new StaticScriptSource("3+4"));
assertEquals(7, obj);
obj = executor.executeScript(new StaticScriptSource("'hello,world'"));
assertEquals("hello,world", obj);
}
use of org.springframework.scripting.support.StaticScriptSource in project spring-integration by spring-projects.
the class PythonScriptExecutorTests method test1.
@Test
public void test1() {
Object obj = executor.executeScript(new StaticScriptSource("x=2"));
assertEquals(2, obj);
}
use of org.springframework.scripting.support.StaticScriptSource in project spring-integration by spring-projects.
the class Jsr223ScriptExecutorTests method testJs.
@Test
public void testJs() {
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("js");
Object obj = executor.executeScript(new StaticScriptSource("function js(){ return 'js';} js();"));
assertEquals("js", obj.toString());
}
use of org.springframework.scripting.support.StaticScriptSource in project spring-integration by spring-projects.
the class Jsr223ScriptExecutorTests method testPython.
@Test
public void testPython() {
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("python");
Object obj = executor.executeScript(new StaticScriptSource("x=2"));
assertEquals(2, obj);
obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)"));
assertEquals(2, obj);
}
use of org.springframework.scripting.support.StaticScriptSource 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"));
assertThat(result).isEqualTo(6);
}
Aggregations